Hello,
I noticed I didn't attach an updated patch last time, which probably
affected the discussion here. Sorry for that; it's attached this time.

We seem to have a disconenct here: there are two different strategies to
do the packaging.

Your idea of the port seems to be to have the py2 and py3 packages "in
sync", so they're almost exact copies of each other. This keeps things
consistent, but I'm not sure this specific kind of consistency is better
than the alternative.

My approach is to make new, better packages for Python 3. I treat this
as a bit of a sandbox, a new chance to do things right. My patch tries
to keep the existing Python 2 packages untouched where it's feasible, to
minimize regressions.
(I did add new Provides based on your review, though, so users can use
the "consistent" names.)
When the py3 packages are finalized, the changes can be applied to the
py2 ones as well. (Or not, if it's decided it's a case of fixing things
that ain't broke.)

So, two paths to get to the same goal. I'm not saying yours is bad, but
I fail to see how it's objectively better. If it is, could you explain
why? Otherwise please take this patch as an incremental improvement with
priorities that are a bit different than yours.


On 11/30/2015 09:59 AM, Jan Cholasta wrote:
> On 27.11.2015 13:46, Petr Viktorin wrote:
>> On 11/26/2015 11:52 AM, Jan Cholasta wrote:
>>> 1) The freeipa-common subpackage is not necessary: /etc/ipa/dnssec
>>> should be owned by freeipa-server and everything else in /etc/ipa
>>> currently owned by freeipa-python should be owned by freeipa-client.
>>
>> If the common files are in freeipa-server or freeipa-client, then the
>> Python 3 packages would need to depend on those. I'd like to avoid that.
> 
> I'm not sure I follow. The files do not belong to freeipa-python, since
> they are used only by freeipa-server and freeipa-client. What Python 3
> packages would need to depend on them?

python3-ipaserver and python3-ipaclient, eventually.

Anyway, /etc/ipa/default.conf is used directly by ipapython.config, so
at least that should be owned by a common package. And once there's a
common package, I don't think there's a problem with it holding the
other tiny files as well.
Also, a lot of the other files are mentioned in ipaplatform.base.paths,
which is part of the freeipa-python, so it seems fitting that that's
what should require them, rather than the -client or -server packages.

>>> This should be a separate patch. I have prepared one, see attachment.
>>>
>>>
>>> 2) IMO this patch does too much, it should only add the Python 3
>>> equivalent of freeipa-python - python3-ipalib - but none of the other
>>> packages/provides.
>>
>> My reasoning for the new packages:
>> - python3-ipalib is the main point
> 
> Right.
> 
>> - freeipa-common contains files that both the py2 and py3 versions need
> 
> See above.
> 
>> - python-ipap11helper has compiled code: with this pulled out,
>> python3-ipalib can be noarch
> 
> This is not the goal here, but if you insist on doing it, do it for
> Python 2 as well.

It is definitely the goal of this patch to make the py3 packages as good
as possible. That includes making them noarch.
On the other hand improving the py2 packages is not a goal of this
particular patch.

>> - python3-ipatests is needed if we want to start testing the py3
>> packages in  CI
> 
> Right.
> 
>>
>> As for new provides, Fedora's Python packaging guidelines say:
>>
>> """
>> Using a fictional module named "example", the subpackage containing
>> the python2 version must provide python2-example. This is of course
>> always the case if the subpackage is named python2-example [...]
>> If the subpackage has some other name then then Provides: python2-example
>> must be added explicitly (but see the %python_provide macro below).
>>
>> The python3 subpackage must provide python3-example. However, as the
>> naming guidelines mandate that the python3 subpackage be named
>> python3-example, this will happen automatically.
>> """
>>
>> so I'm now adding Provides for the top-level modules.
> 
> The goal of this work is to add support for Python 3, not to comply with
> Fedora packaging guidelines. FreeIPA on Fedora uses its own spec file
> anyway.

The goal of this patch is to add new packages that support Python 3.
Yes, the Fedora spec is different, but it's heavily based on the
upstream one, and this is a good thing. I consider the Fedora guidelines
the standard in Python RPM packaging. If IPA uses different packaging
guidelines, can you point me to them?

> Again, if you insist on doing this, do it for Python 2 as well.

Improving the py2 packages would be great, but again it is not the goal
of this patch.

