Skip to content

Build with PEP 517 to avoid build failure #580

Closed

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:

Activity

  1. theskumar commented on Oct 14, 2025

    @theskumar
    Owner

    Thanks @EpicWink for the patch - it looks simple enough.

    That said, in an ideal world we should move to using pyproject.toml. I'm not quite sure about any backward compatibility impact this might have, so if anyone has insights, please share.

    @EpicWink, if you have time, would you be able to create a pull request? I'm also happy to make the changes myself if that's easier.

  2. EpicWink commented on Oct 15, 2025

    @EpicWink
    ContributorAuthor

    See #581, #582, or #583

    I'm not quite sure about any backward compatibility impact this might have, so if anyone has insights, please share.

    The earliest version of setuptools which supports metadata in pyproject.toml only supports Python 3.7+. #583 uses a version which only supports Python 3.9+ (which is fine).

    Main compatibility us that python setup.py fails, which is going to fail in a couple of weeks anyway (unless setuptools version is constrained in #582).

  3. EpicWink commented on Oct 31, 2025

    @EpicWink
    ContributorAuthor

    #583 was accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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