All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] libselinux, libsemanage: make PYPREFIX computation more robust
@ 2017-02-19 21:53 Nicolas Iooss
  2017-02-21 18:56 ` James Carter
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Iooss @ 2017-02-19 21:53 UTC (permalink / raw)
  To: selinux

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).

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 .travis.yml              | 3 ++-
 libselinux/src/Makefile  | 2 +-
 libsemanage/src/Makefile | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6dce35165bd3..7d7424459344 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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]"
diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 5640a57d2768..a277b8715819 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -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
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index 92c829be234d..77f6efc86d2d 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -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
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] libselinux, libsemanage: make PYPREFIX computation more robust
  2017-02-19 21:53 [PATCH 1/1] libselinux, libsemanage: make PYPREFIX computation more robust Nicolas Iooss
@ 2017-02-21 18:56 ` James Carter
  0 siblings, 0 replies; 2+ messages in thread
From: James Carter @ 2017-02-21 18:56 UTC (permalink / raw)
  To: Nicolas Iooss, selinux

On 02/19/2017 04:53 PM, Nicolas Iooss wrote:
> 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).
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Applied.

Thanks,
Jim

> ---
>  .travis.yml              | 3 ++-
>  libselinux/src/Makefile  | 2 +-
>  libsemanage/src/Makefile | 2 +-
>  3 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/.travis.yml b/.travis.yml
> index 6dce35165bd3..7d7424459344 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -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]"
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 5640a57d2768..a277b8715819 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -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
> diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
> index 92c829be234d..77f6efc86d2d 100644
> --- a/libsemanage/src/Makefile
> +++ b/libsemanage/src/Makefile
> @@ -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
>


-- 
James Carter <jwcart2@tycho.nsa.gov>
National Security Agency

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-21 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-19 21:53 [PATCH 1/1] libselinux, libsemanage: make PYPREFIX computation more robust Nicolas Iooss
2017-02-21 18:56 ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.