diff --git a/.github/workflows/CD.yml b/.github/workflows/cd.yml similarity index 92% rename from .github/workflows/CD.yml rename to .github/workflows/cd.yml index 931f440b..a8ee2590 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,11 @@ on: push: branches: - master + tags: + - v* + pull_request: + branches: + - master release: types: - published diff --git a/.readthedocs.yml b/.readthedocs.yml index 9d9a0b6d..3c76f48f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -20,3 +20,5 @@ python: version: 3.7 install: - requirements: docs/requirements.txt + - method: pip + path: . diff --git a/pyproject.toml b/pyproject.toml index 3b2a3a9a..bc28efad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,11 @@ [build-system] # Minimum requirements for the build system (setup.py) to execute. -requires = ["wheel", "setuptools>=39.2.0"] +requires = ["wheel", "setuptools>=42", "setuptools_scm[toml]>=3.4",] build-backend = "setuptools.build_meta" +[tool.setuptools_scm] +write_to = "src/mplhep/_version.py" + [tool.nbqa.config] black = "pyproject.toml" diff --git a/setup.cfg b/setup.cfg index 91626754..47568fc4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = mplhep -version = file: src/mplhep/.VERSION +# version = file: src/mplhep/.VERSION long_description = file: README.md long_description_content_type = text/markdown author = andrzejnovak diff --git a/setup.py b/setup.py index 8c906457..6d1b29fd 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from __future__ import annotations +import setuptools_scm # noqa: F401 from setuptools import setup extras_require = { diff --git a/src/mplhep/.VERSION b/src/mplhep/.VERSION deleted file mode 100644 index 9e29e106..00000000 --- a/src/mplhep/.VERSION +++ /dev/null @@ -1 +0,0 @@ -0.3.15 diff --git a/src/mplhep/__init__.py b/src/mplhep/__init__.py index 116a11e9..42cad831 100644 --- a/src/mplhep/__init__.py +++ b/src/mplhep/__init__.py @@ -10,6 +10,7 @@ from . import alice, atlas, cms, label, lhcb, plot from . import styles as style from ._tools import Config +from ._version import version as __version__ # noqa: F401 from .label import save_variations, savelabels from .plot import ( append_axes, @@ -41,12 +42,6 @@ ), ) -# Make __version__ available -_base_dir = os.path.dirname(os.path.abspath(__file__)) - -with open(os.path.join(_base_dir, ".VERSION")) as version_file: - __version__ = version_file.read().strip() - path = os.path.abspath(__file__) font_path = os.path.join(os.path.dirname(mplhep_data.__file__), "fonts") font_files = fm.findSystemFonts(fontpaths=font_path) diff --git a/src/mplhep/version.pyi b/src/mplhep/version.pyi new file mode 100644 index 00000000..5bb2b22f --- /dev/null +++ b/src/mplhep/version.pyi @@ -0,0 +1,2 @@ +version: str +version_tuple: tuple[int, int, int] | tuple[int, int, int, str, str]