mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found
@ 2018-03-09 18:27 Roland Hieber
  2018-03-10  0:26 ` Michael Olbrich
  0 siblings, 1 reply; 3+ messages in thread
From: Roland Hieber @ 2018-03-09 18:27 UTC (permalink / raw)
  To: ptxdist; +Cc: Roland Hieber

From: Roland Hieber <rohieb@rohieb.name>

Python 2 will probably (hopefully?) vanish in the near future. On
systems that have both Python 2 and Python 3 installed, prefer Python 3.

Make all calls to the detected python compatible to both python2 and
python3.

Signed-off-by: Roland Hieber <rohieb@rohieb.name>
---
 configure.ac         | 7 ++++---
 rules/pre/Rules.make | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index bee3afd0f..a61fa568f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -338,7 +338,7 @@ AC_ARG_WITH(python, AS_HELP_STRING([--with-python],[name of the Python executabl
 	AC_SUBST(PYTHON)
 	AC_MSG_NOTICE([Using Python executable $PYTHON])
     ],[
-	AC_PATH_PROGS(PYTHON, python2 python2.7 python2.6 python)
+	AC_PATH_PROGS(PYTHON, python3 python2 python2.7 python2.6 python)
 	AC_SUBST(PYTHON)
     ])
 
@@ -349,7 +349,8 @@ AC_MSG_CHECKING([Python version])
 PYTHON_VERSION=`$PYTHON --version 2>&1 | $SED -ne "1 s/Python \([[0-9\+\.]]\+\).*/\1/p"`
 case "$PYTHON_VERSION" in
 2.*) ;;
-*)   AC_MSG_ERROR([we need Python version 2.x but found $PYTHON_VERSION]) ;;
+3.*) ;;
+*)   AC_MSG_ERROR([we need Python version 2.x or 3.x but found $PYTHON_VERSION]) ;;
 esac
 AC_MSG_RESULT([$PYTHON_VERSION])
 
@@ -365,7 +366,7 @@ else
 fi
 
 AC_MSG_CHECKING(whether Python development files are present)
-PYTHON_MAKEFILE=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_makefile_filename()" 2> /dev/null`
+PYTHON_MAKEFILE=`$PYTHON -c "from __future__ import print_function; import distutils.sysconfig; print(distutils.sysconfig.get_makefile_filename())" 2> /dev/null`
 if test -e "$PYTHON_MAKEFILE"; then
 	AC_MSG_RESULT(yes)
 else
diff --git a/rules/pre/Rules.make b/rules/pre/Rules.make
index 37357aeca..19ce076fd 100644
--- a/rules/pre/Rules.make
+++ b/rules/pre/Rules.make
@@ -305,8 +305,9 @@ HOST_ENV_PROGS := \
 HOST_ENV_PKG_CONFIG	:= $(PTXDIST_HOST_ENV_PKG_CONFIG)
 
 HOST_ENV_PYTHONPATH	:= \
-	PYTHONPATH="$(shell python -c 'import distutils.sysconfig as sysconfig; \
-		print "%s" % sysconfig.get_python_lib(prefix="'"$(PTXDIST_SYSROOT_HOST)"'")')"
+	PYTHONPATH="$(shell python -c 'from __future__ import print_function; \
+		import distutils.sysconfig as sysconfig; \
+		print("%s" % sysconfig.get_python_lib(prefix="'"$(PTXDIST_SYSROOT_HOST)"'"))')"
 
 HOST_ENV	:= \
 	$(HOST_ENV_AC) \
-- 
2.16.1


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

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