>>> 3) Speaking of freeipa-python, it should be renamed to python-ipalib,
>>> for consistency.
>>>
>>> This should also be a separate patch, again see attachment.
>>
>> I think that would just be unnecessary churn. Python 3 gives us a chance
>> for a fresh start, so I'm taking advantage of that, but renaming
>> existing packages is a pain.
> 
> Something similar was done in SSSD not long ago and according to Lukáš
> (CCd), it was no pain.

OK. But again, not the goal here.

>> With the right Provides, "dnf install python-ipalib" (or python2-ipalib)
>> will do the right thing, and I thing that's enough.
> 
> I don't think that's good enough, since it creates an inconsistency.
> 
>>
>>> 4) There should be a python3-devel (and also other python3- equivalents
>>> of python- packages) BuildRequires when Python 3 support is enabled.
>>
>> I did miss that somehow. Thanks for checking.
>> I added python3-devel; the others are unnecessary because pylint is not
>> currently run on the Python3 version.
> 
> OK, I think that will do for now. Note that many of them are required
> for makeapi and makeaci as well.
> 
> When can we expect a Python 3 pylint patch which adds the remaining
> BuildRequires?

That's something we'll need to talk about in the future: do we want to
run python2-pylint and python3-pylint on every build?
Anyway, I'd like to see the Python3 tests for ipapython and ipalib run
in CI first.


-- 
Petr Viktorin

From 550551442b6444ef2e47a91b729bbc433415260a Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Tue, 3 Nov 2015 16:39:40 +0100
Subject: [PATCH] Package ipapython, ipalib, ipaplatform, ipatests for Python 3

Running make with PYTHON=/usr/bin/python3 will build/install the
bits for Python 3.

A separate setup.py is added for ipalib.

Python3 library RPMs have names according to Fedora guidelines (python3-*).
Provides are specified for all top-level Python modules.

Executable scripts in ipatests have symlinks Python version suffixes
as per Fedora guidelines. Suffix-less names point to the Python 2 versions.

Pure-Python files are packaged to noarch RPMs. The ipap11helper
module is split to its own RPM for this reason.

A new package, freeipa-common, is added for files from freeipa-python
usable by both Python versions: translations and configuration.
This package is required by both freeipa-python and python3-ipalib.
---
 .gitignore                             |   3 +
 Makefile                               |   7 +-
 freeipa.spec.in                        | 237 +++++++++++++++++++++++++++++++--
 ipalib/Makefile                        |  25 ++++
 ipalib/cli.py                          |   1 +
 ipalib/setup.py.in                     |  73 ++++++++++
 ipapython/Makefile                     |  18 +--
 ipapython/ipap11helper/Makefile        |  11 +-
 ipapython/py_default_encoding/Makefile |  21 +--
 setup.py                               |   2 -
 10 files changed, 357 insertions(+), 41 deletions(-)
 create mode 100644 ipalib/Makefile
 create mode 100644 ipalib/setup.py.in

diff --git a/.gitignore b/.gitignore
index fa35df85abd5b18522d2be17070c3d8aceb9bdc5..e63434b44b29fc25bf3da17e90bc0f75f5075bd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,9 @@ freeipa2-dev-doc
 
 /ipatests/setup.py
 
+/ipalib/setup.py
+!/ipalib/Makefile
+
 /ipapython/setup.py
 /ipapython/version.py
 !/ipapython/Makefile
diff --git a/Makefile b/Makefile
index d2c37f1597a011af2bd9ef1a4f7ce87ac59620a3..5c1b7df3384a54114588b604dbe2e4648fb8ccbe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,10 @@
 include VERSION
 
-SUBDIRS=asn1 daemons install ipapython ipa-client
+SUBDIRS=asn1 daemons install ipapython ipalib ipa-client
 CLIENTDIRS=ipapython ipa-client asn1
 
 PRJ_PREFIX=freeipa
+PRJ_PREFIX_PY3=python3-ipa
 
 RPMBUILD ?= $(PWD)/rpmbuild
 TARGET ?= master
@@ -140,6 +141,8 @@ version-update: release-update
 		> ipapython/setup.py
 	sed -e s/__VERSION__/$(IPA_VERSION)/ ipaplatform/setup.py.in \
 		> ipaplatform/setup.py
