fix: python agent: use stdlib distutils when setuptools is installed
[lttng-ust.git] / src / python-lttngust / Makefile.am
1 # SPDX-License-Identifier: LGPL-2.1-only
2
3 INSTALLED_FILES=$(builddir)/installed_files.txt
4
5 STATIC_BINDINGS_DEPS = \
6 lttngust/__init__.py \
7 lttngust/agent.py \
8 lttngust/cmd.py \
9 lttngust/compat.py \
10 lttngust/debug.py \
11 lttngust/loghandler.py
12
13 GENERATED_BINDINGS_DEPS = \
14 lttngust/version.py \
15 setup.py
16
17 # For python < 3.12, force the use of distutils even if setuptools is
18 # installed. For python >= 3.12, set the externally managed option to allow
19 # installation in a directory which isn't in the current PYTHONPATH.
20 if HAVE_PYTHON_312_OR_GREATER
21 PY_INSTALL_OPTS = --single-version-externally-managed
22 else
23 export SETUPTOOLS_USE_DISTUTILS=stdlib
24 endif
25
26 all-local: build-python-bindings.stamp
27
28 copy-static-deps.stamp: $(addprefix $(srcdir)/, $(STATIC_BINDINGS_DEPS))
29 @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
30 for file in $(STATIC_BINDINGS_DEPS); do \
31 cp -f $(srcdir)/$$file $(builddir)/$$file; \
32 done; \
33 fi
34 touch $@
35
36 # Use setup.py for the installation instead of Autoconf.
37 # This ease the installation process and assure a *pythonic*
38 # installation.
39 build-python-bindings.stamp: copy-static-deps.stamp $(GENERATED_BINDINGS_DEPS)
40 $(PYTHON) $(builddir)/setup.py build --force
41 touch $@
42
43 install-exec-local: build-python-bindings.stamp
44 @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \
45 if [ "$(DESTDIR)" != "" ]; then \
46 opts="$$opts --root=$(DESTDIR)"; \
47 fi; \
48 $(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts;
49
50 clean-local:
51 rm -rf $(builddir)/build
52 @if [ x"$(srcdir)" != x"$(builddir)" ]; then \
53 for file in $(STATIC_BINDINGS_DEPS); do \
54 rm -f $(builddir)/$$file; \
55 done; \
56 fi
57
58 # Distutils' setup.py does not include an uninstall target, we thus need to do
59 # it manually. We save the path of the files that were installed during the install target
60 # and delete them during the uninstallation.
61 uninstall-local:
62 if [ "$(DESTDIR)" != "" ]; then \
63 $(SED) -i "s|^|$(DESTDIR)/|g" $(INSTALLED_FILES); \
64 fi
65 cat $(INSTALLED_FILES) | xargs rm -rf || true
66 $(GREP) "__init__.py" $(INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
67 rm -f $(INSTALLED_FILES)
68
69 EXTRA_DIST = $(STATIC_BINDINGS_DEPS)
70
71 CLEANFILES = \
72 build-python-bindings.stamp \
73 copy-static-deps.stamp
This page took 0.03129 seconds and 4 git commands to generate.