From 8de11b091fc705f235b1304fb101c27a82dcda6f Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Tue, 25 Oct 2016 14:01:31 +0200 Subject: 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 --- Makefile.python.am | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Makefile.python.am (limited to 'Makefile.python.am') 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 -- cgit