1 GENERATED_BINDINGS_DEPS = \
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
11 export SETUPTOOLS_USE_DISTUTILS=stdlib
14 # Use setup.py for the installation instead of Autoconf.
15 # This ease the installation process and assure a *pythonic*
17 all-local: $(GENERATED_BINDINGS_DEPS)
18 $(PYTHON) setup.py build --verbose
21 @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \
22 if [ "$(DESTDIR)" != "" ]; then \
23 opts="$$opts --root=$(DESTDIR)"; \
25 $(PYTHON) setup.py install $(PY_INSTALL_OPTS) $$opts;
28 rm -rf $(builddir)/build
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
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)"; \
48 opts="$$opts --root=$(TMP_INSTALL_DIR)"; \
50 $(PYTHON) setup.py build --build-base $(TMP_BUILD_DIR) install $$opts > /dev/null || true
52 if [ "$(DESTDIR)" != "" ]; then \
53 $(SED) -i "s|^|$(DESTDIR)/|g" $(TMP_INSTALLED_FILES); \
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)