Skip to content
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

Custom local_scheme not used when building #1084

Open
andy-maier opened this issue Nov 5, 2024 · 2 comments
Open

Custom local_scheme not used when building #1084

andy-maier opened this issue Nov 5, 2024 · 2 comments

Comments

@andy-maier
Copy link

andy-maier commented Nov 5, 2024

When specifying a local_scheme in pyproject.toml using entrypoints, it is used correctly in python -m setuptools_scm but not used in the generated version file, and not used in the file names of the distribution archives when building them.

The pyroject.toml file has these relevant sections:

[build-system]
requires = [
    "setuptools>=70.0.0",
    "setuptools-scm[toml]>=8.1.0",
    "wheel>=0.41.3"
]
build-backend = "setuptools.build_meta"

. . .

[tool.setuptools_scm]
version_file = "myproject/_version_scm.py"
version_scheme = "no-guess-dev"
local_scheme = "myproject._local_scheme:main"

The myproject/_local_scheme.py file has this content:

from setuptools_scm.version import ScmVersion

def main(version: ScmVersion) -> str:
    return version.format_choice("", "+dirty")

Here is the difference between the python -m setuptools_scm output and the version in the (freshly) generated _version_scm.py file:

Commit state   Latest tag                  python -m setuptools_scm   _version_scm.py
------------------------------------------------------------------------------------------------
Clean          1.23.0 on latest commit     1.23.0                     1.23.0+unknown
Dirty          1.23.0 on latest commit     1.23.0.post1.dev0+dirty    1.23.0.post1.dev0+unknown
Clean          1.22.2 on 13 commits back   1.22.2.post1.dev13         1.22.2.post1.dev13+unknown
Dirty          1.22.2 on 13 commits back   1.22.2.post1.dev13+dirty   1.22.2.post1.dev13+unknown
@andy-maier
Copy link
Author

andy-maier commented Nov 5, 2024

After some more investigation, it turns out that the result depends on whether "build" is run in an isolated environment or not:

  • The above results were for an isolated environment (default of "build").
  • When running "build" in a non-isolated environment (i.e. specify its --no-isolation option), the generated _version_scm.py file shows the same version that python -m setuptools_scm shows.

So my circumvention for now is to run "build" in a non-isolated environment. That's more transparent anyway.

@RonnyPfannschmidt
Copy link
Contributor

whats the logging output when `SETUPTOOLS_SCM_DEBUG=1" in the environment

there should be a error when the version scheme is not found - if that error gets accidentally hidden we are missing a bug

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

No branches or pull requests

2 participants