Switch to Python 3 by default
Default instalation seems to be inconsistent a little when PYTHON variable is not used during build. Python 2 versions of selinux and semanage modules are built and installed, but /usr/sbin/semanage and other tools are already changed to use /usr/bin/python3.
I'd like to propose to change to Python 3 by default and leave it on a maintainer to use PYTHON=/usr/bin/python2 when they doesn't have Python 3 available. They would also need to change shebangs of some tools, but this is the same situation as used to be when default was Python 2 and maintainers needed to change shebangs to /usr/bin/python3.
Do you have any objections?
PATCH 1/3 Always use /usr/bin/python3 in Python scripts
--- dbus/selinux_server.py | 2 +- libsemanage/utils/semanage_migrate_store | 2 +- mcstrans/share/util/mlscolor-test | 2 +- mcstrans/share/util/mlstrans-test | 2 +- python/semanage/semanage | 2 +- sandbox/start | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
dbus/selinux_server.py +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import dbus import dbus.service
libsemanage/utils/semanage_migrate_store +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E from __future__ import print_function
mcstrans/share/util/mlscolor-test +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinux
mcstrans/share/util/mlstrans-test +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinux
python/semanage/semanage +1 -1
@@ -1,4 +1,4 @@ -#! /usr/bin/python3 -Es +#!/usr/bin/python3 -Es # Copyright (C) 2012-2013 Red Hat # AUTHOR: Miroslav Grepl <[email protected]> # AUTHOR: David Quigley <[email protected]>
sandbox/start +1 -1
@@ -1,4 +1,4 @@ -#! /usr/bin/python -Es +#!/usr/bin/python3 -Es try: from subprocess import getstatusoutput except ImportError:
Signature · 1 line
2.20.1
Re: [PATCH 1/3] Always use /usr/bin/python3 in Python scripts
Quoted 2 lines · Petr Lautrbach
Signed-off-by Petr Lautrbach <[email protected]>
For the 3 patches:
Quoted 72 lines
--- dbus/selinux_server.py | 2 +- libsemanage/utils/semanage_migrate_store | 2 +- mcstrans/share/util/mlscolor-test | 2 +- mcstrans/share/util/mlstrans-test | 2 +- python/semanage/semanage | 2 +- sandbox/start | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)dbus/selinux_server.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import dbus import dbus.servicelibsemanage/utils/semanage_migrate_store +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E from __future__ import print_functionmcstrans/share/util/mlscolor-test +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinuxmcstrans/share/util/mlstrans-test +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinuxpython/semanage/semanage +1
-1@@ -1,4 +1,4 @@ -#! /usr/bin/python3 -Es +#!/usr/bin/python3 -Es # Copyright (C) 2012-2013 Red Hat # AUTHOR: Miroslav Grepl <[email protected]> # AUTHOR: David Quigley <[email protected]>sandbox/start +1
-2@@ -1,4 +1,4 @@ -#! /usr/bin/python -Es +#!/usr/bin/python3 -Es try: from subprocess import getstatusoutput except ImportError: --2.20.1
Re: [PATCH 1/3] Always use /usr/bin/python3 in Python scripts
Quoted 6 lines · Nicolas Iooss
Quoted 2 lines · Petr Lautrbach
Signed-off-by Petr Lautrbach <[email protected]>For the 3 patches:
Acked-by Nicolas Iooss <[email protected]>
Merged.
Quoted 72 lines
Quoted 72 lines
--- dbus/selinux_server.py | 2 +- libsemanage/utils/semanage_migrate_store | 2 +- mcstrans/share/util/mlscolor-test | 2 +- mcstrans/share/util/mlstrans-test | 2 +- python/semanage/semanage | 2 +- sandbox/start | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)dbus/selinux_server.py +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import dbus import dbus.servicelibsemanage/utils/semanage_migrate_store +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E from __future__ import print_functionmcstrans/share/util/mlscolor-test +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinuxmcstrans/share/util/mlstrans-test +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/python -E +#!/usr/bin/python3 -E import sys import selinuxpython/semanage/semanage +1
-1@@ -1,4 +1,4 @@ -#! /usr/bin/python3 -Es +#!/usr/bin/python3 -Es # Copyright (C) 2012-2013 Red Hat # AUTHOR: Miroslav Grepl <[email protected]> # AUTHOR: David Quigley <[email protected]>sandbox/start +1
-2@@ -1,4 +1,4 @@ -#! /usr/bin/python -Es +#!/usr/bin/python3 -Es try: from subprocess import getstatusoutput except ImportError: --2.20.1
PATCH 2/3 Switch to python3 by default
In reply to Petr Lautrbach- Python 2.7 is planned to be the last of the 2.x releases
- It's generally advised to use Python 3
- Majority of python/ scripts are already switched python3
- Users with python 2 only can still use:
$ make PYTHON=/usr/bin/python ....
--- libselinux/src/Makefile | 2 +- libsemanage/src/Makefile | 2 +- python/audit2allow/Makefile | 2 +- python/semanage/Makefile | 2 +- python/sepolgen/src/sepolgen/Makefile | 2 +- python/sepolgen/tests/Makefile | 2 +- python/sepolicy/Makefile | 2 +- sandbox/Makefile | 2 +- scripts/env_use_destdir | 2 +- scripts/run-scan-build | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-)
libselinux/src/Makefile +1 -1
@@ -1,7 +1,7 @@ # Support building the Python bindings multiple times, against various Python # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": -PYTHON ?= python +PYTHON ?= python3 PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY))
libsemanage/src/Makefile +1 -1
@@ -1,7 +1,7 @@ # Support building the Python bindings multiple times, against various Python # runtimes (e.g. Python 2 vs Python 3) by optionally prefixing the build # targets with "PYPREFIX": -PYTHON ?= python +PYTHON ?= python3 PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY))
python/audit2allow/Makefile +1 -1
@@ -1,4 +1,4 @@ -PYTHON ?= python +PYTHON ?= python3 SECILC ?= secilc # Installation directories.
python/semanage/Makefile +1 -1
@@ -1,4 +1,4 @@ -PYTHON ?= python +PYTHON ?= python3 # Installation directories. LINGUAS ?= ru
python/sepolgen/src/sepolgen/Makefile +1 -1
@@ -1,5 +1,5 @@ PREFIX ?= /usr -PYTHON ?= python +PYTHON ?= python3 PYTHONLIBDIR ?= $(shell $(PYTHON) -c "from distutils.sysconfig import *; print(get_python_lib(prefix='$(PREFIX)'))") PACKAGEDIR ?= /$(PYTHONLIBDIR)/sepolgen
python/sepolgen/tests/Makefile +1 -1
@@ -1,4 +1,4 @@ -PYTHON ?= python +PYTHON ?= python3 clean: rm -f *~ *.pyc
python/sepolicy/Makefile +1 -1
@@ -1,4 +1,4 @@ -PYTHON ?= python +PYTHON ?= python3 # Installation directories. LINGUAS ?= ru
sandbox/Makefile +1 -1
@@ -1,4 +1,4 @@ -PYTHON ?= python +PYTHON ?= python3 # Installation directories. LINGUAS ?= ru
scripts/env_use_destdir +1 -1
@@ -25,7 +25,7 @@ export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" # shellcheck disable=SC2155 -export PYTHONPATH="$DESTDIR$(${PYTHON:-python} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" +export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" # shellcheck disable=SC2155 export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')"
scripts/run-scan-build +1 -1
@@ -17,7 +17,7 @@ fi # Make sure to use the newly-installed libraries when running tests export LD_LIBRARY_PATH="$DESTDIR/usr/lib:$DESTDIR/lib" export PATH="$DESTDIR/usr/sbin:$DESTDIR/usr/bin:$DESTDIR/sbin:$DESTDIR/bin:$PATH" -export PYTHONPATH="$DESTDIR$(${PYTHON:-python} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" +export PYTHONPATH="$DESTDIR$(${PYTHON:-python3} -c "from distutils.sysconfig import *;print(get_python_lib(prefix='/usr'))")" export RUBYLIB="$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorlibdir"]'):$DESTDIR/$(${RUBY:-ruby} -e 'puts RbConfig::CONFIG["vendorarchdir"]')" # Build and analyze
Signature · 1 line
2.20.1
PATCH 3/3 README: Update Fedora python 3 dependencies
In reply to Petr Lautrbach--- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
README +1 -1
@@ -3,7 +3,7 @@ Subscribe by sending "subscribe selinux" in the body of an email to [email protected]. Build dependencies on Fedora: -yum install audit-libs-devel bison bzip2-devel dbus-devel dbus-glib-devel flex flex-devel flex-static glib2-devel libcap-devel libcap-ng-devel pam-devel pcre-devel python-devel setools-devel swig xmlto redhat-rpm-config +yum install audit-libs-devel bison bzip2-devel dbus-devel dbus-glib-devel flex flex-devel flex-static glib2-devel libcap-devel libcap-ng-devel pam-devel pcre-devel python3-devel python3-setools swig xmlto redhat-rpm-config To build and install everything under a private directory, run: make DESTDIR=~/obj install install-pywrap
Signature · 1 line
2.20.1
Quoted 7 lines · Petr Lautrbach
Default instalation seems to be inconsistent a little when PYTHON variable is not used during build. Python 2 versions of selinux and semanage modules are built and installed, but
/usr/sbin/semanageand other tools are already changed to use/usr/bin/python3.
Quoted 7 lines
I'd like to propose to change to Python 3 by default and leave it on a maintainer to use PYTHON=/usr/bin/python2 when they doesn't have Python 3 available. They would also need to change shebangs of some tools, but this is the same situation as used to be when default was Python 2 and maintainers needed to change shebangs to
/usr/bin/python3.Do you have any objections?
Sounds good to me.
Quoted 15 lines · Stephen Smalley
Quoted 13 lines · Petr Lautrbach
Default instalation seems to be inconsistent a little when PYTHON variable is not used during build. Python 2 versions of selinux and semanage modules are built and installed, but
/usr/sbin/semanageand other tools are already changed to use/usr/bin/python3.I'd like to propose to change to Python 3 by default and leave it on a maintainer to use PYTHON=/usr/bin/python2 when they doesn't have Python 3 available. They would also need to change shebangs of some tools, but this is the same situation as used to be when default was Python 2 and maintainers needed to change shebangs to
/usr/bin/python3.
Quoted 3 lines
Quoted 1 line
Do you have any objections?
Sounds good to me.
I agree.
Cheers,
Nicolas