Hi,

here a three patch that I like to push upstream before I finalize my
Python 3 branch.

The first patch addresses an incompatibility with python-sphinx 1.1 that
I introduced last week. The chance is required to build Dogtag on RHEL 7.

The second patch just moves some Python dependencies from pki-base to
pki-server.

The last one fixes another issue with RHEL and simplifies the spec file.

Christian
From 59f752dcc69c65eb3e98ccf35fff35fd97364fce Mon Sep 17 00:00:00 2001
From: Christian Heimes <[email protected]>
Date: Wed, 2 Mar 2016 18:03:45 +0100
Subject: [PATCH 57/59] Backwards compatibility with sphinx 1.1

sphinx 1.1 doesn't have sphinx.version_info. All supported version have
sphinx.__version__ string. conf.py now parses the string for version
tests.
---
 base/common/python/conf.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/base/common/python/conf.py b/base/common/python/conf.py
index f996c6371cbd545ae5fc9cc3e12cab0977d56cdb..4792254e3d3928b95665759ba390daf9c260604f 100644
--- a/base/common/python/conf.py
+++ b/base/common/python/conf.py
@@ -21,6 +21,8 @@ import sphinx
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
 
+# Sphinx 1.1 has only sphinx.__version__ string
+SPHINX_VERSION = tuple(int(v) for v in sphinx.__version__.split('.')[:2])
 
 # -- General configuration -----------------------------------------------
 
@@ -95,7 +97,7 @@ pygments_style = 'sphinx'
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-if sphinx.version_info < (1, 3):
+if SPHINX_VERSION < (1, 3):
     html_theme = 'default'
 else:
     html_theme = 'classic'
-- 
2.5.0

From 87aa704104bbdff23133b890bb81faafb845b4c5 Mon Sep 17 00:00:00 2001
From: Christian Heimes <[email protected]>
Date: Wed, 2 Mar 2016 18:06:40 +0100
Subject: [PATCH 58/59] Slim down pki-base dependencies

The pki Python modules don't require python-ldap and python-lxml. The
dependencies are only used by the pki.server package.
---
 specs/pki-core.spec | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 349a3f83d73de36333087866b6daa84fa4af4167..76fce56e928696626a02a4a82bfcdca8f8996f4d 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -271,8 +271,6 @@ Obsoletes:        pki-common < %{version}-%{release}
 Obsoletes:        pki-util < %{version}-%{release}
 
 Conflicts:        freeipa-server < 3.0.0
-Requires:         python-ldap
-Requires:         python-lxml
 Requires:         python-nss
 Requires:         python-requests >= 1.1.0-3
 Requires:         python-six
@@ -406,6 +404,8 @@ Requires:         openldap-clients
 Requires:         pki-base = %{version}-%{release}
 Requires:         pki-base-java = %{version}-%{release}
 Requires:         pki-tools = %{version}-%{release}
+Requires:         python-ldap
+Requires:         python-lxml
 Requires:         policycoreutils-python
 %if 0%{?fedora} >= 23
 Requires:         policycoreutils-python-utils
-- 
2.5.0

From 83b2cf7f7e0876758886f59776a729c3fe3fe01c Mon Sep 17 00:00:00 2001
From: Christian Heimes <[email protected]>
Date: Wed, 2 Mar 2016 19:24:28 +0100
Subject: [PATCH 59/59] Simplify Python package installation

* The cmake files now copy just *.py into the installation directory.
  This ensures that no stale pyc files or __pycache__ directories are
  copied. rpmbuilder takes care of pyc/pyo compilation on Fedora and
  RHEL.
* The pki-core.spec file uses python2 macros. In case of RHEL missing
  macros are defined on the top of the file.
* A bug in the python_sitelib macros has been fixed. rpmbuilder doesn't
  like lines breaks.
