Skip to content

Build with PEP 517 to avoid build failure #580

@EpicWink

Description

@EpicWink

On 31 October (in 12 days), python-dotenv's build script will stop working as setuptools drops support for invoking python setup.py. Read this blog post about why.

The simple fix is to switch to building with build (which uses PEP 517 to build the sdist and wheel) instead of calling python setup.py (and installing setuptools).

A further improvement is to explicitly declare the build backend and requirements in pyproject.toml:

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

It's not necessary to move the project metadata and build configuration to pyproject.toml, although that would be a further improvement, allowing for it all to become declarative; setuptools even supports the dynamic version and combined long-description files currently in python-dotenv's setup.py.

Example patch (click to expand)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 67668d5..c819ac3 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -16,7 +16,7 @@ jobs:
     - name: Install dependencies
       run: |
         python -m pip install --upgrade pip
-        pip install setuptools wheel twine
+        pip install build twine
     - name: Build and publish
       env:
         TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
diff --git a/Makefile b/Makefile
index e5bcb30..39f90d1 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ release-test: sdist
        twine upload --repository-url https://test.pypi.org/legacy/ dist/*
 
 sdist: clean
-       python setup.py sdist bdist_wheel
+       python -m build -d dist .
        ls -l dist
 
 test:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions