diff --git a/meson.build b/meson.build index cb6a213..baf1d02 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'numpy-financial', 'cython', 'c', - version: '2.0.0.dev', + version: run_command('tools/version.py', check: true).stdout().strip(), license: 'BSD-3', meson_version: '>=1.4.0', ) diff --git a/pyproject.toml b/pyproject.toml index aea7a12..dc01f4e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires = [ [project] name = "numpy-financial" -version = "2.0.0" +dynamic = ['version'] requires-python = ">=3.13" description = "Simple financial functions" license = "BSD-3-Clause" diff --git a/tools/version.py b/tools/version.py new file mode 100755 index 0000000..d182e47 --- /dev/null +++ b/tools/version.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +"""Determine and print the version number. + +Used in the top level ``meson.build``. +""" + +from pathlib import Path + +INIT = Path(__file__).parent.parent / "numpy_financial" / "__init__.py" + + +def version_from_init(): + """Extract the version string from ``numpy_financial/__init__.py``.""" + lines = INIT.read_text().splitlines() + version_line = next(line for line in lines if line.startswith("__version__ =")) + return version_line.split(" = ")[1].strip().strip("\"'") + + +if __name__ == "__main__": + print(version_from_init())