From fc50845c4af02fcee0c5218894b2b07a8a8940f8 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sun, 26 Jun 2022 17:41:21 -0700 Subject: [PATCH] Replace setup.py with build Using setup.py is no longer recommended by setuptools. Instead, projects should use build: https://github.com/pypa/build. Invoking build will create a source and wheel distribution https://pypa-build.readthedocs.io/en/latest/: > By default, a source distribution (sdist) is built from {srcdir} and a > binary distribution (wheel) is built from the sdist. See the setuptools quickstart guides for more information: https://setuptools.pypa.io/en/latest/userguide/quickstart.html > Instead, when creating new Python packages, it is recommended to use a > command line tool called build. This tool will automatically download > setuptools and any other build-time dependencies that your project > might have. You just need to specify them in a pyproject.toml file at > the root of your package, as indicated in the following section. --- .github/workflows/deploy.yml | 6 +++--- .pre-commit-config.yaml | 1 - Makefile | 6 +++--- pyproject.toml | 3 +++ setup.py | 17 ----------------- tox.ini | 1 + 6 files changed, 10 insertions(+), 24 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc1b7a78..ffbfe8dc 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,7 +1,7 @@ name: "Deploy to PyPI" on: workflow_dispatch: - inputs: + inputs: tag: description: "Git tag to deploy to PyPI" required: true @@ -21,7 +21,7 @@ jobs: - shell: bash run: | python -m pip install --disable-pip-version-check -U pip - python -m pip install -U setuptools wheel twine - python setup.py sdist bdist_wheel + python -m pip install -U build twine + python -m build python -m twine check dist/* python -m twine upload --username=__token__ --password=${{ secrets.PYPI_TOKEN }} dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a4b3294..9a2251ac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,5 +19,4 @@ repos: args: ["--strict"] additional_dependencies: [ "pytest==6.2.5", - "types-setuptools==57.4.2", ] diff --git a/Makefile b/Makefile index 585ca2ef..ad3ec566 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ clean: .PHONY: build build: - python setup.py sdist bdist_wheel + python -m build .PHONY: publish publish: @@ -72,12 +72,12 @@ dev: instdev test .PHONY: instdev instdev: pip install -r dev-requirements.txt - python setup.py develop + pip install -e . @echo "$@ done." .PHONY: install install: - python setup.py install + pip install . @echo "$@ done." .PHONY: clobber diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fed528d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py deleted file mode 100644 index 4ab6be28..00000000 --- a/setup.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2015-2020 Nir Cohen -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from setuptools import setup - -setup() diff --git a/tox.ini b/tox.ini index efa6ae6d..cc9dfc51 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ [tox] minversion = 1.9 envlist = lint, py{36,37,38,39,310,py3} +isolated_build = true skip_missing_interpreters = true [testenv]