+	sed -e s/__VERSION__/$(IPA_VERSION)/ ipalib/setup.py.in \
+		> ipalib/setup.py
 	sed -e s/__VERSION__/$(IPA_VERSION)/ ipapython/version.py.in \
 		> ipapython/version.py
 	sed -e s/__VERSION__/$(IPA_VERSION)/ ipatests/setup.py.in \
@@ -237,6 +240,7 @@ rpms: rpmroot rpmdistdir version-update lint tarballs
 	cp dist/sources/$(TARBALL) $(RPMBUILD)/SOURCES/.
 	rpmbuild --define "_topdir $(RPMBUILD)" -ba freeipa.spec
 	cp $(RPMBUILD)/RPMS/*/$(PRJ_PREFIX)-*-$(IPA_VERSION)-*.rpm dist/rpms/
+	cp $(RPMBUILD)/RPMS/*/$(PRJ_PREFIX_PY3)*-$(IPA_VERSION)-*.rpm dist/rpms/
 	cp $(RPMBUILD)/SRPMS/$(PRJ_PREFIX)-$(IPA_VERSION)-*.src.rpm dist/srpms/
 	rm -rf $(RPMBUILD)
 
@@ -244,6 +248,7 @@ client-rpms: rpmroot rpmdistdir version-update lint tarballs
 	cp dist/sources/$(TARBALL) $(RPMBUILD)/SOURCES/.
 	rpmbuild --define "_topdir $(RPMBUILD)" --define "ONLY_CLIENT 1" -ba freeipa.spec
 	cp $(RPMBUILD)/RPMS/*/$(PRJ_PREFIX)-*-$(IPA_VERSION)-*.rpm dist/rpms/
+	cp $(RPMBUILD)/RPMS/*/$(PRJ_PREFIX_PY3)*-$(IPA_VERSION)-*.rpm dist/rpms/
 	cp $(RPMBUILD)/SRPMS/$(PRJ_PREFIX)-$(IPA_VERSION)-*.src.rpm dist/srpms/
 	rm -rf $(RPMBUILD)
 
diff --git a/freeipa.spec.in b/freeipa.spec.in
index 0011aa05f17d7ebf79e20c411b470e5345f3d03a..c97fa03a5156c54ed5a602478b5d822d73335982 100644
--- a/freeipa.spec.in
+++ b/freeipa.spec.in
@@ -2,6 +2,12 @@
 # subpackages
 %{!?ONLY_CLIENT:%global ONLY_CLIENT 0}
 
+%if 0%{?rhel}
+%global with_python3 0
+%else
+%global with_python3 1
+%endif
+
 %global alt_name ipa
 %if 0%{?rhel}
 %global samba_version 4.0.5-1
@@ -102,6 +108,10 @@ BuildRequires:  custodia
 BuildRequires:  libcmocka-devel
 BuildRequires:  nss_wrapper
 
+%if 0%{?with_python3}
+BuildRequires:  python3-devel
+%endif  # with_python3
+
 %description
 IPA is an integrated solution to provide centrally managed Identity (users,
 hosts, services), Authentication (SSO, 2FA), and Authorization
@@ -169,6 +179,9 @@ Provides: %{alt_name}-server = %{version}
 Conflicts: %{alt_name}-server
 Obsoletes: %{alt_name}-server < %{version}
 
+Provides: python2-ipaserver = %{version}
+%{?python_provide:%python_provide python2-ipaserver}
+
 # With FreeIPA 3.3, package freeipa-server-selinux was obsoleted as the
 # entire SELinux policy is stored in the system policy
 Obsoletes: freeipa-server-selinux < 3.3.0
@@ -282,6 +295,9 @@ Provides: %{alt_name}-client = %{version}
 Conflicts: %{alt_name}-client
 Obsoletes: %{alt_name}-client < %{version}
 
+Provides: python2-ipaclient = %{version}
+%{?python_provide:%python_provide python2-ipaclient}
+
 %description client
 IPA is an integrated solution to provide centrally managed Identity (users,
 hosts, services), Authentication (SSO, 2FA), and Authorization
@@ -314,6 +330,8 @@ This package provides command-line tools for IPA administrators.
 %package python
 Summary: Python libraries used by IPA
 Group: System Environment/Libraries
+
+Requires: %{name}-common = %{version}-%{release}
 Requires: python-gssapi >= 1.1.2
 Requires: gnupg
 Requires: iproute
