Skip to content

Drop setuptools-scm requirement in wheels #21820

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 1 commit into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ def make_release_tree(self, base_dir, files):
"pyparsing>=2.2.1,<3.0.0",
"python-dateutil>=2.7",
] + (
# Installing from a git checkout.
["setuptools_scm>=4"] if Path(__file__).with_name(".git").exists()
else []
# Installing from a git checkout that is not producing a wheel.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly is having this in setup_requires insufficient? Or is that only going to work with pyproject.toml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know; this came in with the original PR #18971; would have to ask @anntzer for the exact reason.

Copy link
Contributor

@anntzer anntzer Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #18971 (comment) and #18971 (comment): the two options were either
(a) don't have a runtime dep on setuptools_scm, and accept that inplace installs get the wrong version if one does pip install -e . and then update the git repo (the version comes from _version.py and is only updated when setup.py is run, either directly (e.g. when recompiling) or via pip); or
(b) make setuptools_scm a dependency so that the version is always correct.

I was actually in favor of (a) (as described in that thread), but didn't feel that strongly about it. I guess that's another opportunity to go back to (a) :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept that inplace installs get the wrong version if one does pip install -e .

Do you mean that the wrong version gets reported, or that the install doesn't work? I think reporting the current commit in the version is nice, but hardly crucial.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wrong version gets reported if one does pip install -e and then updates the git repo (and even then, there are probably workarounds possible e.g. using git hooks...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted in #21783, my solution has been to import and use setuptools_scm, then fallback to importlib_metadata. Given the fallback, it seemed fine to treat setuptools_scm as an optional dependency and only list it as a "build" dependency. It's not perfect, but I've gone to statically listing all package metadata in setup.cfg.

["setuptools_scm>=4"] if (
Path(__file__).with_name(".git").exists() and
os.environ.get("CIBUILDWHEEL", "0") != "1"
) else []
),
use_scm_version={
"version_scheme": "release-branch-semver",
Expand Down