Skip to content

Migrate packaging to a pyproject.toml file and add wheel deployment #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,41 @@ concurrency:

jobs:
build:
name: Build source distribution
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Build the sdist
python-version: "3.9"
- name: Install build dependencies
run: |
python setup.py sdist
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist and wheel
run: |
python -m build
- name: Check the sdist installs and imports
run: |
mkdir -p test-sdist
cd test-sdist
python -m venv venv-sdist
venv-sdist/bin/python -m pip install ../dist/cons-*.tar.gz
- uses: actions/upload-artifact@v2
- name: Check the wheel installs and imports
run: |
mkdir -p test-wheel
cd test-wheel
python -m venv venv-wheel
venv-wheel/bin/python -m pip install ../dist/cons-*.whl
- uses: actions/upload-artifact@v4
with:
name: artifact
path: dist/*

upload_pypi:
name: Upload to PyPI on release
name: Upload distributions to PyPI on release
needs: [build]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
Expand All @@ -51,7 +61,7 @@ jobs:
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_secret }}
66 changes: 34 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
outputs:
changes: ${{ steps.changes.outputs.src }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
Expand All @@ -36,9 +36,10 @@ jobs:
src:
- *python
- '.github/**/*.yml'
- 'pyproject.toml'
- 'setup.cfg'
- 'requirements.txt'
- '.coveragerc'
- 'coverage.xml'
- '.pre-commit-config.yaml'

style:
Expand All @@ -47,11 +48,11 @@ jobs:
runs-on: ubuntu-latest
if: ${{ needs.changes.outputs.changes == 'true' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: pre-commit/action@v2.0.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- uses: pre-commit/action@v3.0.1

test:
needs:
Expand All @@ -62,27 +63,28 @@ jobs:
strategy:
matrix:
python-version:
- 3.8
- 3.9
- '3.10'
- '3.11'
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest -v tests/ --cov=cons --cov-report=xml:./coverage.xml
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
parallel: true
flag-name: run-${{ matrix.python-version }}
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest -v tests/ --cov=cons --cov-report=xml:./coverage.xml
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
parallel: true
flag-name: run-${{ matrix.python-version }}

all-checks:
if: ${{ always() }}
Expand All @@ -100,7 +102,7 @@ jobs:
if: ${{ needs.changes.outputs.changes == 'true' && needs.all-checks.result == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: AndreMiras/coveralls-python-action@develop
with:
parallel-finished: true
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
29 changes: 16 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
exclude: |
(?x)^(
versioneer\.py|
cons/_version\.py|
doc/.*|
bin/.*
)$
(?x)^(
doc/.*|
bin/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: debug-statements
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 25.1.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 7.3.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 6.0.1
hooks:
- id: isort
- repo: https://github.com/humitos/mirrors-autoflake.git
rev: v1.1
- repo: https://github.com/PyCQA/autoflake
rev: v2.3.1
hooks:
- id: autoflake
exclude: |
(?x)^(
.*/?__init__\.py|
)$
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variables",
]
32 changes: 30 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
include versioneer.py
include cons/_version.py
# Include only the specified files in the source distribution
include LICENSE.txt
include MANIFEST.in
include pyproject.toml
include README.md
include setup.cfg

# Include everything in the cons source directory
recursive-include cons *

# Exclude unwanted directories and files
prune .github
prune tests
prune .pytest_cache
prune .ropeproject
prune .venv
prune __pycache__
global-exclude *.pyc
global-exclude *.pyo
global-exclude *.pyd
global-exclude .git*
global-exclude .coverage
global-exclude coverage.xml
global-exclude testing-report.html
global-exclude Makefile
global-exclude requirements.txt
global-exclude .pre-commit-config.yaml
global-exclude .pylintrc
global-exclude .DS_Store
global-exclude __pycache__
6 changes: 3 additions & 3 deletions cons/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from importlib.metadata import version

from . import unify # noqa: F401
from ._version import get_versions
from .core import car, cdr, cons # noqa: F401

__version__ = get_versions()["version"]
del get_versions
__version__ = version("cons")
Loading