@@ -339,6 +357,15 @@ Provides: %{alt_name}-python = %{version}
 Conflicts: %{alt_name}-python
 Obsoletes: %{alt_name}-python < %{version}
 
+Provides: python2-ipapython = %{version}
+Provides: python2-ipalib = %{version}
+Provides: python2-ipaplatform = %{version}
+Provides: python2-ipap11helper = %{version}
+%{?python_provide:%python_provide python2-ipapython}
+%{?python_provide:%python_provide python2-ipalib}
+%{?python_provide:%python_provide python2-ipaplatform}
+%{?python_provide:%python_provide python2-ipap11helper}
+
 %description python
 IPA is an integrated solution to provide centrally managed Identity (users,
 hosts, services), Authentication (SSO, 2FA), and Authorization
@@ -347,6 +374,78 @@ features for further integration with Linux based clients (SUDO, automount)
 and integration with Active Directory based infrastructures (Trusts).
 If you are using IPA, you need to install this package.
 
+%if 0%{?with_python3}
+
+%package -n python3-ipalib
+BuildArch: noarch
+Summary: Python 3 libraries used by IPA
+Group: System Environment/Libraries
+
+Provides: python3-ipaplatform = %{version}
+Provides: python3-ipapython = %{version}
+%{?python_provide:%python_provide python3-ipalib}
+%{?python_provide:%python_provide python3-ipaplatform}
+%{?python_provide:%python_provide python3-ipapython}
+
+Requires: %{name}-common = %{version}-%{release}
+Requires: python3-ipap11helper%{?_isa} = %{version}-%{release}
+Requires: python3-gssapi >= 1.1.2
+Requires: gnupg
+Requires: iproute
+Requires: keyutils
+Requires: python3-pyOpenSSL
+Requires: python3-nss >= 0.16
+Requires: python3-cryptography
+Requires: python3-lxml
+Requires: python3-netaddr
+Requires: python3-libipa_hbac
+Requires: python3-qrcode-core >= 5.0.0
+Requires: python3-pyasn1
+Requires: python3-dateutil
+Requires: python3-yubico >= 1.2.3
+Requires: python3-sss-murmur
+Requires: wget
+Requires: python3-dbus
+Requires: python3-setuptools
+Requires: python3-six
+Requires: python3-jwcrypto
+
+%description -n python3-ipalib
+IPA is an integrated solution to provide centrally managed Identity (users,
+hosts, services), Authentication (SSO, 2FA), and Authorization
+(host access control, SELinux user roles, services). The solution provides
+features for further integration with Linux based clients (SUDO, automount)
+and integration with Active Directory based infrastructures (Trusts).
+This package is needed for running IPA components under Python 3.
+
+%package -n python3-ipap11helper
+Summary: Python 3 libraries used by IPA
+Group: System Environment/Libraries
+
+%{?python_provide:%python_provide python3-ipap11helper}
+
+%description -n python3-ipap11helper
+IPA is an integrated solution to provide centrally managed Identity (users,
+hosts, services), Authentication (SSO, 2FA), and Authorization
+(host access control, SELinux user roles, services). The solution provides
+features for further integration with Linux based clients (SUDO, automount)
+and integration with Active Directory based infrastructures (Trusts).
+This package contains the ipap11helper extension for Python 3.
+
+%endif # with_python3
+
+%package common
+Summary: Common files used by IPA
+Group: System Environment/Libraries
+
+%description common
+IPA is an integrated solution to provide centrally managed Identity (users,
+hosts, services), Authentication (SSO, 2FA), and Authorization
+(host access control, SELinux user roles, services). The solution provides
+features for further integration with Linux based clients (SUDO, automount)
+and integration with Active Directory based infrastructures (Trusts).
+If you are using IPA, you need to install this package.
+
 %if ! %{ONLY_CLIENT}
 %package tests
 Summary: IPA tests and test tools
@@ -366,6 +465,9 @@ Provides: %{alt_name}-tests = %{version}
 Conflicts: %{alt_name}-tests
 Obsoletes: %{alt_name}-tests < %{version}
 
+Provides: python2-ipatests = %{version}
+%{?python_provide:%python_provide python2-ipatests}
+
 %description tests
 IPA is an integrated solution to provide centrally managed Identity (users,
 hosts, services), Authentication (SSO, 2FA), and Authorization