* Re: [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found
  2018-03-09 18:27 [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found Roland Hieber
@ 2018-03-10  0:26 ` Michael Olbrich
  2018-03-11 10:37   ` Roland Hieber
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Olbrich @ 2018-03-10  0:26 UTC (permalink / raw)
  To: ptxdist

On Fri, Mar 09, 2018 at 07:27:47PM +0100, Roland Hieber wrote:
> From: Roland Hieber <rohieb@rohieb.name>
> 
> Python 2 will probably (hopefully?) vanish in the near future. On
> systems that have both Python 2 and Python 3 installed, prefer Python 3.
> 
> Make all calls to the detected python compatible to both python2 and
> python3.

No. We introduced this ensure that the 'python' we get is Python 2. Before
we can change this we need to make sure that all users actually work
correctly with Python 3. And then we should switch entirely to Python 3.

Michael

> Signed-off-by: Roland Hieber <rohieb@rohieb.name>
> ---
>  configure.ac         | 7 ++++---
>  rules/pre/Rules.make | 5 +++--
>  2 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index bee3afd0f..a61fa568f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -338,7 +338,7 @@ AC_ARG_WITH(python, AS_HELP_STRING([--with-python],[name of the Python executabl
>  	AC_SUBST(PYTHON)
>  	AC_MSG_NOTICE([Using Python executable $PYTHON])
>      ],[
> -	AC_PATH_PROGS(PYTHON, python2 python2.7 python2.6 python)
> +	AC_PATH_PROGS(PYTHON, python3 python2 python2.7 python2.6 python)
>  	AC_SUBST(PYTHON)
>      ])
>  
> @@ -349,7 +349,8 @@ AC_MSG_CHECKING([Python version])
>  PYTHON_VERSION=`$PYTHON --version 2>&1 | $SED -ne "1 s/Python \([[0-9\+\.]]\+\).*/\1/p"`
>  case "$PYTHON_VERSION" in
>  2.*) ;;
> -*)   AC_MSG_ERROR([we need Python version 2.x but found $PYTHON_VERSION]) ;;
> +3.*) ;;
> +*)   AC_MSG_ERROR([we need Python version 2.x or 3.x but found $PYTHON_VERSION]) ;;
>  esac
>  AC_MSG_RESULT([$PYTHON_VERSION])
>  
> @@ -365,7 +366,7 @@ else
>  fi
>  
>  AC_MSG_CHECKING(whether Python development files are present)
> -PYTHON_MAKEFILE=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_makefile_filename()" 2> /dev/null`
> +PYTHON_MAKEFILE=`$PYTHON -c "from __future__ import print_function; import distutils.sysconfig; print(distutils.sysconfig.get_makefile_filename())" 2> /dev/null`
>  if test -e "$PYTHON_MAKEFILE"; then
>  	AC_MSG_RESULT(yes)
>  else
> diff --git a/rules/pre/Rules.make b/rules/pre/Rules.make
> index 37357aeca..19ce076fd 100644
> --- a/rules/pre/Rules.make
> +++ b/rules/pre/Rules.make
> @@ -305,8 +305,9 @@ HOST_ENV_PROGS := \
>  HOST_ENV_PKG_CONFIG	:= $(PTXDIST_HOST_ENV_PKG_CONFIG)
>  
>  HOST_ENV_PYTHONPATH	:= \
> -	PYTHONPATH="$(shell python -c 'import distutils.sysconfig as sysconfig; \
> -		print "%s" % sysconfig.get_python_lib(prefix="'"$(PTXDIST_SYSROOT_HOST)"'")')"
> +	PYTHONPATH="$(shell python -c 'from __future__ import print_function; \
> +		import distutils.sysconfig as sysconfig; \
> +		print("%s" % sysconfig.get_python_lib(prefix="'"$(PTXDIST_SYSROOT_HOST)"'"))')"
>  
>  HOST_ENV	:= \
>  	$(HOST_ENV_AC) \
> -- 
> 2.16.1
> 
> 
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

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

* Re: [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found
  2018-03-10  0:26 ` Michael Olbrich
@ 2018-03-11 10:37   ` Roland Hieber
  0 siblings, 0 replies; 3+ messages in thread
From: Roland Hieber @ 2018-03-11 10:37 UTC (permalink / raw)
  To: ptxdist

On Sat, Mar 10, 2018 at 01:26:43AM +0100, Michael Olbrich wrote:
> On Fri, Mar 09, 2018 at 07:27:47PM +0100, Roland Hieber wrote:
> > From: Roland Hieber <rohieb@rohieb.name>
> > 
> > Python 2 will probably (hopefully?) vanish in the near future. On
> > systems that have both Python 2 and Python 3 installed, prefer Python 3.
> > 
> > Make all calls to the detected python compatible to both python2 and
> > python3.
> 
> No. We introduced this ensure that the 'python' we get is Python 2. Before
> we can change this we need to make sure that all users actually work
> correctly with Python 3. And then we should switch entirely to Python 3.

OK. But how do we ensure this? Are there still distributions out there
which don't ship Python 3 at all?

 - Roland

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

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

end of thread, other threads:[~2018-03-11 10:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 18:27 [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found Roland Hieber
2018-03-10  0:26 ` Michael Olbrich
2018-03-11 10:37   ` Roland Hieber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox