From b7d43c5a5d98ef2a00035071e6a8d1ee5665dd36 Mon Sep 17 00:00:00 2001 From: Ionel Cristian Maries Date: Fri, 10 Apr 2015 21:08:50 +0300 Subject: [PATCH 1/7] Add support for building proper wheels (universal and proper dependency evnironment markers for argparse/colorama if setuptools is new-ish). --HG-- branch : pytest-2.7 --- setup.cfg | 2 ++ setup.py | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 6ebbc65a5..770dd1fb2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,3 +6,5 @@ all_files = 1 [upload_sphinx] upload-dir = doc/en/build/html +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py index 0e8b3509f..038e5f633 100644 --- a/setup.py +++ b/setup.py @@ -26,12 +26,25 @@ def get_version(): raise ValueError("could not read version") +def has_newish_setuptools(): + try: + import setuptools + return tuple(int(i) for i in str(setuptools.__version__).split('.')) > (0, 7) + except Exception: + return False + + def main(): install_requires = ['py>=1.4.25'] - if sys.version_info < (2, 7) or (3,) <= sys.version_info < (3, 2): - install_requires.append('argparse') - if sys.platform == 'win32': - install_requires.append('colorama') + extras_require = {} + if has_newish_setuptools(): + extras_require[':python_version=="2.6"'] = ['argparse'] + extras_require[':sys_platform=="win32"'] = ['colorama'] + else: + if sys.version_info < (2, 7) or (3,) <= sys.version_info < (3, 2): + install_requires.append('argparse') + if sys.platform == 'win32': + install_requires.append('colorama') setup( name='pytest', @@ -48,6 +61,7 @@ def main(): cmdclass={'test': PyTest}, # the following should be enabled for release install_requires=install_requires, + extras_require=extras_require, packages=['_pytest', '_pytest.assertion'], py_modules=['pytest'], zip_safe=False, From 40a682476dab9e2e50b83b803457e78d478dbf0a Mon Sep 17 00:00:00 2001 From: Ionel Cristian Maries Date: Fri, 10 Apr 2015 21:44:27 +0300 Subject: [PATCH 2/7] Improve version test (use pkg_resources to compare versions). Also log failures to stderr. --HG-- branch : pytest-2.7 --- setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 038e5f633..e7d74c793 100644 --- a/setup.py +++ b/setup.py @@ -29,8 +29,10 @@ def get_version(): def has_newish_setuptools(): try: import setuptools - return tuple(int(i) for i in str(setuptools.__version__).split('.')) > (0, 7) - except Exception: + import pkg_resources + return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7') + except Exception as exc: + sys.stderr.write("Could not test setuptool's version: %s\n" % exc) return False From a58cb3b95ceaf4bc73b71d664e898bd071ddcfd5 Mon Sep 17 00:00:00 2001 From: Ionel Cristian Maries Date: Fri, 10 Apr 2015 21:58:59 +0300 Subject: [PATCH 3/7] Test for setuptools 0.7.2, turns out there's no 0.7 release on pypi. --HG-- branch : pytest-2.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e7d74c793..d30f71a4a 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ def has_newish_setuptools(): try: import setuptools import pkg_resources - return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7') + return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7.2') except Exception as exc: sys.stderr.write("Could not test setuptool's version: %s\n" % exc) return False From edd6c0f9b3088df8d7d0e18094ddbb1ec92aedec Mon Sep 17 00:00:00 2001 From: Ionel Cristian Maries Date: Fri, 10 Apr 2015 21:59:47 +0300 Subject: [PATCH 4/7] Make argpase a dependency for python 3.0 and 3.1 too. --HG-- branch : pytest-2.7 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d30f71a4a..4225d22c2 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ def main(): install_requires = ['py>=1.4.25'] extras_require = {} if has_newish_setuptools(): - extras_require[':python_version=="2.6"'] = ['argparse'] + extras_require[':python_version=="2.6" or python_version=="3.0" or python_version=="3.1"'] = ['argparse'] extras_require[':sys_platform=="win32"'] = ['colorama'] else: if sys.version_info < (2, 7) or (3,) <= sys.version_info < (3, 2): From db08dcab143a70876ac09f2a87d4f7adc9428461 Mon Sep 17 00:00:00 2001 From: Ionel Cristian Maries Date: Fri, 10 Apr 2015 22:11:17 +0300 Subject: [PATCH 5/7] Rename function and add nice docstring. --HG-- branch : pytest-2.7 --- setup.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 4225d22c2..e9f1fb54a 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,18 @@ def get_version(): raise ValueError("could not read version") -def has_newish_setuptools(): +def has_environment_marker_support(): + """ + Tests that setuptools has support for PEP-426 environment marker support. + + The first known release to support it is 0.7 (and the earliest on PyPI seems to be 0.7.2 + so we're using that), see: http://pythonhosted.org/setuptools/history.html#id142 + + References: + + * https://wheel.readthedocs.org/en/latest/index.html#defining-conditional-dependencies + * https://www.python.org/dev/peps/pep-0426/#environment-markers + """ try: import setuptools import pkg_resources @@ -39,7 +50,7 @@ def has_newish_setuptools(): def main(): install_requires = ['py>=1.4.25'] extras_require = {} - if has_newish_setuptools(): + if has_environment_marker_support(): extras_require[':python_version=="2.6" or python_version=="3.0" or python_version=="3.1"'] = ['argparse'] extras_require[':sys_platform=="win32"'] = ['colorama'] else: From 129bb5393ba2102d1942c12eca39df003a67d981 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Sun, 12 Apr 2015 23:36:28 +0100 Subject: [PATCH 6/7] Do imports at the head of the file --HG-- branch : pytest-2.7 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index e9f1fb54a..5af27b1f5 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,6 @@ import os, sys +import setuptools +import pkg_resources from setuptools import setup, Command classifiers = ['Development Status :: 6 - Mature', @@ -39,8 +41,6 @@ def has_environment_marker_support(): * https://www.python.org/dev/peps/pep-0426/#environment-markers """ try: - import setuptools - import pkg_resources return pkg_resources.parse_version(setuptools.__version__) >= pkg_resources.parse_version('0.7.2') except Exception as exc: sys.stderr.write("Could not test setuptool's version: %s\n" % exc) From 9cae9a2a977073612ec00ceba2436399972a44d6 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Sun, 12 Apr 2015 23:36:43 +0100 Subject: [PATCH 7/7] Add wheel support in the changelog --HG-- branch : pytest-2.7 --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index e83fae916..7747c292c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,9 @@ - fixed docs to remove the notion that yield-fixtures are experimental. They are here to stay :) Thanks Bruno Oliveira. +- Support building wheels by using environment markers for the + requirements. Thanks Ionel Maries Cristian. + 2.7.0 (compared to 2.6.4) -----------------------------