From c3aee4b1e64efa7893bcacbfde793e04f01a8dda Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 21 Aug 2016 18:13:32 +0200 Subject: [PATCH 1/7] second take at setuptools_scm since setuptools 18.6 fixes the issues with develop installs https://github.com/pypa/setuptools/blob/master/CHANGES.rst#186 https://github.com/pypa/setuptools/issues/439 --- .gitignore | 3 +++ HOWTORELEASE.rst | 8 ++------ _pytest/__init__.py | 7 +++++-- setup.py | 14 ++++---------- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 0e42b11ff..3b7ec9fac 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,9 @@ include/ *~ .hypothesis/ +# autogenerated +_pytest/_version.py +# setuptools .eggs/ doc/*/_build diff --git a/HOWTORELEASE.rst b/HOWTORELEASE.rst index 372ecf7f1..523ed41cc 100644 --- a/HOWTORELEASE.rst +++ b/HOWTORELEASE.rst @@ -3,11 +3,9 @@ How to release pytest Note: this assumes you have already registered on pypi. -1. Bump version numbers in ``_pytest/__init__.py`` (``setup.py`` reads it). +1. Check and finalize ``CHANGELOG.rst``. -2. Check and finalize ``CHANGELOG.rst``. - -3. Write ``doc/en/announce/release-VERSION.txt`` and include +2. Write ``doc/en/announce/release-VERSION.txt`` and include it in ``doc/en/announce/index.txt``. Run this command to list names of authors involved:: git log $(git describe --abbrev=0 --tags)..HEAD --format='%aN' | sort -u @@ -81,5 +79,3 @@ Note: this assumes you have already registered on pypi. 9. Push ``master`` and ``features``. c. **major release (3.0.0)**: same steps as that of a **minor release** - - diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 0a37f23b2..a6f201091 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,5 @@ -# -__version__ = '3.1.0.dev0' +__all__ = ['__version__'] +try: + from ._version import version as __version__ +except ImportError: + __version__ = None # broken installation, we don't even try diff --git a/setup.py b/setup.py index 1d0630cd2..3cba379e4 100644 --- a/setup.py +++ b/setup.py @@ -18,15 +18,6 @@ classifiers = ['Development Status :: 6 - Mature', with open('README.rst') as fd: long_description = fd.read() -def get_version(): - p = os.path.join(os.path.dirname( - os.path.abspath(__file__)), "_pytest", "__init__.py") - with open(p) as f: - for line in f.readlines(): - if "__version__" in line: - return line.strip().split("=")[-1].strip(" '") - raise ValueError("could not read version") - def has_environment_marker_support(): """ @@ -63,7 +54,9 @@ def main(): name='pytest', description='pytest: simple powerful testing with Python', long_description=long_description, - version=get_version(), + use_scm_version={ + 'write_to': '_pytest/_version.py', + }, url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], @@ -74,6 +67,7 @@ def main(): keywords="test unittest", cmdclass={'test': PyTest}, # the following should be enabled for release + setup_requires=['setuptools-scm'], install_requires=install_requires, extras_require=extras_require, packages=['_pytest', '_pytest.assertion', '_pytest._code', '_pytest.vendored_packages'], From 31e6fe8f52ef90adcb6a8bafcf08b26b8796b931 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 29 Aug 2016 15:53:41 +0200 Subject: [PATCH 2/7] HOWTORELEASE.tst: use restructuredtext autonumbering --- HOWTORELEASE.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/HOWTORELEASE.rst b/HOWTORELEASE.rst index 523ed41cc..1cbe279b3 100644 --- a/HOWTORELEASE.rst +++ b/HOWTORELEASE.rst @@ -3,25 +3,25 @@ How to release pytest Note: this assumes you have already registered on pypi. -1. Check and finalize ``CHANGELOG.rst``. +#. Check and finalize ``CHANGELOG.rst``. -2. Write ``doc/en/announce/release-VERSION.txt`` and include +#. Write ``doc/en/announce/release-VERSION.txt`` and include it in ``doc/en/announce/index.txt``. Run this command to list names of authors involved:: git log $(git describe --abbrev=0 --tags)..HEAD --format='%aN' | sort -u -4. Regenerate the docs examples using tox:: +#. Regenerate the docs examples using tox:: tox -e regen -5. At this point, open a PR named ``release-X`` so others can help find regressions or provide suggestions. +#. At this point, open a PR named ``release-X`` so others can help find regressions or provide suggestions. -6. Use devpi for uploading a release tarball to a staging area:: +#. Use devpi for uploading a release tarball to a staging area:: devpi use https://devpi.net/USER/dev devpi upload --formats sdist,bdist_wheel -7. Run from multiple machines:: +#. Run from multiple machines:: devpi use https://devpi.net/USER/dev devpi test pytest==VERSION @@ -29,27 +29,27 @@ Note: this assumes you have already registered on pypi. Alternatively, you can use `devpi-cloud-tester `_ to test the package on AppVeyor and Travis (follow instructions on the ``README``). -8. Check that tests pass for relevant combinations with:: +#. Check that tests pass for relevant combinations with:: devpi list pytest or look at failures with "devpi list -f pytest". -9. Feeling confident? Publish to pypi:: +#. Feeling confident? Publish to pypi:: devpi push pytest==VERSION pypi:NAME where NAME is the name of pypi.python.org as configured in your ``~/.pypirc`` file `for devpi `_. -10. Tag the release:: +#. Tag the release:: git tag VERSION git push origin VERSION Make sure ```` is **exactly** the git hash at the time the package was created. -11. Send release announcement to mailing lists: +#. Send release announcement to mailing lists: - pytest-dev@python.org - python-announce-list@python.org @@ -57,7 +57,7 @@ Note: this assumes you have already registered on pypi. And announce the release on Twitter, making sure to add the hashtag ``#pytest``. -12. **After the release** +#. **After the release** a. **patch release (2.8.3)**: From c0a51f56624fef1b1977a285dcf1d5430e59a94e Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 19 Apr 2017 20:12:38 +0200 Subject: [PATCH 3/7] restore check-manifst functionality --- scripts/check-manifest.py | 1 - tox.ini | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/check-manifest.py b/scripts/check-manifest.py index 5911a84fe..909e7519b 100644 --- a/scripts/check-manifest.py +++ b/scripts/check-manifest.py @@ -18,4 +18,3 @@ if os.path.isdir('.git'): else: print('No .git directory found, skipping checking the manifest file') sys.exit(0) - diff --git a/tox.ini b/tox.ini index 5c103f94c..cbb685705 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,8 @@ commands= [testenv:linting] basepython = python2.7 +setenv = # needed to keep check-manifest working + SETUPTOOLS_SCM_PRETEND_VERSION=0.0.1 deps = flake8 # pygments required by rst-lint From 2cf422733c0fadb43a707eb6c942425f2cc312a1 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 19 Apr 2017 20:25:53 +0200 Subject: [PATCH 4/7] restore linting, drop _pytest._version for check-manifest --- _pytest/__init__.py | 6 ++++-- setup.py | 4 +--- tox.ini | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index a6f201091..2599bd05a 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,5 +1,7 @@ __all__ = ['__version__'] +import pkg_resources + try: - from ._version import version as __version__ -except ImportError: + __version__ = pkg_resources.get_distribution('pytest').version +except Exception: __version__ = None # broken installation, we don't even try diff --git a/setup.py b/setup.py index 3cba379e4..73d42b73d 100644 --- a/setup.py +++ b/setup.py @@ -54,9 +54,7 @@ def main(): name='pytest', description='pytest: simple powerful testing with Python', long_description=long_description, - use_scm_version={ - 'write_to': '_pytest/_version.py', - }, + use_scm_version=True, url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/tox.ini b/tox.ini index cbb685705..d46e468c8 100644 --- a/tox.ini +++ b/tox.ini @@ -47,8 +47,9 @@ commands= [testenv:linting] basepython = python2.7 -setenv = # needed to keep check-manifest working - SETUPTOOLS_SCM_PRETEND_VERSION=0.0.1 +# needed to keep check-manifest working +setenv = + SETUPTOOLS_SCM_PRETEND_VERSION=2.0.1 deps = flake8 # pygments required by rst-lint @@ -58,7 +59,7 @@ deps = commands = {envpython} scripts/check-manifest.py flake8 pytest.py _pytest testing - rst-lint CHANGELOG.rst HOWTORELEASE.rst README.rst + rst-lint CHANGELOG.rst HOWTORELEASE.rst README.rst --encoding utf-8 [testenv:py27-xdist] deps=pytest-xdist>=1.13 From 4242bf62627f90d895f32889da43dda62775a1fa Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 20 Apr 2017 21:46:58 +0200 Subject: [PATCH 5/7] use unknown to specify unknown versions --- _pytest/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 2599bd05a..df4c53b02 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,7 +1,10 @@ -__all__ = ['__version__'] import pkg_resources +__all__ = ['__version__'] + try: __version__ = pkg_resources.get_distribution('pytest').version except Exception: - __version__ = None # broken installation, we don't even try + # broken installation, we don't even try + # unknown only works because we do poor mans version compare + __version__ = 'unknown' From e02cb6d7ce804d242496e50cb7e892b740290dcd Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 23 Apr 2017 16:59:08 +0200 Subject: [PATCH 6/7] restore setuptools_scm write_to usage --- _pytest/__init__.py | 6 ++---- setup.cfg | 4 ++++ setup.py | 32 +++++++++++++++++++------------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index df4c53b02..7c69a96f5 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,10 +1,8 @@ -import pkg_resources - __all__ = ['__version__'] try: - __version__ = pkg_resources.get_distribution('pytest').version -except Exception: + from ._version import __version__ +except ImportError: # broken installation, we don't even try # unknown only works because we do poor mans version compare __version__ = 'unknown' diff --git a/setup.cfg b/setup.cfg index f3299af5b..816539e2e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,6 +9,10 @@ upload-dir = doc/en/build/html [bdist_wheel] universal = 1 +[check-manifest] +ignore = + _pytest/_version.py + [metadata] license_file = LICENSE diff --git a/setup.py b/setup.py index 73d42b73d..a71692c25 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,23 @@ -import os, sys +import os +import sys import setuptools import pkg_resources from setuptools import setup, Command -classifiers = ['Development Status :: 6 - Mature', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: POSIX', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: MacOS :: MacOS X', - 'Topic :: Software Development :: Testing', - 'Topic :: Software Development :: Libraries', - 'Topic :: Utilities'] + [ - ('Programming Language :: Python :: %s' % x) for x in - '2 2.6 2.7 3 3.3 3.4 3.5 3.6'.split()] +classifiers = [ + 'Development Status :: 6 - Mature', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Operating System :: POSIX', + 'Operating System :: Microsoft :: Windows', + 'Operating System :: MacOS :: MacOS X', + 'Topic :: Software Development :: Testing', + 'Topic :: Software Development :: Libraries', + 'Topic :: Utilities', +] + [ + ('Programming Language :: Python :: %s' % x) + for x in '2 2.6 2.7 3 3.3 3.4 3.5 3.6'.split() +] with open('README.rst') as fd: long_description = fd.read() @@ -54,7 +58,9 @@ def main(): name='pytest', description='pytest: simple powerful testing with Python', long_description=long_description, - use_scm_version=True, + use_scm_version={ + 'write_to': '_pytest/_version.py', + }, url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], From a280e43949a489192dd7a80ee9c982843d9b153e Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 26 Apr 2017 15:57:55 +0200 Subject: [PATCH 7/7] fix import error --- _pytest/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytest/__init__.py b/_pytest/__init__.py index 7c69a96f5..6e41f0504 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,7 +1,7 @@ __all__ = ['__version__'] try: - from ._version import __version__ + from ._version import version as __version__ except ImportError: # broken installation, we don't even try # unknown only works because we do poor mans version compare