Skip to content

Commit

Permalink
Replace setup.py with PyPA "build" (#371)
Browse files Browse the repository at this point in the history
Use the `build` package to generate source and wheel distributions.
This means we can remove the `setup.py` file entirely since it's not
needed. Update the GitHub Actions workflows to match.
  • Loading branch information
leouieda authored Aug 25, 2022
1 parent efdff59 commit f1c038c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:

- name: Build source and wheel distributions
run: |
python setup.py sdist bdist_wheel
make build
echo ""
echo "Generated files:"
ls -lh dist/
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ defaults:

jobs:

#############################################################################
# Build the wheel and source archives and check them with Twine
build:
runs-on: ubuntu-latest
# Only publish from the origin repository, not forks
if: github.repository_owner == 'fatiando'

steps:
# Checks-out your repository under $GITHUB_WORKSPACE
Expand Down Expand Up @@ -65,7 +69,7 @@ jobs:
- name: Build source and wheel distributions
run: |
python setup.py sdist bdist_wheel
make build
echo ""
echo "Generated files:"
ls -lh dist/
Expand All @@ -82,6 +86,8 @@ jobs:
name: pypi-${{ github.sha }}
path: dist

#############################################################################
# Publish built wheels and source archives to PyPI and test PyPI
publish:
runs-on: ubuntu-latest
needs: build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:

- name: Build source and wheel distributions
run: |
python setup.py sdist bdist_wheel
make build
echo ""
echo "Generated files:"
ls -lh dist/
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
PROJECT=verde
TESTDIR=tmp-test-dir-with-unique-name
PYTEST_ARGS=--cov-config=../.coveragerc --cov-report=term-missing --cov=$(PROJECT) --doctest-modules -v --pyargs
CHECK_STYLE=setup.py $(PROJECT) doc tools
CHECK_STYLE=$(PROJECT) doc tools

help:
@echo "Commands:"
Expand All @@ -11,11 +11,15 @@ help:
@echo " test run the test suite (including doctests) and report coverage"
@echo " format automatically format the code"
@echo " check run code style and quality checks"
@echo " build build source and wheel distributions"
@echo " clean clean up build and generated files"
@echo ""

build:
python -m build .

install:
pip install --no-deps -e .
python -m pip install --no-deps -e .

test:
# Run a tmp folder to make sure the tests are run on the installed version
Expand Down Expand Up @@ -49,7 +53,6 @@ isort-check:
flake8:
flake8 $(CHECK_STYLE)


clean:
find . -name "*.pyc" -exec rm -v {} \;
find . -name ".coverage.*" -exec rm -v {} \;
Expand Down
7 changes: 2 additions & 5 deletions env/requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
setuptools_scm>=6.2
setuptools>=45
wheel
# Requirements to build and check distributions
build
twine
# TOML parser dropped 3.6 and is causing problems. Remove once we drop 3.6
tomli<2.0.0
4 changes: 1 addition & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ dependencies:
- python==3.10
- pip
# Build
- setuptools_scm>=6.2
- setuptools>=45
- wheel
- twine
- build
# Run
- numpy
- scipy
Expand Down
15 changes: 0 additions & 15 deletions setup.py

This file was deleted.

0 comments on commit f1c038c

Please sign in to comment.