From a4765472e42a02c7018cc2052dc9f92533bae2ff Mon Sep 17 00:00:00 2001 From: Jeremy Smith <64465231+pt1243@users.noreply.github.com> Date: Sun, 22 Oct 2023 16:11:11 +0200 Subject: [PATCH] Specify dynamic __version__ --- my_package/__init__.py | 1 + my_package/__version__.py | 1 + pyproject.toml | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 my_package/__version__.py diff --git a/my_package/__init__.py b/my_package/__init__.py index e69de29..9226fe7 100644 --- a/my_package/__init__.py +++ b/my_package/__init__.py @@ -0,0 +1 @@ +from .__version__ import __version__ diff --git a/my_package/__version__.py b/my_package/__version__.py new file mode 100644 index 0000000..3dc1f76 --- /dev/null +++ b/my_package/__version__.py @@ -0,0 +1 @@ +__version__ = "0.1.0" diff --git a/pyproject.toml b/pyproject.toml index 24252fd..bdc69dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,13 +4,13 @@ authors = [ {name = "Jeremy Smith", email = "64465231+pt1243@users.noreply.github.com"}, ] description = "My Python package." -version = "0.1.0" requires-python = ">=3.8" readme = "README.md" license = {file = "LICENSE"} dependencies = [ "numpy", ] +dynamic = ["version"] [build-system] requires = ["setuptools>=61.0.0", "wheel"] @@ -19,6 +19,9 @@ build-backend = "setuptools.build_meta" [tool.setuptools] packages = ["my_package"] +[tool.setuptools.dynamic] +version = {attr = "my_package.__version__"} + [tool.pytest.ini_options] addopts = "--cov=my_package --cov-report=term-missing --cov-append" testpaths = [