Commit 02b30d3a authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

python/Makefile: Don't assume purelib is under /usr/{,local}



This is done in order to make sure the test_make_uninstall() test
can work properly under ubuntu which uses our pkgdep setup for
PEP668. Without this change, the uninstall target for python/*
is not working properly as it cannot find the site-packages
directory under specified destination.

Change-Id: I1c9d847e051499c5778ad22cdc6b74833d3c90dd
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24969


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 66bb5d46
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -14,9 +14,30 @@ endif

pylibdir := $(abspath $(shell python3 -c "import sysconfig; print(sysconfig.get_paths()['purelib'])"))
ifneq ($(CONFIG_PREFIX),)
pylibdir := $(pylibdir:/usr%=%)
pylibdir := $(pylibdir:/local%=%)
pylibdir := $(CONFIG_PREFIX)$(pylibdir)
# Consider different scenarios where purelib can be located:
#
# - /usr/lib/python*/site-packages
# - /usr/local/lib/python*/site-packages
# - /foo/bar/lib/python*/site-packages
#
# The latter here can be a result of using interpreter from within a venv
# located at custom location - see how we handle PEP668 under ubuntu in
# pkgdep/ubuntu.sh for instance.
#
# So the common part here is:
#   *lib/python*/site-packages
#
# So we cut the path to get the prefix (whatever it may be) and then we nuke
# it from the main path. So the corner case would look like so:
#
# pylibdir := /foo/bar/lib/python*/site-packages
# pylibprefix := /foo/bar
# pylibdir := $(CONFIG_PREFIX)/lib/python*/site-packages
#
# FIXME: I couldn't get patsubst to do the heavy lifting here, hence fallback
# to shell.
pylibprefix := $(shell a=$(pylibdir); echo $${a%/lib*})
pylibdir := $(CONFIG_PREFIX)$(pylibdir:$(pylibprefix)%=%)
endif

all: