URL: https://github.com/freeipa/freeipa/pull/195
Author: tiran
 Title: #195: [WIP] Make ipaclient pip install-able
Action: opened

PR body:
"""
This makes ipaclient and dependencies pip install-able by adding install 
requirements to all ```setup.py```. A new make target ```bdist_wheel``` creates 
wheel distributions.

## example
```
$ make bdist_wheel
$ cp ../custodia/dist/custodia-0.2-py2.py3-none-any.whl dist/
$ virtualenv /tmp/ipaenv
New python executable in /tmp/ipaenv/bin/python2
Also creating executable in /tmp/ipaenv/bin/python
Installing setuptools, pip, wheel...done.
$ /tmp/ipaenv/bin/pip install dist/*.whl
Processing ./dist/custodia-0.2-py2.py3-none-any.whl
Processing ./dist/ipaclient-4.4.90.201610271437GITd812266-py2.py3-none-any.whl
Processing ./dist/ipalib-4.4.90.201610271437GITd812266-py2.py3-none-any.whl
Processing ./dist/ipaplatform-4.4.90.201610271437GITd812266-py2.py3-none-any.whl
Processing ./dist/ipapython-4.4.90.201610271437GITd812266-py2.py3-none-any.whl
 
...
 
Installing collected packages: configparser, requests, six, idna, pycparser, 
cffi, pyasn1, enum34, ipaddress, cryptography, jwcrypto, custodia, qrcode, 
python-nss, ipaplatform, netaddr, lxml, pyldap, netifaces, decorator, gssapi, 
dnspython, ipapython, ipalib, ipaclient
  Running setup.py install for python-nss ... done
Successfully installed cffi-1.8.3 configparser-3.5.0 cryptography-1.5.2 
custodia-0.2 decorator-4.0.10 dnspython-1.15.0 enum34-1.1.6 gssapi-1.2.0 
idna-2.1 ipaclient-4.4.90.201610271437GITd812266 ipaddress-1.0.17 
ipalib-4.4.90.201610271437GITd812266 ipaplatform-4.4.90.201610271437GITd812266 
ipapython-4.4.90.201610271437GITd812266 jwcrypto-0.3.1 lxml-3.6.4 
netaddr-0.7.18 netifaces-0.10.5 pyasn1-0.1.9 pycparser-2.16 pyldap-2.4.25.1 
python-nss-1.0.0 qrcode-5.3 requests-2.11.1 six-1.10.0
```

## open problems

- [ ] Custodia is not yet released on PyPI (to be released soon)
- [ ] dependencies are duplicated in setup.py and RPM spec
- [ ] ipaplatform hard-codes the distribution on build time
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/195/head:pr195
git checkout pr195
From d8122663b5c9d8c992eec66f21a54be002840029 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Thu, 27 Oct 2016 14:04:58 +0200
Subject: [PATCH] Add install requirements to Python packages

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 Makefile              | 12 +++++++++++-
 ipaclient/setup.cfg   |  4 ++++
 ipaclient/setup.py    | 11 +++++++++++
 ipalib/setup.cfg      |  4 ++++
 ipalib/setup.py       |  8 ++++++++
 ipaplatform/setup.cfg |  4 ++++
 ipaplatform/setup.py  |  7 +++++++
 ipapython/setup.cfg   |  4 ++++
 ipapython/setup.py    | 17 +++++++++++++++++
 ipaserver/setup.cfg   |  4 ++++
 ipaserver/setup.py    | 25 ++++++++++++++++++++++++-
 ipasetup.py.in        | 24 ++++++++++++++++++++++++
 ipatests/setup.cfg    |  4 ++++
 ipatests/setup.py     | 23 ++++++++++++++++++++++-
 14 files changed, 148 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 761b57d..be775d3 100644
--- a/Makefile
+++ b/Makefile
@@ -7,6 +7,7 @@ SUBDIRS=util asn1 daemons install ipapython ipalib
 CLIENTDIRS=ipapython ipalib client util asn1
 CLIENTPYDIRS=ipaclient ipaplatform
 PYPKGDIRS=$(CLIENTPYDIRS) ipalib ipapython ipaserver ipatests
+WHEELS=$(CLIENTPYDIRS) ipalib ipapython
 
 PRJ_PREFIX=freeipa
 
@@ -166,13 +167,22 @@ ipasetup.py: ipasetup.py.in FORCE
 	sed -e s/__VERSION__/$(IPA_VERSION)/ $< > $@
 
 .PHONY: egg_info
-egg_info: ipapython/version.py ipaplatform/__init__.py ipasetup.py
+egg_info: bootstrap-autogen ipapython/version.py ipasetup.py
 	for directory in $(PYPKGDIRS); do \
 	    pushd $${directory} ; \
 	    $(PYTHON) setup.py egg_info $(EXTRA_SETUP); \
 	    popd ; \
 	done
 
+.PHONY: bdist_wheel
+bdist_wheel: egg_info
+	rm -f dist/*.whl
+	for directory in $(WHEELS); do \
+	    pushd $${directory} ; \
+	    $(PYTHON) setup.py bdist_wheel; \
+	    popd ; \
+	done
+
 version-update: release-update ipapython/version.py ipasetup.py
 	sed -e s/__VERSION__/$(IPA_VERSION)/ -e s/__RELEASE__/$(IPA_RPM_RELEASE)/ \
 		freeipa.spec.in > freeipa.spec
diff --git a/ipaclient/setup.cfg b/ipaclient/setup.cfg
index 34abb12..666b750 100644
--- a/ipaclient/setup.cfg
+++ b/ipaclient/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipaclient/setup.py b/ipaclient/setup.py
index 32778b0..6d12171 100644
--- a/ipaclient/setup.py
+++ b/ipaclient/setup.py
@@ -42,4 +42,15 @@
             "ipaclient.remote_plugins.2_156",
             "ipaclient.remote_plugins.2_164",
         ],
+        install_requires=[
+            "cryptography",
+            "ipalib",
+            "ipapython",
+            "python-nss",
+            "qrcode",
+            "six",
+        ],
+        extra_requires = {
+            "otptoken_yubikey": ["yubico", "usb"]
+        }
     )
diff --git a/ipalib/setup.cfg b/ipalib/setup.cfg
index 34abb12..666b750 100644
--- a/ipalib/setup.cfg
+++ b/ipalib/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipalib/setup.py b/ipalib/setup.py
index 982a783..2a7754c 100644
--- a/ipalib/setup.py
+++ b/ipalib/setup.py
@@ -35,4 +35,12 @@
         packages=[
             "ipalib",
         ],
+        install_requires=[
+            "ipaplatform",
+            "ipapython",
+            "netaddr",
+            "pyasn1",
+            "python-nss",
+            "six",
+        ],
     )
diff --git a/ipaplatform/setup.cfg b/ipaplatform/setup.cfg
index 34abb12..666b750 100644
--- a/ipaplatform/setup.cfg
+++ b/ipaplatform/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipaplatform/setup.py b/ipaplatform/setup.py
index 82499da..98a9f08 100644
--- a/ipaplatform/setup.py
+++ b/ipaplatform/setup.py
@@ -39,4 +39,11 @@
             "ipaplatform.redhat",
             "ipaplatform.rhel"
         ],
+        install_requires=[
+            "cffi",
+            # "ipalib",  # circular dependency
+            "pyasn1",
+            "python-nss",
+            "six",
+        ],
     )
diff --git a/ipapython/setup.cfg b/ipapython/setup.cfg
index 34abb12..666b750 100644
--- a/ipapython/setup.cfg
+++ b/ipapython/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipapython/setup.py b/ipapython/setup.py
index 47acdd6..e254253 100755
--- a/ipapython/setup.py
+++ b/ipapython/setup.py
@@ -38,4 +38,21 @@
             "ipapython.secrets",
             "ipapython.install"
         ],
+        install_requires=[
+            "cffi",
+            "custodia",
+            "cryptography",
+            "dnspython",
+            "gssapi",
+            "jwcrypto",
+            "ipaplatform",
+            # "ipalib",  # circular dependency
+            "pyldap",
+            "lxml",
+            "netaddr",
+            "netifaces",
+            "python-nss",
+            "requests",
+            "six",
+        ],
     )
diff --git a/ipaserver/setup.cfg b/ipaserver/setup.cfg
index 34abb12..666b750 100644
--- a/ipaserver/setup.cfg
+++ b/ipaserver/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipaserver/setup.py b/ipaserver/setup.py
index e24e197..0cd20da 100755
--- a/ipaserver/setup.py
+++ b/ipaserver/setup.py
@@ -31,7 +31,7 @@
     from ipasetup import ipasetup  # noqa: E402
 
     ipasetup(
-        name='freeipa',
+        name='ipaserver',
         doc=__doc__,
         package_dir={'ipaserver': ''},
         packages=[
@@ -43,4 +43,27 @@
             'ipaserver.install.plugins',
             'ipaserver.install.server',
         ],
+        install_requires=[
+            "cryptography",
+            "dnspython",
+            "dogtag-pki",
+            "ipaclient",
+            "ipalib",
+            "ipaplatform",
+            "ipapython",
+            "lxml",
+            "netaddr",
+            "memcache",
+            "pyasn1",
+            "pyldap",
+            "python-nss",
+            "six",
+            # not available on PyPI
+            # "python-dbus",
+            # "python-libipa_hbac",
+            # "python-sss",
+            # "python-sss-murmur",
+            # "python-SSSDConfig",
+            # "samba-python",
+        ],
     )
diff --git a/ipasetup.py.in b/ipasetup.py.in
index f291d22..2d65413 100644
--- a/ipasetup.py.in
+++ b/ipasetup.py.in
@@ -18,6 +18,25 @@
 import os
 import sys
 
+
+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__',
+    'kdcproxy': 'kdcproxy >= 0.3',
+    'netifaces': 'netifaces >= 0.10.4',
+    'python-nss': 'python-nss >= 0.16',
+    'pyldap': 'pyldap >= 2.4.15',
+    'qrcode': 'qrcode >= 5.0',
+    # 'yubico': 'yubico >= 1.2.3',
+}
+
+
 common_args = dict(
     version="__VERSION__",
     license="GPL",
@@ -48,11 +67,16 @@ old_path = os.path.abspath(os.getcwd())
 def ipasetup(name, doc, **kwargs):
     doclines = doc.split("\n")
 
+    install_requires = list(kwargs.pop('install_requires', []))
+    for i, entry in enumerate(install_requires):
+        install_requires[i] = PACKAGE_VERSION.get(entry, entry)
+
     setup_kwargs = common_args.copy()
     setup_kwargs.update(
         name=name,
         description=doclines[0],
         long_description="\n".join(doclines[:2]),
+        install_requires=install_requires,
         **kwargs
     )
     # exclude setup helpers from getting installed
diff --git a/ipatests/setup.cfg b/ipatests/setup.cfg
index 34abb12..666b750 100644
--- a/ipatests/setup.cfg
+++ b/ipatests/setup.cfg
@@ -1,4 +1,8 @@
+[sdist]
+dist-dir = ../dist
+
 [bdist_wheel]
+dist-dir = ../dist
 universal = 1
 
 [metadata]
diff --git a/ipatests/setup.py b/ipatests/setup.py
index 32a5207..1de0bbe 100644
--- a/ipatests/setup.py
+++ b/ipatests/setup.py
@@ -56,5 +56,26 @@
             'ipatests.test_pkcs10': ['*.csr'],
             "ipatests.test_ipaserver": ['data/*'],
             'ipatests.test_xmlrpc': ['data/*'],
-        }
+        },
+        install_requires=[
+            "cryptography",
+            "dnspython",
+            "dogtag-pki",
+            "ipaclient",
+            "ipalib",
+            "ipaplatform",
+            "ipapython",
+            "ipaserver",
+            "lxml",
+            "nose",
+            "pyldap",
+            "pytest",
+            "python-gssapi",
+            "python-nss",
+            "selenium",
+            "six",
+            "yaml",
+            # not available on PyPI
+            # "python-dbus",
+        ],
     )
-- 
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