-
-
Notifications
You must be signed in to change notification settings - Fork 942
Python library is being installed without its git version tag #3047
Description
search you tried in the issue tracker
is:issue git version tag
describe your issue
We've started using my library ms3 as a pre-commit hook to generate additional files before committing. These include metadata files which routinely state the version of ms3 used to generate them.
Expected behaviour
The library should output the same version that is stated in the .pre-commit-config.yaml file calling it (currently v2.4.0).
Observed behaviour
Instead, the version information is something like 0.0.post1.dev1+gc24101c. Needless to say that under all other circumstances the version output is correctly based on the latest git tag.
Possible explanation
The version output looks like a version tag for a git repo that does not come with any tags. Could it be that pre-commit clones the repository without the relevant version tag?
Useful information
ms3 infers its own version using the importlib.metadata module, which happens here in the top-level init.py. It is written to the file __version__.py from where it can be imported by any other module.
How to reproduce
git clone https://github.com/johentsch/ms3 --depth 1- Replace the contents of
.pre-commit-hooks.yamlwith the content below - In the repo, execute
pre-commit try-repo . --all-files --verbose
Output
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578
0.0.post1.dev1+gc587578To convince yourself that under normal circumstances it works correctly, you could pip install . and then execute ms3 --version.
pre-commit --version
pre-commit 3.5.0
.pre-commit-hooks.yaml
- id: version
name: Show ms3 version
entry: ms3 --version
language: python~/.cache/pre-commit/pre-commit.log (if present)
No response