fix: python agent: use stdlib distutils when setuptools is installed
[lttng-ust.git] / python-lttngust / Makefile.am
1 GENERATED_BINDINGS_DEPS = \
2 lttngust/__init__.py \
3 setup.py
4
5 # For python < 3.12, force the use of distutils even if setuptools is
6 # installed. For python >= 3.12, set the externally managed option to allow
7 # installation in a directory which isn't in the current PYTHONPATH.
8 if HAVE_PYTHON_312_OR_GREATER
9 PY_INSTALL_OPTS = --single-version-externally-managed
10 else
11 export SETUPTOOLS_USE_DISTUTILS=stdlib
12 endif
13
14 # Use setup.py for the installation instead of Autoconf.
15 # This ease the installation process and assure a *pythonic*
16 # installation.
17 all-local: $(GENERATED_BINDINGS_DEPS)
18 $(PYTHON) setup.py build --verbose
19
20 install-exec-local:
21 @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \
22 if [ "$(DESTDIR)" != "" ]; then \
23 opts="$$opts --root=$(DESTDIR)"; \
24 fi; \
25 $(PYTHON) setup.py install $(PY_INSTALL_OPTS) $$opts;
26
27 clean-local:
28 rm -rf $(builddir)/build
29
30 # Distutils' setup.py does not include an uninstall target, we thus need to do
31 # it manually. We fake an install in a temporary folder and use the generated
32 # tree structure to infere the actual location within the install prefix.
33 # 1. Create temporary file and folder
34 # 2. Set the root install folder for a temporary folder
35 # 3. Install in that temporary folder and record all the files installed
36 # 4. If DESTDIR is set, prepend it to the paths of the install files
37 # 5. Remove the installed files and the Python package folder
38 # 6. Remove the files created by this target
39
40 uninstall-local:
41 $(eval TMP_INSTALLED_FILES:=$(shell mktemp $(builddir)/tmp-installed-files-XXXXXX))
42 $(eval TMP_INSTALL_DIR:=$(shell mktemp -d $(builddir)/tmp-install-dir-XXXXXX))
43 $(eval TMP_BUILD_DIR:=$(shell mktemp -d $(builddir)/tmp-build-dir-XXXXXX))
44 @opts="--root=$(TMP_INSTALL_DIR) --prefix=$(prefix) --record $(TMP_INSTALLED_FILES) --no-compile $(DISTSETUPOPTS)"; \
45 if [ "$(DESTDIR)" != "" ]; then \
46 opts="$$opts --root=$(DESTDIR)"; \
47 else \
48 opts="$$opts --root=$(TMP_INSTALL_DIR)"; \
49 fi; \
50 $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts > /dev/null || true
51
52 if [ "$(DESTDIR)" != "" ]; then \
53 $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \
54 fi
55
56 cat $(TMP_INSTALLED_FILES) | xargs rm -rf || true
57 $(GREP) "__init__.py" $(TMP_INSTALLED_FILES) | xargs dirname | xargs rm -rf || true
58 rm -f $(TMP_INSTALLED_FILES)
59 rm -rf $(TMP_INSTALL_DIR)
60 rm -rf $(TMP_BUILD_DIR)
This page took 0.031787 seconds and 5 git commands to generate.