mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
make: improve check for externally managed Python
Move PYTHON_EXTERNALLY_MANAGED and PIP_BREAK_SYSTEM_PACKAGES into Makefile.install to avoid code duplication. In addition, add PIPFLAGS variable to enable specifying pip options during installation. This is particularly useful for packaging, where it is common for `pip install` to run in an environment with pre-installed dependencies and without internet access. In such environment, we need to specify the following options: --no-build-isolation --no-index --no-deps Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
fdf546dbd5
commit
4f15fe8c59
@ -29,6 +29,29 @@ LIBDIR ?= $(PREFIX)/lib
|
|||||||
export PREFIX BINDIR SBINDIR MANDIR RUNDIR
|
export PREFIX BINDIR SBINDIR MANDIR RUNDIR
|
||||||
export LIBDIR INCLUDEDIR LIBEXECDIR PLUGINDIR
|
export LIBDIR INCLUDEDIR LIBEXECDIR PLUGINDIR
|
||||||
|
|
||||||
|
# Detect externally managed Python environment (PEP 668).
|
||||||
|
PYTHON_EXTERNALLY_MANAGED := $(shell $(PYTHON) -c 'import os, sysconfig; print(int(os.path.isfile(os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED"))))')
|
||||||
|
PIP_BREAK_SYSTEM_PACKAGES ?= 0
|
||||||
|
|
||||||
|
# If Python environment is externally managed and PIP_BREAK_SYSTEM_PACKAGES is not set, skip pip install.
|
||||||
|
SKIP_PIP_INSTALL := 0
|
||||||
|
ifeq ($(PYTHON_EXTERNALLY_MANAGED),1)
|
||||||
|
ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
|
||||||
|
|
||||||
|
SKIP_PIP_INSTALL := 1
|
||||||
|
$(info Warn: Externally managed python environment)
|
||||||
|
$(info Consider using PIP_BREAK_SYSTEM_PACKAGES=1)
|
||||||
|
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Default flags for pip install:
|
||||||
|
# --upgrade: Upgrade crit/pycriu packages
|
||||||
|
# --ignore-installed: Ignore existing packages and reinstall them
|
||||||
|
PIPFLAGS ?= --upgrade --ignore-installed
|
||||||
|
|
||||||
|
export SKIP_PIP_INSTALL PIPFLAGS
|
||||||
|
|
||||||
install-man:
|
install-man:
|
||||||
$(Q) $(MAKE) -C Documentation install
|
$(Q) $(MAKE) -C Documentation install
|
||||||
.PHONY: install-man
|
.PHONY: install-man
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
PYTHON_EXTERNALLY_MANAGED := $(shell $(PYTHON) -c 'import os, sysconfig; print(int(os.path.isfile(os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED"))))')
|
|
||||||
PIP_BREAK_SYSTEM_PACKAGES := 0
|
|
||||||
|
|
||||||
VERSION_FILE := $(if $(obj),$(addprefix $(obj)/,crit/version.py),crit/version.py)
|
VERSION_FILE := $(if $(obj),$(addprefix $(obj)/,crit/version.py),crit/version.py)
|
||||||
|
|
||||||
all-y += ${VERSION_FILE}
|
all-y += ${VERSION_FILE}
|
||||||
@ -10,31 +7,19 @@ ${VERSION_FILE}:
|
|||||||
$(Q) echo "__version__ = '${CRIU_VERSION}'" > $@
|
$(Q) echo "__version__ = '${CRIU_VERSION}'" > $@
|
||||||
|
|
||||||
install: ${VERSION_FILE}
|
install: ${VERSION_FILE}
|
||||||
ifeq ($(PYTHON_EXTERNALLY_MANAGED),1)
|
ifeq ($(SKIP_PIP_INSTALL),0)
|
||||||
ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
|
|
||||||
$(E) " SKIP INSTALL crit: Externally managed python environment (See PEP 668 for more information)"
|
|
||||||
$(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make install"
|
|
||||||
else
|
|
||||||
$(E) " INSTALL " crit
|
$(E) " INSTALL " crit
|
||||||
$(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./crit
|
$(Q) $(PYTHON) -m pip install $(PIPFLAGS) --prefix=$(DESTDIR)$(PREFIX) ./crit
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
$(E) " INSTALL " crit
|
$(E) " SKIP INSTALL crit"
|
||||||
$(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./crit
|
|
||||||
endif
|
endif
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
ifeq ($(PYTHON_EXTERNALLY_MANAGED),1)
|
ifeq ($(SKIP_PIP_INSTALL),0)
|
||||||
ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
|
|
||||||
$(E) " SKIP UNINSTALL crit: Externally managed python environment (See PEP 668 for more information)"
|
|
||||||
$(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make uninstall"
|
|
||||||
else
|
|
||||||
$(E) " UNINSTALL" crit
|
$(E) " UNINSTALL" crit
|
||||||
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) crit
|
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) crit
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
$(E) " UNINSTALL" crit
|
$(E) " SKIP UNINSTALL crit"
|
||||||
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) crit
|
|
||||||
endif
|
endif
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
|
25
lib/Makefile
25
lib/Makefile
@ -4,9 +4,6 @@ UAPI_HEADERS := lib/c/criu.h images/rpc.proto images/rpc.pb-c.h criu/include/ve
|
|||||||
|
|
||||||
all-y += lib-c lib-a lib-py
|
all-y += lib-c lib-a lib-py
|
||||||
|
|
||||||
PYTHON_EXTERNALLY_MANAGED := $(shell $(PYTHON) -c 'import os, sysconfig; print(int(os.path.isfile(os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED"))))')
|
|
||||||
PIP_BREAK_SYSTEM_PACKAGES := 0
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# C language bindings.
|
# C language bindings.
|
||||||
lib/c/Makefile: ;
|
lib/c/Makefile: ;
|
||||||
@ -57,17 +54,11 @@ install: lib-c lib-a lib-py lib/c/criu.pc.in
|
|||||||
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
|
$(Q) mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||||
$(Q) sed -e 's,@version@,$(CRIU_VERSION),' -e 's,@libdir@,$(LIBDIR),' -e 's,@includedir@,$(dir $(INCLUDEDIR)/criu/),' lib/c/criu.pc.in > lib/c/criu.pc
|
$(Q) sed -e 's,@version@,$(CRIU_VERSION),' -e 's,@libdir@,$(LIBDIR),' -e 's,@includedir@,$(dir $(INCLUDEDIR)/criu/),' lib/c/criu.pc.in > lib/c/criu.pc
|
||||||
$(Q) install -m 644 lib/c/criu.pc $(DESTDIR)$(LIBDIR)/pkgconfig
|
$(Q) install -m 644 lib/c/criu.pc $(DESTDIR)$(LIBDIR)/pkgconfig
|
||||||
ifeq ($(PYTHON_EXTERNALLY_MANAGED),1)
|
ifeq ($(SKIP_PIP_INSTALL),0)
|
||||||
ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
|
|
||||||
$(E) " SKIP INSTALL pycriu: Externally managed python environment (See PEP 668 for more information)"
|
|
||||||
$(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make install"
|
|
||||||
else
|
|
||||||
$(E) " INSTALL " pycriu
|
$(E) " INSTALL " pycriu
|
||||||
$(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./lib
|
$(Q) $(PYTHON) -m pip install $(PIPFLAGS) --prefix=$(DESTDIR)$(PREFIX) ./lib
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
$(E) " INSTALL " pycriu
|
$(E) " SKIP INSTALL pycriu"
|
||||||
$(Q) $(PYTHON) -m pip install --upgrade --ignore-installed --prefix=$(DESTDIR)$(PREFIX) ./lib
|
|
||||||
endif
|
endif
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
|
|
||||||
@ -80,16 +71,10 @@ uninstall:
|
|||||||
$(Q) $(RM) $(addprefix $(DESTDIR)$(INCLUDEDIR)/criu/,$(notdir $(UAPI_HEADERS)))
|
$(Q) $(RM) $(addprefix $(DESTDIR)$(INCLUDEDIR)/criu/,$(notdir $(UAPI_HEADERS)))
|
||||||
$(E) " UNINSTALL" pkgconfig/criu.pc
|
$(E) " UNINSTALL" pkgconfig/criu.pc
|
||||||
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/pkgconfig/,criu.pc)
|
$(Q) $(RM) $(addprefix $(DESTDIR)$(LIBDIR)/pkgconfig/,criu.pc)
|
||||||
ifeq ($(PYTHON_EXTERNALLY_MANAGED),1)
|
ifeq ($(SKIP_PIP_INSTALL),0)
|
||||||
ifeq ($(PIP_BREAK_SYSTEM_PACKAGES),0)
|
|
||||||
$(E) " SKIP UNINSTALL pycriu: Externally managed python environment (See PEP 668 for more information)"
|
|
||||||
$(E) " Consider using PIP_BREAK_SYSTEM_PACKAGES=1 make uninstall"
|
|
||||||
else
|
|
||||||
$(E) " UNINSTALL" pycriu
|
$(E) " UNINSTALL" pycriu
|
||||||
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) pycriu
|
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) pycriu
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
$(E) " UNINSTALL" pycriu
|
$(E) " SKIP UNINSTALL pycriu"
|
||||||
$(Q) $(PYTHON) ./scripts/uninstall_module.py --prefix=$(DESTDIR)$(PREFIX) pycriu
|
|
||||||
endif
|
endif
|
||||||
.PHONY: uninstall
|
.PHONY: uninstall
|
||||||
|
Loading…
x
Reference in New Issue
Block a user