@@ -374,6 +476,34 @@ features for further integration with Linux based clients (SUDO, automount)
 and integration with Active Directory based infrastructures (Trusts).
 This package contains tests that verify IPA functionality.
 
+%if 0%{?with_python3}
+
+%package -n python3-ipatests
+Summary: IPA tests and test tools
+BuildArch: noarch
+
+Requires: python3-ipalib = %{version}-%{release}
+Requires: tar
+Requires: xz
+Requires: python3-nose
+Requires: python3-pytest >= 2.6
+Requires: python3-coverage
+Requires: python3-polib
+Requires: python3-pytest-multihost >= 0.5
+Requires: python3-pytest-sourceorder
+
+%{?python_provide:%python_provide python3-ipatests}
+
+%description -n python3-ipatests
+IPA is an integrated solution to provide centrally managed Identity (users,
+hosts, services), Authentication (SSO, 2FA), and Authorization
+(host access control, SELinux user roles, services). The solution provides
+features for further integration with Linux based clients (SUDO, automount)
+and integration with Active Directory based infrastructures (Trusts).
+This package contains tests that verify IPA functionality under Python 3.
+
+%endif # with_python3
+
 %endif # ONLY_CLIENT
 
 
@@ -402,6 +532,10 @@ cd daemons; ../autogen.sh --prefix=%{_usr} --sysconfdir=%{_sysconfdir} --localst
 cd install; ../autogen.sh --prefix=%{_usr} --sysconfdir=%{_sysconfdir} --localstatedir=%{_localstatedir} --libdir=%{_libdir} --mandir=%{_mandir}; cd ..
 %endif # ONLY_CLIENT
 
+%if 0%{?with_python3}
+(cd ipapython/ipap11helper && make PYTHON=%{__python3} IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} all)
+%endif
+
 %if ! %{ONLY_CLIENT}
 make IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} all
 %else
@@ -424,9 +558,38 @@ rm -f ipaplatform/constants.py
 make version-update
 %if ! %{ONLY_CLIENT}
 make install DESTDIR=%{buildroot}
+
+mv %{buildroot}%{_bindir}/ipa-run-tests %{buildroot}%{_bindir}/ipa-run-tests-%{python2_version}
+mv %{buildroot}%{_bindir}/ipa-test-config %{buildroot}%{_bindir}/ipa-test-config-%{python2_version}
+mv %{buildroot}%{_bindir}/ipa-test-task %{buildroot}%{_bindir}/ipa-test-task-%{python2_version}
+
+%if 0%{?with_python3}
+(cd ipatests && %{__python3} setup.py install --root %{buildroot})
+mv %{buildroot}%{_bindir}/ipa-run-tests %{buildroot}%{_bindir}/ipa-run-tests-%{python3_version}
+mv %{buildroot}%{_bindir}/ipa-test-config %{buildroot}%{_bindir}/ipa-test-config-%{python3_version}
+mv %{buildroot}%{_bindir}/ipa-test-task %{buildroot}%{_bindir}/ipa-test-task-%{python3_version}
+ln -s %{_bindir}/ipa-run-tests-%{python3_version} %{buildroot}%{_bindir}/ipa-run-tests-3
+ln -s %{_bindir}/ipa-test-config-%{python3_version} %{buildroot}%{_bindir}/ipa-test-config-3
+ln -s %{_bindir}/ipa-test-task-%{python3_version} %{buildroot}%{_bindir}/ipa-test-task-3
+%endif # with_python3
+
+ln -s %{_bindir}/ipa-run-tests-%{python2_version} %{buildroot}%{_bindir}/ipa-run-tests-2
+ln -s %{_bindir}/ipa-test-config-%{python2_version} %{buildroot}%{_bindir}/ipa-test-config-2
+ln -s %{_bindir}/ipa-test-task-%{python2_version} %{buildroot}%{_bindir}/ipa-test-task-2
+ln -s %{_bindir}/ipa-run-tests-%{python2_version} %{buildroot}%{_bindir}/ipa-run-tests
+ln -s %{_bindir}/ipa-test-config-%{python2_version} %{buildroot}%{_bindir}/ipa-test-config
+ln -s %{_bindir}/ipa-test-task-%{python2_version} %{buildroot}%{_bindir}/ipa-test-task
+
 %else
 make client-install DESTDIR=%{buildroot}
 %endif # ONLY_CLIENT