---
 base/common/python/CMakeLists.txt |  2 ++
 base/server/CMakeLists.txt        |  6 ++++--
 specs/pki-core.spec               | 24 ++++++++----------------
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/base/common/python/CMakeLists.txt b/base/common/python/CMakeLists.txt
index a164597755e4a48169610fbf81a092c57cc0dd9f..f6e57b949815f61f8b38f6d2d9da8df501029376 100644
--- a/base/common/python/CMakeLists.txt
+++ b/base/common/python/CMakeLists.txt
@@ -44,6 +44,8 @@ install(
         pki
     DESTINATION
         ${PYTHON_SITE_PACKAGES}
+    FILES_MATCHING PATTERN
+        *.py
 )
 
 install(
diff --git a/base/server/CMakeLists.txt b/base/server/CMakeLists.txt
index 058cbf167ea62e0c8a08454b4b43d7a5cc9dc048..c4c6baacf62ccea1680c612b3b76b69adf0c46dd 100644
--- a/base/server/CMakeLists.txt
+++ b/base/server/CMakeLists.txt
@@ -35,9 +35,11 @@ install(
 # install Python libraries
 install(
     DIRECTORY
-        python/
+        python/pki/server
     DESTINATION
-        ${PYTHON_SITE_PACKAGES}
+        ${PYTHON_SITE_PACKAGES}/pki/server
+    FILES_MATCHING PATTERN
+        *.py
 )
 
 # install systemd scripts
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 76fce56e928696626a02a4a82bfcdca8f8996f4d..c69800ce5245c87f9c33e2db134d37687e6fd001 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -1,8 +1,7 @@
-# Python
-%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from
-distutils.sysconfig import get_python_lib; print(get_python_lib())")}
-%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from
-distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+# Python, keep every statement on a single line
+%{!?__python2: %global __python2 /usr/bin/python2}
+%{!?python2_sitelib: %global python2_sitelib %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+
 
 # Tomcat
 %if 0%{?fedora} >= 23
@@ -737,13 +736,13 @@ ln -s %{_datadir}/pki/java-tools/KRATool.cfg %{buildroot}%{_datadir}/pki/java-to
 
 %if ! 0%{?rhel}
 # Scanning the python code with pylint.
-python2 ../pylint-build-scan.py rpm --prefix %{buildroot}
+%{__python2} ../pylint-build-scan.py rpm --prefix %{buildroot}
 if [ $? -ne 0 ]; then
     echo "pylint failed. RC: $?"
     exit 1
 fi
 
-python2 ../pylint-build-scan.py rpm --prefix %{buildroot} -- --py3k
+%{__python2} ../pylint-build-scan.py rpm --prefix %{buildroot} -- --py3k
 if [ $? -ne 0 ]; then
     echo "pylint --py3k failed. RC: $?"
     exit 1
@@ -879,14 +878,7 @@ systemctl daemon-reload
 %{_datadir}/pki/key/templates
 %dir %{_sysconfdir}/pki
 %config(noreplace) %{_sysconfdir}/pki/pki.conf
-%dir %{python_sitelib}/pki
-%{python_sitelib}/pki/*.py
-%{python_sitelib}/pki/*.pyc
-%{python_sitelib}/pki/*.pyo
-%dir %{python_sitelib}/pki/cli
-%{python_sitelib}/pki/cli/*.py
-%{python_sitelib}/pki/cli/*.pyc
-%{python_sitelib}/pki/cli/*.pyo
+%{python2_sitelib}/pki
 %dir %{_localstatedir}/log/pki
 %{_sbindir}/pki-upgrade
 %{_mandir}/man8/pki-upgrade.8.gz
@@ -958,7 +950,7 @@ systemctl daemon-reload
 %{_sbindir}/pki-server
 %{_sbindir}/pki-server-nuxwdog
 %{_sbindir}/pki-server-upgrade
-%{python_sitelib}/pki/server/
+%{python2_sitelib}/pki/server/
 %dir %{_datadir}/pki/deployment
 %{_datadir}/pki/deployment/config/
 %dir %{_datadir}/pki/scripts
-- 
2.5.0

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Pki-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to