From 8de11b091fc705f235b1304fb101c27a82dcda6f Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Tue, 25 Oct 2016 14:01:31 +0200 Subject: [PATCH] Build: Makefiles for Python packages This version builds only one version of Python packages. If you want to build for Python 2 & 3 call configure twice using different --with-python or specify PYTHON variable when calling make. dist-hook is using SOURCES.txt file from egg-info. According to Petr Viktorin this should be enough for our purposes and avoids need to create plugins for setuptools. Currently VPATH builds do not work for various reasons. This should be fixed later on. Most credit goes to these guys: Christian Heimes Petr Viktorin Kevin Brown https://fedorahosted.org/freeipa/ticket/6418 Reviewed-By: Martin Basti Reviewed-By: Christian Heimes --- .gitignore | 3 --- Makefile.am | 2 ++ Makefile.python.am | 38 ++++++++++++++++++++++++++++++++++++++ configure.ac | 6 ++++++ freeipa.spec.in | 4 +++- ipaclient/Makefile.am | 1 + ipalib/Makefile | 24 ------------------------ ipalib/Makefile.am | 1 + ipaplatform/Makefile.am | 1 + ipapython/Makefile | 38 -------------------------------------- ipapython/Makefile.am | 1 + ipaserver/Makefile.am | 1 + ipatests/Makefile.am | 3 +++ 13 files changed, 57 insertions(+), 66 deletions(-) create mode 100644 Makefile.python.am create mode 100644 ipaclient/Makefile.am delete mode 100644 ipalib/Makefile create mode 100644 ipalib/Makefile.am create mode 100644 ipaplatform/Makefile.am delete mode 100644 ipapython/Makefile create mode 100644 ipapython/Makefile.am create mode 100644 ipaserver/Makefile.am create mode 100644 ipatests/Makefile.am diff --git a/.gitignore b/.gitignore index 8ba75d488..98e6ef255 100644 --- a/.gitignore +++ b/.gitignore @@ -68,10 +68,7 @@ freeipa2-dev-doc /client/ipa-join /client/ipa-rmkeytab -!/ipalib/Makefile - /ipapython/version.py -!/ipapython/Makefile /ipaplatform/__init__.py /ipaplatform/constants.py diff --git a/Makefile.am b/Makefile.am index 1e6b47519..6f36c3336 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,3 +3,5 @@ SUBDIRS = asn1 util client daemons install ipaclient ipalib ipaplatform ipapytho # contrib # doc # init + +MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo diff --git a/Makefile.python.am b/Makefile.python.am new file mode 100644 index 000000000..0ea3fcf16 --- /dev/null +++ b/Makefile.python.am @@ -0,0 +1,38 @@ +pkgname = $(shell basename "$(abs_srcdir)") +pkgpythondir = $(pythondir)/$(pkgname) + +all-local: + cd $(srcdir); $(PYTHON) setup.py build \ + --build-base "$(abs_builddir)/build" \ + --verbose + +install-exec-local: + $(PYTHON) $(srcdir)/setup.py install \ + --prefix "$(DESTDIR)$(prefix)" \ + --single-version-externally-managed \ + --record "$(DESTDIR)$(pkgpythondir)/install_files.txt" \ + --optimize 1 \ + --verbose + +uninstall-local: + cat "$(DESTDIR)$(pkgpythondir)/install_files.txt" | xargs rm -rf + rm -rf "$(DESTDIR)$(pkgpythondir)" + +clean-local: + $(PYTHON) "$(srcdir)/setup.py" clean --all + rm -rf "$(srcdir)/build" "$(srcdir)/dist" "$(srcdir)/MANIFEST" + find "$(srcdir)" \ + -name "*.py[co]" -delete -o \ + -name "__pycache__" -delete -o \ + -name "*.egg-info" -exec rm -rf {} + + +# take list of all Python source files and copy them into distdir +# SOURCES.txt does not contain directories so we need to create those +dist-hook: + $(PYTHON) "$(srcdir)/setup.py" egg_info + PYTHON_SOURCES=$$(cat "$(srcdir)/$(pkgname).egg-info/SOURCES.txt") || exit $$?; \ + for FILEN in $${PYTHON_SOURCES}; \ + do \ + if test -x "$(srcdir)/$${FILEN}"; then MODE=755; else MODE=644; fi; \ + $(INSTALL) -D -m $${MODE} "$(srcdir)/$${FILEN}" "$(distdir)/$${FILEN}" || exit $$?; \ + done diff --git a/configure.ac b/configure.ac index 6873f5657..b773c0360 100644 --- a/configure.ac +++ b/configure.ac @@ -461,8 +461,14 @@ AC_CONFIG_FILES([ install/restart_scripts/Makefile install/wsgi/Makefile install/oddjob/Makefile + ipaclient/Makefile + ipalib/Makefile + ipaplatform/Makefile + ipapython/Makefile ipapython/version.py + ipaserver/Makefile ipasetup.py + ipatests/Makefile ipatests/man/Makefile po/Makefile util/Makefile diff --git a/freeipa.spec.in b/freeipa.spec.in index 7a093c3e9..15a5d7d53 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -5,7 +5,7 @@ %if 0%{?rhel} %global with_python3 0 %else -%global with_python3 1 +%global with_python3 0 %endif # lint is not executed during rpmbuild @@ -699,6 +699,8 @@ make %{?_smp_mflags} client-check VERBOSE=yes LIBDIR=%{_libdir} %install %make_install +# remove files which are useful only for make uninstall +find %{buildroot} -wholename '*/site-packages/*/install_files.txt' -exec rm {} \; 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} diff --git a/ipaclient/Makefile.am b/ipaclient/Makefile.am new file mode 100644 index 000000000..8be72b25d --- /dev/null +++ b/ipaclient/Makefile.am @@ -0,0 +1 @@ +include $(top_srcdir)/Makefile.python.am diff --git a/ipalib/Makefile b/ipalib/Makefile deleted file mode 100644 index 9d5c2c1c4..000000000 --- a/ipalib/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -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 -rf *~ *.pyc __pycache__/ - -distclean: clean - -maintainer-clean: distclean - rm -rf build diff --git a/ipalib/Makefile.am b/ipalib/Makefile.am new file mode 100644 index 000000000..8be72b25d --- /dev/null +++ b/ipalib/Makefile.am @@ -0,0 +1 @@ +include $(top_srcdir)/Makefile.python.am diff --git a/ipaplatform/Makefile.am b/ipaplatform/Makefile.am new file mode 100644 index 000000000..8be72b25d --- /dev/null +++ b/ipaplatform/Makefile.am @@ -0,0 +1 @@ +include $(top_srcdir)/Makefile.python.am diff --git a/ipapython/Makefile b/ipapython/Makefile deleted file mode 100644 index 7ecc5f565..000000000 --- a/ipapython/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -PYTHON ?= /usr/bin/python2 -PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib())") - -all: - @for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done - -check: - -.PHONY: install -install: - if [ "$(DESTDIR)" = "" ]; then \ - $(PYTHON) setup.py install; \ - else \ - $(PYTHON) setup.py install --root $(DESTDIR); \ - fi - @for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done - -clean: - rm -rf *~ *.pyc __pycache__/ - @for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done - -distclean: clean - rm -f ipa-python.spec version.py - @for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done - -maintainer-clean: distclean - rm -rf build - @for subdir in $(SUBDIRS); do \ - (cd $$subdir && $(MAKE) $@) || exit 1; \ - done diff --git a/ipapython/Makefile.am b/ipapython/Makefile.am new file mode 100644 index 000000000..8be72b25d --- /dev/null +++ b/ipapython/Makefile.am @@ -0,0 +1 @@ +include $(top_srcdir)/Makefile.python.am diff --git a/ipaserver/Makefile.am b/ipaserver/Makefile.am new file mode 100644 index 000000000..8be72b25d --- /dev/null +++ b/ipaserver/Makefile.am @@ -0,0 +1 @@ +include $(top_srcdir)/Makefile.python.am diff --git a/ipatests/Makefile.am b/ipatests/Makefile.am new file mode 100644 index 000000000..4f3bca221 --- /dev/null +++ b/ipatests/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = man + +include $(top_srcdir)/Makefile.python.am