From: Roland Hieber <r.hieber@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: Roland Hieber <rohieb@rohieb.name>
Subject: [ptxdist] [PATCH] configure.ac: prefer Python 3 if it is found
Date: Fri, 9 Mar 2018 19:27:47 +0100 [thread overview]
Message-ID: <20180309182747.3265-1-r.hieber@pengutronix.de> (raw)
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
next reply other threads:[~2018-03-09 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 18:27 Roland Hieber [this message]
2018-03-10 0:26 ` Michael Olbrich
2018-03-11 10:37 ` Roland Hieber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180309182747.3265-1-r.hieber@pengutronix.de \
--to=r.hieber@pengutronix.de \
--cc=ptxdist@pengutronix.de \
--cc=rohieb@rohieb.name \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox