URL: https://github.com/freeipa/freeipa/pull/702
Author: tiran
 Title: #702: Correct PyPI package dependencies
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/702/head:pr702
git checkout pr702
From 21208052af34b21e14840df73ce4b3a000484d81 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Mon, 10 Apr 2017 10:00:23 +0200
Subject: [PATCH 1/2] Correct PyPI package dependencies

* Remove unused install requires from ipapython
* Add missing requirements to ipaserver
* Correct dependencies for yubico otptoken
* Add explicit dependency on cffi for csrgen
* Python 2 uses python-ldap, Python 3 pyldap

https://pagure.io/freeipa/issue/6875

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 ipaclient/setup.py |  5 ++---
 ipapython/setup.py |  6 ++----
 ipaserver/setup.py |  5 ++++-
 ipasetup.py.in     | 16 ++++++++++++----
 ipatests/setup.py  |  3 ++-
 tox.ini            |  3 +--
 6 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/ipaclient/setup.py b/ipaclient/setup.py
index ccb5396..0140fd5 100644
--- a/ipaclient/setup.py
+++ b/ipaclient/setup.py
@@ -50,12 +50,11 @@
             ],
         },
         install_requires=[
+            "cffi",
             "cryptography",
             "ipalib",
             "ipapython",
             "jinja2",
-            "python-yubico",
-            "pyusb",
             "qrcode",
             "six",
         ],
@@ -66,7 +65,7 @@
         },
         extras_require={
             "install": ["ipaplatform"],
-            "otptoken_yubikey": ["yubico", "usb"]
+            "otptoken_yubikey": ["python-yubico", "pyusb"],
         },
         zip_safe=False,
     )
diff --git a/ipapython/setup.py b/ipapython/setup.py
index f4bc3f8..4f71530 100755
--- a/ipapython/setup.py
+++ b/ipapython/setup.py
@@ -41,16 +41,14 @@
             "cryptography",
             "dnspython",
             "gssapi",
-            "jwcrypto",
             # "ipalib",  # circular dependency
-            "pyldap",
             "netaddr",
             "netifaces",
-            "requests",
             "six",
         ],
         extras_require={
-            ":python_version<'3'": ["enum34"],
+            ":python_version<'3'": ["enum34", "python-ldap"],
+            ":python_version>='3'": ["pyldap"],
             "install": ["dbus-python"],  # for certmonger
         },
     )
diff --git a/ipaserver/setup.py b/ipaserver/setup.py
index 097508f..f48cef4 100755
--- a/ipaserver/setup.py
+++ b/ipaserver/setup.py
@@ -55,10 +55,11 @@
             "ipalib",
             "ipaplatform",
             "ipapython",
+            "jwcrypto",
             "lxml",
             "netaddr",
             "pyasn1",
-            "pyldap",
+            "requests",
             "six",
         ],
         entry_points={
@@ -70,6 +71,8 @@
             ],
         },
         extras_require={
+            ":python_version<'3'": ["python-ldap"],
+            ":python_version>='3'": ["pyldap"],
             # These packages are currently not available on PyPI.
             "dcerpc": ["samba", "pysss", "pysss_nss_idmap"],
             "hbactest": ["pyhbac"],
diff --git a/ipasetup.py.in b/ipasetup.py.in
index b0a5051..2ad57e2 100644
--- a/ipasetup.py.in
+++ b/ipasetup.py.in
@@ -101,6 +101,7 @@ common_args = dict(
         "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
         "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: Implementation :: CPython",
         "Operating System :: POSIX",
         "Operating System :: POSIX :: Linux",
@@ -138,13 +139,20 @@ 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
+    # Env markers like ":python_version<'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(k))
+            if not k.startswith(':'):
+                continue
+            values = setup_kwargs['extras_require'].pop(k)
+            req = setup_kwargs.setdefault('install_requires', [])
+            if k == ":python_version<'3'" and sys.version_info.major == 2:
+                req.extend(values)
+            elif k == ":python_version>='3'" and sys.version_info.major >= 3:
+                req.extend(values)
+            else:
+                raise ValueError(k, values)
 
     os.chdir(local_path)
     try:
diff --git a/ipatests/setup.py b/ipatests/setup.py
index 4c02c79..00b9334 100644
--- a/ipatests/setup.py
+++ b/ipatests/setup.py
@@ -68,12 +68,13 @@
             "ipapython",
             "nose",
             "polib",
-            "pyldap",
             "pytest",
             "pytest_multihost",
             "six",
         ],
         extras_require={
+            ":python_version<'3'": ["python-ldap"],
+            ":python_version>='3'": ["pyldap"],
             "integration": ["dbus-python", "pyyaml", "ipaserver"],
             "ipaserver": ["ipaserver"],
             "webui": ["selenium", "pyyaml", "ipaserver"],
diff --git a/tox.ini b/tox.ini
index db551df..ccface9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -22,8 +22,7 @@ commands=
 [testenv:pylint2]
 basepython=python2.7
 deps=
-    ipaclient
-    ipapython[certmonger]
+    ipaclient[otptoken_yubikey]
     pylint
 commands=
     {envpython} -m pylint \

From 23e3680fbbc9d1050bf735c5851809978adece52 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Tue, 25 Apr 2017 13:15:02 +0200
Subject: [PATCH 2/2] Band-aid for pip dependency bug

pip install foo foo[more] does not install the extra dependencies 'more'
of foo. It's a known bug in pip, see
https://github.com/pypa/pip/issues/4391#issuecomment-290712930 and
https://github.com/pypa/pip/issues/988

The same bug applies to pip wheel. As a workaround pip wheel first
builds extra dependencies, then wheel dependencies. This ensures that
ipaclient[otptoken_yubikey] dependencies get built properly.

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 7608dfa..cbe4f2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -295,7 +295,7 @@ wheel_bundle: $(WHEELBUNDLEDIR) bdist_wheel .wheelconstraints
 	    --find-links $(WHEELDISTDIR) \
 	    --find-links $(WHEELBUNDLEDIR) \
 	    --wheel-dir $(WHEELBUNDLEDIR) \
-	    $(IPA_WHEEL_PACKAGES) $(IPA_EXTRA_WHEELS)
+	    $(IPA_EXTRA_WHEELS) $(IPA_WHEEL_PACKAGES)
 
 pypi_packages: $(WHEELPYPIDIR) .wheelconstraints
 	rm -f $(WHEELPYPIDIR)/*
-- 
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