Skip to content

Rework setuptools-scm configuration #1192

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

Merged
merged 9 commits into from
Aug 17, 2025

Conversation

seifertm
Copy link
Contributor

pytest-asyncio has an unnecessarily complex setuptools-scm configuration, which is split over multiple files (pyproject.toml and setup.cfg). This setup broke with the recent release of setuptools-scm v9.2 leading to build errors.

This PR addresses several issues:

  • it provides pytest_asyncio.__version__ through importlib.metadata as opposed to a version file leading to simpler configuration
  • it bumps setuptools-scm to v9.2.0
  • it pins the versions build dependencies (setuptools and setuptools-scm) to make builds reproducible. Build dependencies should be updated by dependabot nowadays

This patch sets an upper bound for setuptools_scm which has breaking changes and prevents the project from being built.
This is required for reproducible builds. Pinned build dependencies should be updated by dependabot.
This is required for reproducible builds. Pinned build dependencies should be updated by dependabot.
This replaces the existing approach that uses a version file generated by setuptools-scm.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.91%. Comparing base (4fbe1e0) to head (d28f82e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1192      +/-   ##
==========================================
+ Coverage   88.88%   88.91%   +0.02%     
==========================================
  Files           2        2              
  Lines         405      406       +1     
  Branches       44       44              
==========================================
+ Hits          360      361       +1     
  Misses         35       35              
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@seifertm seifertm added this pull request to the merge queue Aug 17, 2025
Merged via the queue into pytest-dev:main with commit db36483 Aug 17, 2025
21 of 22 checks passed
@seifertm seifertm deleted the fix-broken-build branch August 17, 2025 14:14
@webknjaz
Copy link
Member

@seifertm FYI this way of packaging with pinning the build deps is actively harmful for downstreams like Linux distribution packagers. Instead, use pip constraints to make the upstream packaging predictable.

@webknjaz
Copy link
Member

We were just talking about it the other day over at PyPUG, by the way: pypa/packaging.python.org#1886

@seifertm
Copy link
Contributor Author

seifertm commented Aug 17, 2025

@seifertm FYI this way of packaging with pinning the build deps is actively harmful for downstreams like Linux distribution packagers. Instead, use pip constraints to make the upstream packaging predictable.

@webknjaz Thanks for bringing this up, I didn't think of this.

My understanding is that downstream packagers may want to build from source using the build dependencies that are available in their respective package repositories. Specifying exact versions of build dependencies would interfere with that. Is that about right?

In that case, let's revert to specifying lower (and upper?) bounds for build dependencies and pin the version using a different mechanism, as you suggested.

@webknjaz
Copy link
Member

My understanding is that downstream packagers may want to build from source using the build dependencies that are available in their respective package repositories. Specifying exact versions of build dependencies would interfere with that. Is that about right?

@seifertm yes. Downstreams usually don't have per-venv separation and so there's exactly one version of a build deps on the system at a time. For example, one version of setuptools installed globally. This causes conflicts and would cause headache as they'll be trying to patch out the limitations.

In that case, let's revert to specifying lower (and upper?) bounds for build dependencies and pin the version using a different mechanism, as you suggested.

I usually recommend the lower bound corresponding to a version where a feature you use was added. Upper bounds cause almost as many problems as hard pins. Version exclusions (!=) are fine. Though, some build backends (uv, flit core) still advertise upper bounds, which isn't friendly with downstreams nevertheless.

Though, while the metadata shouldn't be overly tight, you can still set the $PIP_CONSTRAINT env var where you call pypa/build or pip (in CI/tox/nox/etc). Point it to a file with all the transitive deps pinned. You can generate/manage this file using pip-tools that knows how to extract PEP 517 build deps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants