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

Dynamic versioning with setuptools_scm #137

Open
ns-rse opened this issue Nov 29, 2024 · 0 comments
Open

Dynamic versioning with setuptools_scm #137

ns-rse opened this issue Nov 29, 2024 · 0 comments

Comments

@ns-rse
Copy link

ns-rse commented Nov 29, 2024

Can use setuptools_scm to dynamically set the version which is derived from Git tags.

Necessary lines in pyproject.toml

[build-system]
requires = [
  ...
  "setuptools[toml]>=8"
]

[project]
...
dynamic = ["version"]

[tool.setuptools_scm]
write_to = "isoslam/_version.py"

Optional addition if using pytest-cov to report test coverage.

[tool.coverage.run]
omit = [
  "isoslam/_version.py"
]

Can then import the version in __init__.py to make it available.

from importlib.metadata import version

release = version("<pkgname>")
__version__ = ".".join(release.split("."[:2]))
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

1 participant