diff --git a/.gitignore b/.gitignore index ed30965b..6d76704f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,8 @@ __pycache__ .coverage /.cache /.venv +/.eggs + + +# auto-generated by setuptools_scm +/pytestqt/_version.py diff --git a/docs/conf.py b/docs/conf.py index 3b7186be..7dae585b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,14 +47,10 @@ # |version| and |release|, also used in various other places throughout the # built documents. # -import re -with open('../pytestqt/__init__.py') as f: - m = re.search("version = '(.*)'", f.read()) - assert m is not None -version = m.group(1) +import pkg_resources +version = pkg_resources.get_distribution('pytest-qt').version # The short X.Y version. # The full version, including alpha/beta/rc tags. -release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/pytestqt/__init__.py b/pytestqt/__init__.py index 0fbc62be..0b666df0 100644 --- a/pytestqt/__init__.py +++ b/pytestqt/__init__.py @@ -1,2 +1,3 @@ -version = '2.0.0' +# _version is automatically generated by setuptools_scm +from pytestqt._version import version __version__ = version diff --git a/setup.py b/setup.py index bc63902f..147f0bc9 100644 --- a/setup.py +++ b/setup.py @@ -23,15 +23,8 @@ def run_tests(self): errno = pytest.main([]) sys.exit(errno) - -with open('pytestqt/__init__.py') as f: - m = re.search("version = '(.*)'", f.read()) - assert m is not None - version = m.group(1) - setup( name="pytest-qt", - version=version, packages=['pytestqt'], entry_points={ 'pytest11': ['pytest-qt = pytestqt.plugin'], @@ -47,6 +40,8 @@ def run_tests(self): license="MIT", keywords="pytest qt test unittest", url="http://github.com/pytest-dev/pytest-qt", + use_scm_version={'write_to': 'pytestqt/_version.py'}, + setup_requires=['setuptools_scm'], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Framework :: Pytest',