+
+%if 0%{?with_python3}
+(cd ipalib && make PYTHON=%{__python3} IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} DESTDIR=%{buildroot} install)
+(cd ipapython && make PYTHON=%{__python3} IPA_VERSION_IS_GIT_SNAPSHOT=no %{?_smp_mflags} DESTDIR=%{buildroot} install)
+(cd ipaplatform && %{__python3} setup.py install --root %{buildroot})
+%endif # with_python3
+
 %find_lang %{gettext_domain}
 
 
@@ -948,7 +1111,22 @@ fi
 %config %{_sysconfdir}/bash_completion.d
 %{_mandir}/man1/ipa.1.gz
 
-%files python -f %{gettext_domain}.lang
+%files common -f %{gettext_domain}.lang
+%defattr(-,root,root,-)
+%doc README Contributors.txt
+%license COPYING
+%dir %attr(0755,root,root) %{_sysconfdir}/ipa/
+%ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/default.conf
+%ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/ca.crt
+%dir %attr(0755,root,root) %{_sysconfdir}/ipa/nssdb
+%dir %attr(0755,root,root) %{_sysconfdir}/ipa/dnssec
+%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/cert8.db
+%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/key3.db
+%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/secmod.db
+%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/pwdfile.txt
+%ghost %config(noreplace) %{_sysconfdir}/pki/ca-trust/source/ipa.p11-kit
+
+%files python
 %defattr(-,root,root,-)
 %doc README Contributors.txt
 %license COPYING
@@ -967,20 +1145,34 @@ fi
 %attr(0644,root,root) %{python_sitearch}/default_encoding_utf8.so
 %attr(0644,root,root) %{python_sitearch}/_ipap11helper.so
 %{python_sitelib}/ipapython-*.egg-info
+%{python_sitelib}/ipalib-*.egg-info
 %{python_sitelib}/freeipa-*.egg-info
 %{python_sitelib}/ipaplatform-*.egg-info
 %{python_sitearch}/python_default_encoding-*.egg-info
 %{python_sitearch}/_ipap11helper-*.egg-info
-%dir %attr(0755,root,root) %{_sysconfdir}/ipa/
-%ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/default.conf
-%ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/ca.crt
-%dir %attr(0755,root,root) %{_sysconfdir}/ipa/nssdb
-%dir %attr(0755,root,root) %{_sysconfdir}/ipa/dnssec
-%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/cert8.db
-%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/key3.db
-%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/secmod.db
-%ghost %config(noreplace) %{_sysconfdir}/ipa/nssdb/pwdfile.txt
-%ghost %config(noreplace) %{_sysconfdir}/pki/ca-trust/source/ipa.p11-kit
+
+%if 0%{?with_python3}
+%files -n python3-ipalib
+%defattr(-,root,root,-)
+%doc README Contributors.txt
+%license COPYING
+
+%{python3_sitelib}/ipapython/
+%{python3_sitelib}/ipalib/
+%{python3_sitelib}/ipaplatform/
+%{python3_sitelib}/ipapython-*.egg-info
+%{python3_sitelib}/ipalib-*.egg-info
+%{python3_sitelib}/ipaplatform-*.egg-info
+
+%files -n python3-ipap11helper
+%defattr(-,root,root,-)
+%doc README Contributors.txt
+%license COPYING
+
+%attr(0644,root,root) %{python3_sitearch}/_ipap11helper.cpython-*.so
+%{python3_sitearch}/_ipap11helper-*.egg-info
+
+%endif # with_python3
 
 %if ! %{ONLY_CLIENT}
 %files tests -f tests-python.list
@@ -1001,10 +1193,33 @@ fi
 %{_bindir}/ipa-run-tests
 %{_bindir}/ipa-test-config
 %{_bindir}/ipa-test-task
+%{_bindir}/ipa-run-tests-2
+%{_bindir}/ipa-test-config-2
+%{_bindir}/ipa-test-task-2
+%{_bindir}/ipa-run-tests-%{python2_version}
+%{_bindir}/ipa-test-config-%{python2_version}
+%{_bindir}/ipa-test-task-%{python2_version}
 %{python_sitelib}/ipatests-*.egg-info
 %{_mandir}/man1/ipa-run-tests.1.gz
 %{_mandir}/man1/ipa-test-config.1.gz
 %{_mandir}/man1/ipa-test-task.1.gz
