libselinux, libsemanage: make PYPREFIX computation more robust
PATCH 1/1 libselinux, libsemanage: make PYPREFIX computation more robust
On systems where $PYTHON is python3.5 (instead of python2 or python3), pkg-config fails to find the Python package because it is named with a dash (e.g. python-3.5).
Moreover the build system may have been using the pkg-config configuration files for the wrong Python version when several Python with the same major version number are installed (e.g. using python-3.5 on a system with both python-3.4 and python-3.5 and where /usr/lib/pkgconfig/python3.pc is a symlink to python-3.5.pc).
In order to fix these two issues, compute $PYPREFIX from $PYTHON by using the full major.minor version.
Moreover update Travis-Ci configuration to grab the relevant configuration files for pkg-config from /opt/python (for example /opt/python/3.5.2/lib/pkgconfig/python-3.5.pc) instead of using system-provided files (/usr/lib/x86_64-linux-gnu/pkgconfig/python3.pc and /usr/lib/x86_64-linux-gnu/pkgconfig/python2.pc).
--- .travis.yml | 3 ++- libselinux/src/Makefile | 2 +- libsemanage/src/Makefile | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-)
.travis.yml +2 -1
@@ -76,7 +76,8 @@ before_script: # Configure the variables for Python parts - export VIRTUAL_ENV="$HOME/virtualenv/$PYVER" - export PYTHON="$VIRTUAL_ENV/bin/python" - - export PYPREFIX="$($PYTHON -c 'import sys;print("python%d" % sys.version_info[0])')" + # Use the header files in /opt/python/... for Python because the virtualenvs do not provide Python.h + - export PKG_CONFIG_PATH="/opt/python/$($PYTHON -c 'import sys;print("%d.%d.%d" % sys.version_info[:3])')/lib/pkgconfig" # PyPy does not provide a config file for pkg-config nor a pypy-c.so - if echo "$PYVER" | grep -q pypy ; then export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include PYLIBS= ; fi # Python virtualenvs do not support "import site; print(site.getsitepackages()[0]"
libselinux/src/Makefile +1 -1
@@ -2,7 +2,7 @@ # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": PYTHON ?= python -PYPREFIX ?= $(notdir $(PYTHON)) +PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY)) PKG_CONFIG ?= pkg-config
libsemanage/src/Makefile +1 -1
@@ -2,7 +2,7 @@ # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": PYTHON ?= python -PYPREFIX ?= $(notdir $(PYTHON)) +PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY)) PKG_CONFIG ?= pkg-config
Signature · 1 line
2.11.1
James Carter
AppliedQuoted 13 lines · Nicolas Iooss
On systems where $PYTHON is python3.5 (instead of python2 or python3), pkg-config fails to find the Python package because it is named with a dash (e.g. python-3.5).
Moreover the build system may have been using the pkg-config configuration files for the wrong Python version when several Python with the same major version number are installed (e.g. using python-3.5 on a system with both python-3.4 and python-3.5 and where
/usr/lib/pkgconfig/python3.pcis a symlink to python-3.5.pc).In order to fix these two issues, compute $PYPREFIX from $PYTHON by using the full major.minor version.
Quoted 7 lines
Moreover update Travis-Ci configuration to grab the relevant configuration files for pkg-config from
/opt/python(for example/opt/python/3.5.2/lib/pkgconfig/python-3.5.pc) instead of using system-provided files (/usr/lib/x86_64-linux-gnu/pkgconfig/python3.pcand/usr/lib/x86_64-linux-gnu/pkgconfig/python2.pc).Signed-off-by Nicolas Iooss <[email protected]>
Applied.
Thanks,
Jim
Quoted 47 lines
--- .travis.yml | 3 ++- libselinux/src/Makefile | 2 +- libsemanage/src/Makefile | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-).travis.yml +2
-1@@ -76,7 +76,8 @@ before_script: # Configure the variables for Python parts - export VIRTUAL_ENV="$HOME/virtualenv/$PYVER" - export PYTHON="$VIRTUAL_ENV/bin/python" - - export PYPREFIX="$($PYTHON -c 'import sys;print("python%d" % sys.version_info[0])')" + # Use the header files in /opt/python/... for Python because the virtualenvs do not provide Python.h + - export PKG_CONFIG_PATH="/opt/python/$($PYTHON -c 'import sys;print("%d.%d.%d" % sys.version_info[:3])')/lib/pkgconfig" # PyPy does not provide a config file for pkg-config nor a pypy-c.so - if echo "$PYVER" | grep -q pypy ; then export PYINC=-I$($PYTHON -c 'import sys;print(sys.prefix)')/include PYLIBS= ; fi # Python virtualenvs do not support "import site; print(site.getsitepackages()[0]"libselinux/src/Makefile +1
-1@@ -2,7 +2,7 @@ # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": PYTHON ?= python -PYPREFIX ?= $(notdir $(PYTHON)) +PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY)) PKG_CONFIG ?= pkg-configlibsemanage/src/Makefile +1
-1@@ -2,7 +2,7 @@ # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": PYTHON ?= python -PYPREFIX ?= $(notdir $(PYTHON)) +PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY)) PKG_CONFIG ?= pkg-config
Signature · 2 lines
James Carter <[email protected]> National Security Agency