Simplify python agent build
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 18 Mar 2021 17:45:06 +0000 (13:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 22 Mar 2021 20:27:59 +0000 (16:27 -0400)
Import the fixes and simplification to the python build integration with
autotools from babeltrace2.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I1da953c48acc2162f369893793e195803376a4f8
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
.gitignore
configure.ac
python-lttngust/Makefile.am

index d524b20cd48ae7dee4428339f871126abf37a994..26cb98ff57548ea9bf31421f56ed14c5720d3093 100644 (file)
@@ -105,3 +105,5 @@ python-lttngust/lttngust/__init__.py
 python-lttngust/**/*.pyc
 python-lttngust/build
 python-lttngust/setup.py
+python-lttngust/build-python-bindings.stamp
+python-lttngust/copy-static-deps.stamp
index a743278f0aa73930afb95c8b9e959a76cf405444..414daf6bfe621bd8179e805a1f5452b91b7454ff 100644 (file)
@@ -554,15 +554,6 @@ AC_CONFIG_FILES([
        lttng-ust-ctl.pc
 ])
 
-# Create link for python agent for the VPATH guru.
-AC_CONFIG_LINKS([
-       python-lttngust/lttngust/agent.py:python-lttngust/lttngust/agent.py
-       python-lttngust/lttngust/cmd.py:python-lttngust/lttngust/cmd.py
-       python-lttngust/lttngust/compat.py:python-lttngust/lttngust/compat.py
-       python-lttngust/lttngust/debug.py:python-lttngust/lttngust/debug.py
-       python-lttngust/lttngust/loghandler.py:python-lttngust/lttngust/loghandler.py
-])
-
 AC_CONFIG_FILES([tests/unit/ust-elf/test_ust_elf],[chmod +x tests/unit/ust-elf/test_ust_elf])
 
 AC_OUTPUT
index 8643d0f98340418154a9c79f8696f26c7ae0cd10..33a968f5a6393d322bfe12823e4fb0bee4325738 100644 (file)
@@ -1,49 +1,59 @@
 # SPDX-License-Identifier: LGPL-2.1-only
 
+INSTALLED_FILES=$(builddir)/installed_files.txt
+
+STATIC_BINDINGS_DEPS = \
+       lttngust/agent.py \
+       lttngust/cmd.py \
+       lttngust/compat.py \
+       lttngust/debug.py \
+       lttngust/loghandler.py
+
+all-local: build-python-bindings.stamp
+
+copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS))
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for file in $(STATIC_BINDINGS_DEPS); do \
+                       cp -f $(srcdir)/$$file $(builddir)/$$file; \
+               done; \
+       fi
+       touch $@
+
 # Use setup.py for the installation instead of Autoconf.
 # This ease the installation process and assure a *pythonic*
 # installation.
-all-local:
-       $(PYTHON) setup.py build --verbose
+build-python-bindings.stamp: copy-static-deps.stamp
+       $(PYTHON) $(builddir)/setup.py build --force
+       touch $@
 
-install-exec-local:
-       @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \
+install-exec-local: build-python-bindings.stamp
+       @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
        if [ "$(DESTDIR)" != "" ]; then \
                opts="$$opts --root=$(DESTDIR)"; \
        fi; \
-       $(PYTHON) setup.py install $$opts;
+       $(PYTHON) $(builddir)/setup.py install $$opts;
 
 clean-local:
        rm -rf $(builddir)/build
+       @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
+               for file in $(STATIC_BINDINGS_DEPS); do \
+                       rm -f $(builddir)/$$file; \
+               done; \
+       fi
 
 # Distutils' setup.py does not include an uninstall target, we thus need to do
-# it manually. We fake an install in a temporary folder and use the generated
-# tree structure to infere the actual location within the install prefix.
-# 1. Create temporary file and folder
-# 2. Set the root install folder for a temporary folder
-# 3. Install in that temporary folder and record all the files installed
-# 4. If DESTDIR is set, prepend it to the paths of the install files
-# 5. Remove the installed files and the Python package folder
-# 6. Remove the files created by this target
-
+# it manually. We save the path of the files that were installed during the install target
+# and delete them during the uninstallation.
 uninstall-local:
-       $(eval TMP_INSTALLED_FILES:=$(shell mktemp $(builddir)/tmp-installed-files-XXXXXX))
-       $(eval TMP_INSTALL_DIR:=$(shell mktemp -d $(builddir)/tmp-install-dir-XXXXXX))
-       $(eval TMP_BUILD_DIR:=$(shell mktemp -d $(builddir)/tmp-build-dir-XXXXXX))
-       @opts="--root=$(TMP_INSTALL_DIR) --prefix=$(prefix) --record $(TMP_INSTALLED_FILES) --no-compile $(DISTSETUPOPTS)"; \
-       if [ "$(DESTDIR)" != "" ]; then \
-               opts="$$opts --root=$(DESTDIR)"; \
-       else \
-               opts="$$opts --root=$(TMP_INSTALL_DIR)"; \
-       fi; \
-       $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts > /dev/null || true
-       
        if [ "$(DESTDIR)" != "" ]; then \
-               $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \
+               $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
        fi
-       
-       cat $(TMP_INSTALLED_FILES) | xargs rm -rf || true
-       $(GREP) "__init__.py" $(TMP_INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
-       rm -f $(TMP_INSTALLED_FILES)
-       rm -rf $(TMP_INSTALL_DIR)
-       rm -rf $(TMP_BUILD_DIR)
+       cat $(INSTALLED_FILES) | xargs rm -rf || true
+       $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
+       rm -f $(INSTALLED_FILES)
+
+EXTRA_DIST = $(STATIC_BINDINGS_DEPS)
+
+CLEANFILES = \
+       build-python-bindings.stamp \
+       copy-static-deps.stamp
This page took 0.026926 seconds and 4 git commands to generate.