+
+%if 0%{?with_python3}
+%files -n python3-ipatests
+%defattr(-,root,root,-)
+%doc README Contributors.txt
+%license COPYING
+
+%{python3_sitelib}/ipatests/
+%{_bindir}/ipa-run-tests-3
+%{_bindir}/ipa-test-config-3
+%{_bindir}/ipa-test-task-3
+%{_bindir}/ipa-run-tests-%{python3_version}
+%{_bindir}/ipa-test-config-%{python3_version}
+%{_bindir}/ipa-test-task-%{python3_version}
+%{python3_sitelib}/ipatests-*.egg-info
+%endif # with_python3
+
 %endif # ONLY_CLIENT
 
 %changelog
diff --git a/ipalib/Makefile b/ipalib/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..5bd84fa4a7e77c14abc84f8edb50e24ac318ddee
--- /dev/null
+++ b/ipalib/Makefile
@@ -0,0 +1,25 @@
+PYTHON ?= /usr/bin/python2
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib())")
+
+all:
+	# Pure Python; no need to build
+	true
+
+check:
+
+.PHONY: install
+install:
+	if [ "$(DESTDIR)" = "" ]; then \
+		$(PYTHON) setup.py install; \
+	else \
+		$(PYTHON) setup.py install --root $(DESTDIR); \
+	fi
+
+clean:
+	rm -f *~ *.pyc __pycache__/
+
+distclean: clean
+	rm -f setup.py
+
+maintainer-clean: distclean
+	rm -rf build
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 44ef61d3033c0a187ba84f682b5d88b2130076bf..567b599461c9c7d474881212e62be0179e09108f 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -47,6 +47,7 @@ except ImportError:
     # this is already installed and since it is installed with IPA therein
     # lies the problem. Skip it for now so ipalib can be imported in-tree
     # even in cases that IPA isn't installed on the dev machine.
+    # Also, under Python 3, default_encoding_utf8 is not built at all.
     pass
 
 from ipalib import frontend
