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

Dev template config not used? #107

Open
fleimgruber opened this issue Nov 21, 2024 · 2 comments
Open

Dev template config not used? #107

fleimgruber opened this issue Nov 21, 2024 · 2 comments

Comments

@fleimgruber
Copy link

With a pyproject.toml

[tool.setuptools-git-versioning]
enabled = true
version_file = "VERSION"
count_commits_from_version_file = true
dev_template = "{tag}.post+git.{full_sha}"

[build-system]
requires = [ "setuptools>=41", "setuptools-git-versioning>=2.0,<3", "wheel" ]
build-backend = "setuptools.build_meta"

and VERSION file having the content "0.0.1", on running uv run setuptools-git-versioning -vv I get this error:

error: Failed to generate package metadata for `my_package==0.0.1 @ editable+.`
  Caused by: Build backend failed to determine requirements with `build_editable()` (exit code: 1)

[stderr]
Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\build_meta.py", line 483, in get_requires_for_build_editable
    return self.get_requires_for_build_wheel(config_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\build_meta.py", line 334, in get_requires_for_build_wheel
    return self._get_build_requires(config_settings, requirements=[])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\build_meta.py", line 304, in _get_build_requires
    self.run_setup()
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\build_meta.py", line 320, in run_setup
    exec(code, locals())
  File "<string>", line 1, in <module>
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\_distutils\core.py", line 145, in setup
    _setup_distribution = dist = klass(attrs)
                                 ^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\dist.py", line 319, in __init__
    _Distribution.__init__(self, dist_attrs)
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\_distutils\dist.py", line 279, in __init__
    self.finalize_options()
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools\dist.py", line 677, in finalize_options
    ep(self)
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools_git_versioning.py", line 256, in infer_version
    version = version_from_git(dist.metadata.name, **config, root=root)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools_git_versioning.py", line 618, in version_from_git
    return _sanitize_version(version)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\setuptools_git_versioning.py", line 469, in _sanitize_version
    result = str(Version(sanitized_version))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\LeimgruberF\AppData\Local\uv\cache\builds-v0\.tmplgWeLE\Lib\site-packages\packaging\version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
packaging.version.InvalidVersion: Invalid version: '0.0.1.postNone+git.77864310.dirty'

where the configured dev_template seems to be ignored?

@dolfinus
Copy link
Owner

https://setuptools-git-versioning.readthedocs.io/en/stable/options/dev_template.html

Used if there are no untracked files, and current commit is not tagged.

Have you committed all the changes in your repo?

@fleimgruber
Copy link
Author

Thanks for the quick answer!

I had untracked files, yes. After committing I get the expected behavior. It seems to me that the issue was because the "VERSIONS" file was untracked? If I create dummy untracked files after the mentioned commit, it still works as expected.

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