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..1cbe279b3 100644 --- a/HOWTORELEASE.rst +++ b/HOWTORELEASE.rst @@ -3,27 +3,25 @@ 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). +#. Check and finalize ``CHANGELOG.rst``. -2. Check and finalize ``CHANGELOG.rst``. - -3. 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 @@ -31,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 @@ -59,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)**: @@ -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..6e41f0504 100644 --- a/_pytest/__init__.py +++ b/_pytest/__init__.py @@ -1,2 +1,8 @@ -# -__version__ = '3.1.0.dev0' +__all__ = ['__version__'] + +try: + 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 + __version__ = 'unknown' 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/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 1d0630cd2..a71692c25 100644 --- a/setup.py +++ b/setup.py @@ -1,32 +1,27 @@ -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() -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 +58,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 +71,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'], diff --git a/tox.ini b/tox.ini index 5c103f94c..d46e468c8 100644 --- a/tox.ini +++ b/tox.ini @@ -47,6 +47,9 @@ commands= [testenv:linting] basepython = python2.7 +# needed to keep check-manifest working +setenv = + SETUPTOOLS_SCM_PRETEND_VERSION=2.0.1 deps = flake8 # pygments required by rst-lint @@ -56,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