URL: https://github.com/freeipa/freeipa/pull/263
Author: tiran
 Title: #263: Backwards compatibility with setuptools 0.9.8
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/263/head:pr263
git checkout pr263
From 6fe7e95b2e6715378103506a45ef630dad0db863 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Tue, 22 Nov 2016 16:08:46 +0100
Subject: [PATCH] Backwards compatibility with setuptools 0.9.8

Setuptools 0.9.8 does not support PEP 440 version schema with +git
suffix and PEP 508 env markers.

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 ipasetup.py.in | 31 +++++++++++++++++++++++++------
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git a/ipasetup.py.in b/ipasetup.py.in
index fac4b25..2f6ed96 100644
--- a/ipasetup.py.in
+++ b/ipasetup.py.in
@@ -50,16 +50,27 @@ class build_py(setuptools_build_py):
             return setuptools_build_py.build_module(self, module,
                                                     module_file, package)
 
+import setuptools
+
+VERSION = '@VERSION@'
+
+SETUPTOOLS_VERSION = tuple(int(v) for v in setuptools.__version__.split("."))
+
+# backwards compatibility with setuptools 0.9.8, split off +gitHASH suffix
+# PEP 440 was introduced in setuptools 8.
+if SETUPTOOLS_VERSION < (8, 0, 0):
+    VERSION = VERSION.split('+')[0]
+
 
 PACKAGE_VERSION = {
     'cryptography': 'cryptography >= 0.9',
     'dnspython': 'dnspython >= 1.11.1',
     'gssapi': 'gssapi > 1.1.2',
-    'ipaclient': 'ipaclient == @VERSION@',
-    'ipalib': 'ipalib == @VERSION@',
-    'ipaplatform': 'ipaplatform == @VERSION@',
-    'ipapython': 'ipapython == @VERSION@',
-    'ipaserver': 'ipaserver == @VERSION@',
+    'ipaclient': 'ipaclient == {}'.format(VERSION),
+    'ipalib': 'ipalib == {}'.format(VERSION),
+    'ipaplatform': 'ipaplatform == {}'.format(VERSION),
+    'ipapython': 'ipapython == {}'.format(VERSION),
+    'ipaserver': 'ipaserver == {}'.format(VERSION),
     'kdcproxy': 'kdcproxy >= 0.3',
     'netifaces': 'netifaces >= 0.10.4',
     'python-nss': 'python-nss >= 0.16',
@@ -70,7 +81,7 @@ PACKAGE_VERSION = {
 
 
 common_args = dict(
-    version="@VERSION@",
+    version=VERSION,
     license="GPLv3",
     author="FreeIPA Developers",
     author_email="freeipa-devel@redhat.com",
@@ -126,6 +137,14 @@ def ipasetup(name, doc, **kwargs):
     cmdclass = setup_kwargs.setdefault('cmdclass', {})
     cmdclass['build_py'] = build_py
 
+    # Env markers like ":python_version<'3.3'" are not supported by
+    # setuptools < 18.0.
+    if 'extras_require' in setup_kwargs and SETUPTOOLS_VERSION < (18, 0, 0):
+        for k in list(setup_kwargs['extras_require']):
+            if k.startswith(':'):
+                req = setup_kwargs.setdefault('install_requires', [])
+                req.extend(setup_kwargs['extras_require'].pop(key))
+
     os.chdir(local_path)
     try:
         # BEFORE importing distutils, remove MANIFEST. distutils doesn't
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to