diff --git a/.gitignore b/.gitignore index 4cd27848100eae36889f1812e25449924b5e973d..7fe6ec56a3203cf1729778b828ef58b2413b7c30 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ __pycache__/ # C extensions *.so -# Version info for PyPI -km3io/version.txt +# Version info +km3io/version.py # Distribution / packaging .Python diff --git a/MANIFEST.in b/MANIFEST.in index 40c6e4589d4ef61a979779cfd2542f974a48d503..8da04a047d30a631a00f96cb01f44ab07ca86077 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,3 @@ include README.rst include LICENSE include requirements.txt -include km3io/version.txt diff --git a/doc/conf.py b/doc/conf.py index 944303b9799f01688505bc4ec35766251302de95..cf1e47b4048f6b79eaaaea2a59c913ee0bacf722 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -18,13 +18,11 @@ import os from datetime import date import sphinx_rtd_theme from pkg_resources import get_distribution -import km3io # -- Project information ----------------------------------------------------- -release = get_distribution('km3io').version -version = '.'.join(release.split('.')[:2]) -project = 'km3io {}'.format(km3io.__version__) +version = get_distribution('km3io').version +project = 'km3io {}'.format(version) copyright = '{0}, Zineb Aly and Tamas Gal'.format(date.today().year) author = 'Zineb Aly, Tamas Gal, Johannes Schumann' @@ -74,4 +72,4 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] -html_title = "km3io {}".format(km3io.__version__) +html_title = "km3io {}".format(version) diff --git a/km3io/__init__.py b/km3io/__init__.py index 6c7748f659cd2ecaed6821316dec1319200af4bc..edd00a18f2ff75474ac40bb9cfb98aba4338e302 100644 --- a/km3io/__init__.py +++ b/km3io/__init__.py @@ -1,5 +1,9 @@ -from .__version__ import version -__version__ = version +from pkg_resources import get_distribution, DistributionNotFound + +try: + version = get_distribution(__name__).version +except DistributionNotFound: + version = "unknown version" from .offline import OfflineReader from .daq import DAQReader diff --git a/km3io/__version__.py b/km3io/__version__.py deleted file mode 100644 index f9ea4bda5dcc97d59133d2826d9641ea1a60fceb..0000000000000000000000000000000000000000 --- a/km3io/__version__.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -# Filename: __version__.py -# pylint: disable=C0103 -""" -Pep 386 compliant version info. - - (major, minor, micro, alpha/beta/rc/final, #) - (1, 1, 2, 'alpha', 0) => "1.1.2.dev" - (1, 2, 0, 'beta', 2) => "1.2b2" - -""" -from __future__ import absolute_import, print_function, division - -from os.path import dirname, realpath, join - -from setuptools_scm import get_version - -version = 'unknown version' - -try: - version = get_version(root='..', relative_to=__file__) -except LookupError: - with open(join(realpath(dirname(__file__)), "version.txt"), 'r') as fobj: - version = fobj.read() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..8c1be0fb0ea9a7c44107498e8799d3ac99b745e7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] + +[tool.setuptools_scm] +write_to = "km3io/version.py" diff --git a/setup.py b/setup.py index 7f9d245dcbc52f66057d6f9e96a99ea1ebfced63..9348c37b590c6fce145f252ca89911fe910ad394 100644 --- a/setup.py +++ b/setup.py @@ -26,10 +26,7 @@ setup( include_package_data=True, platforms='any', setup_requires=['setuptools_scm'], - use_scm_version={ - 'write_to': 'km3io/version.txt', - 'tag_regex': r'^(?P<prefix>v)?(?P<version>[^\+]+)(?P<suffix>.*)?$', - }, + use_scm_version=True, install_requires=requirements, python_requires='>=3.5', entry_points={