Skip to content

Commit

Permalink
Build: Makefiles for Python packages
Browse files Browse the repository at this point in the history
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 <[email protected]>
 Petr Viktorin <[email protected]>
 Kevin Brown <[email protected]>

https://fedorahosted.org/freeipa/ticket/6418

Reviewed-By: Martin Basti <[email protected]>
Reviewed-By: Christian Heimes <[email protected]>
  • Loading branch information
pspacek authored and Martin Babinsky committed Nov 9, 2016
1 parent 81da45f commit 8de11b0
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 66 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ SUBDIRS = asn1 util client daemons install ipaclient ipalib ipaplatform ipapytho
# contrib
# doc
# init

MOSTLYCLEANFILES = ipasetup.pyc ipasetup.pyo
38 changes: 38 additions & 0 deletions Makefile.python.am
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion freeipa.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions ipaclient/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(top_srcdir)/Makefile.python.am
24 changes: 0 additions & 24 deletions ipalib/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions ipalib/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(top_srcdir)/Makefile.python.am
1 change: 1 addition & 0 deletions ipaplatform/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(top_srcdir)/Makefile.python.am
38 changes: 0 additions & 38 deletions ipapython/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions ipapython/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(top_srcdir)/Makefile.python.am
1 change: 1 addition & 0 deletions ipaserver/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include $(top_srcdir)/Makefile.python.am
3 changes: 3 additions & 0 deletions ipatests/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS = man

include $(top_srcdir)/Makefile.python.am

0 comments on commit 8de11b0

Please sign in to comment.