diff --git a/ipalib/setup.py.in b/ipalib/setup.py.in
new file mode 100644
index 0000000000000000000000000000000000000000..47481dbe0c6b95e1c419258da1eb9b2543a8a3d8
--- /dev/null
+++ b/ipalib/setup.py.in
@@ -0,0 +1,73 @@
+#!/usr/bin/python2
+# Copyright (C) 2007  Red Hat
+# see file 'COPYING' for use and warranty information
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""FreeIPA common python library
+
+FreeIPA is a server for identity, policy, and audit.
+"""
+
+DOCLINES = __doc__.split("\n")
+
+import os
+import sys
+import distutils.sysconfig
+
+CLASSIFIERS = """\
+Intended Audience :: System Environment/Base
+License :: GPL
+Programming Language :: Python
+Operating System :: POSIX
+Operating System :: Unix
+"""
+
+# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
+# update it when the contents of directories change.
+if os.path.exists('MANIFEST'): os.remove('MANIFEST')
+
+def setup_package():
+
+    from distutils.core import setup
+
+    old_path = os.getcwd()
+    local_path = os.path.dirname(os.path.abspath(sys.argv[0]))
+    os.chdir(local_path)
+    sys.path.insert(0,local_path)
+
+    try:
+        setup(
+            name = "ipalib",
+            version = "__VERSION__",
+            license = "GPL",
+            url = "http://www.freeipa.org/";,
+            description = DOCLINES[0],
+            long_description = "\n".join(DOCLINES[2:]),
+            download_url = "http://www.freeipa.org/page/Downloads";,
+            classifiers=[line for line in CLASSIFIERS.split('\n') if line],
+            platforms = ["Linux", "Solaris", "Unix"],
+            package_dir = {'ipalib': ''},
+            packages = ["ipalib",
+                        "ipalib.plugins",
+                       ],
+        )
+    finally:
+        del sys.path[0]
+        os.chdir(old_path)
+    return
+
+if __name__ == '__main__':
+    setup_package()
diff --git a/ipapython/Makefile b/ipapython/Makefile
index a865ca7580f5270eca4383508ced23e8537da669..833f3cdc561129a7f7646987ee2fe6e56a768acd 100644
--- a/ipapython/Makefile
+++ b/ipapython/Makefile
@@ -1,7 +1,5 @@
-PYTHONLIBDIR ?= $(shell  python2 -c "from distutils.sysconfig import *; print get_python_lib()")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/ipa
-CONFIGDIR ?= $(DESTDIR)/etc/ipa
-TESTS = $(wildcard test/*.py)
+PYTHON ?= /usr/bin/python2
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib())")
 
 SUBDIRS = py_default_encoding ipap11helper
 
@@ -15,16 +13,16 @@ check:
 .PHONY: install
 install:
 	if [ "$(DESTDIR)" = "" ]; then \
-		python2 setup.py install; \
+		$(PYTHON) setup.py install; \
 	else \
-		python2 setup.py install --root $(DESTDIR); \
+		$(PYTHON) setup.py install --root $(DESTDIR); \
 	fi
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
 
 clean:
-	rm -f *~ *.pyc
+	rm -f *~ *.pyc __pycache__/
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
@@ -40,9 +38,3 @@ maintainer-clean: distclean
 	@for subdir in $(SUBDIRS); do \
 		(cd $$subdir && $(MAKE) $@) || exit 1; \
 	done
-
-.PHONY: test
-test: $(subst .py,.tst,$(TESTS))
-
-%.tst: %.py
-	python2 $<
diff --git a/ipapython/ipap11helper/Makefile b/ipapython/ipap11helper/Makefile
index 88f17f70588e1fa20ed98409e37f7dc2e72b6f68..f66edb82e5aec83d3d6b2b666a1e3441e45b3b13 100644
--- a/ipapython/ipap11helper/Makefile
+++ b/ipapython/ipap11helper/Makefile
@@ -1,15 +1,14 @@
-PYTHONLIBDIR ?= $(shell  python2 -c "from distutils.sysconfig import *; print get_python_lib()")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/ipa
-CONFIGDIR ?= $(DESTDIR)/etc/ipa
+PYTHON ?= /usr/bin/python2
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib())")
 
 all:
-	python2 setup.py build
+	$(PYTHON) setup.py build
 
 install:
 	if [ "$(DESTDIR)" = "" ]; then \
-		python2 setup.py install; \
+		$(PYTHON) setup.py install; \
 	else \
-		python2 setup.py install --root $(DESTDIR); \
+		$(PYTHON) setup.py install --root $(DESTDIR); \
 	fi
 
 clean:
diff --git a/ipapython/py_default_encoding/Makefile b/ipapython/py_default_encoding/Makefile
index 88f17f70588e1fa20ed98409e37f7dc2e72b6f68..a73f429dbb71fb89998685d55124b6bb42b17cf4 100644
--- a/ipapython/py_default_encoding/Makefile
+++ b/ipapython/py_default_encoding/Makefile
@@ -1,15 +1,20 @@
-PYTHONLIBDIR ?= $(shell  python2 -c "from distutils.sysconfig import *; print get_python_lib()")
-PACKAGEDIR ?= $(DESTDIR)/$(PYTHONLIBDIR)/ipa
-CONFIGDIR ?= $(DESTDIR)/etc/ipa
+PYTHON ?= /usr/bin/python2
+PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib())")
+PYTHONVERSION ?= $(shell $(PYTHON) -c "import sys; print(sys.version_info[0])")
 
 all:
-	python2 setup.py build
+	if [ "$(PYTHONVERSION)" = "2" ]; then \
+		python2 setup.py build; \
+	fi
 
 install:
-	if [ "$(DESTDIR)" = "" ]; then \
-		python2 setup.py install; \
-	else \
-		python2 setup.py install --root $(DESTDIR); \
+	# Skip this module under Python 3
+	if [ "$(PYTHONVERSION)" = "2" ]; then \
+		if [ "$(DESTDIR)" = "" ]; then \
+			python2 setup.py install; \
+		else \
+			python2 setup.py install --root $(DESTDIR); \
+		fi; \
 	fi
 
 clean:
diff --git a/setup.py b/setup.py
index 330503d6125ddff287b39874c1754fa04d15e7c9..006f34e70fb7862005ee7feae7a4c3d6209f3d3d 100755
--- a/setup.py
+++ b/setup.py
@@ -75,8 +75,6 @@ setup(
     license='GPLv3+',
     url='http://freeipa.org/',
     packages=[
-        'ipalib',
-        'ipalib.plugins',
         'ipaserver',
         'ipaserver.advise',
         'ipaserver.advise.plugins',
-- 
2.5.0

-- 
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