Skip to contentSkip to conversation

dependencies.sh: Check for a host python version >= 2.7

PATCH New aduskett at gmail.com 5 participants 9 messages Dec 16, 2018 – Feb 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

From: Adam Duskett <[email protected]>

Older distributions such as CentOS6 come with python2.6, which causes build failures in packages such as host-libglib2 because they require python2.7 and above.

host-libglib2 will produce the error message:
/bin/sh: python2.7: command not found

Python2.7 is a hard-coded value in configure.ac. If one changes the value to just "python," the following stack trace is produced:

Traceback (most recent call last):
File "./gdbus-2.0/codegen/gdbus-codegen.in", line 55, in <module>
self.outfile.write(LICENSE_STR.format(config.VERSION))
ValueError : sys.exit(codegen_main.codegen_main())
zero length field name in format

Instead of supporting an ancient version of Python that had its support ended in October os 2013, it would be more pragmatic only to support Python2.7 and above.

Luckily; CentOS6 has the centos-release-scl repository, which allows users to install python2.7, and Debian 8 comes with Python2.7 already, making this patch relatively low impact.

---
Changes v1 -> v2:
- Updated version requirement in prerequisite.txt

Changes v2 -> v3:
- Added more precise language to the commit message.
- Added an example stack trace and error caused by python2.6 and host-libglib2.

 support/dependencies/dependencies.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
support/dependencies/dependencies.sh +8 -0
index 58c34d880f..d0b6bdc23a 100755
@@ -181,6 +181,14 @@ if test "${missing_progs}" = "yes" ; then
 	exit 1
 fi
 
+# Check that the python version is at least 2.7
+PYTHON_VERSION=$(python -V 2>&1 |awk '{print $2}')
+if [ $(echo $PYTHON_VERSION |sed -e 's/\.//g') -lt 2700 ]; then
+	echo
+	echo "You have python '$PYTHON_VERSION' installed.  Python >= 2.7 is required"
+	exit 1;
+fi
+
 if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
 	if ! which locale > /dev/null ; then
 		echo
Signature · 1 line
2.19.2
#1 lore raw

PATCH v3 2/2 prerequisite.txt: Bump python dependency to 2.7

From: Adam Duskett <[email protected]>

---
Changes v1 -> v2:
- Added this patch to the patch series.

Changes v2 -> v3:
- None.

 docs/manual/prerequisite.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
docs/manual/prerequisite.txt +1 -1
index 66e1b88f16..dcd3fd255e 100644
@@ -32,7 +32,7 @@ between distributions).
 ** +perl+ (version 5.8.7 or any later)
 ** +tar+
 ** +cpio+
-** +python+ (version 2.6 or any later)
+** +python+ (version 2.7 or any later)
 ** +unzip+
 ** +rsync+
 ** +file+ (must be in +/usr/bin/file+)
Signature · 1 line
2.19.2
#3 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

In reply to aduskett at gmail.com

Hello Adam,

Quoted 9 lines · aduskett at gmail.com

From: Adam Duskett <[email protected]>

Older distributions such as CentOS6 come with python2.6, which causes build failures in packages such as host-libglib2 because they require python2.7 and above.

host-libglib2 will produce the error message:
/bin/sh: python2.7: command not found

Quoted 9 lines

Python2.7 is a hard-coded value in configure.ac. If one changes the value to just "python," the following stack trace is produced:

Traceback (most recent call last):
File "./gdbus-2.0/codegen/gdbus-codegen.in", line 55, in <module>
self.outfile.write(LICENSE_STR.format(config.VERSION))
ValueError : sys.exit(codegen_main.codegen_main())
zero length field name in format

Or avoid the python call (used only for re-generation of already delivered files) by patching libglib2 (fixes the libglib2 build in case of python2.7 without proper xml.parsers.expat installation):

gio/Makefile.am +1 -1
index 3039e00..b7ba228 100644
@@ -101,7 +101,7 @@ GDBUS_PYTHON_DEPS = 					\
 	$(builddir)/gdbus-2.0/codegen/config.py 	\
 	$(srcdir)/gdbus-2.0/codegen/utils.py
 
-gdbus-daemon-generated.h gdbus-daemon-generated.c: $(srcdir)/dbus-daemon.xml $(GDBUS_PYTHON_DEPS)
+gdbus-daemon-generated.h gdbus-daemon-generated.c: $(srcdir)/dbus-daemon.xml
 	$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
 		UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
 		$(PYTHON) $(srcdir)/gdbus-2.0/codegen/gdbus-codegen.in \

Regards,
Peter

Quoted 40 lines

Instead of supporting an ancient version of Python that had its support ended in October os 2013, it would be more pragmatic only to support Python2.7 and above.

Luckily; CentOS6 has the centos-release-scl repository, which allows users to install python2.7, and Debian 8 comes with Python2.7 already, making this patch relatively low impact.

---
Changes v1 -> v2:
- Updated version requirement in prerequisite.txt

Changes v2 -> v3:
- Added more precise language to the commit message.
- Added an example stack trace and error caused by python2.6 and host-libglib2.

 support/dependencies/dependencies.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
support/dependencies/dependencies.sh +8 -0
index 58c34d880f..d0b6bdc23a 100755
@@ -181,6 +181,14 @@ if test "${missing_progs}" = "yes" ; then
 	exit 1
 fi
 
+# Check that the python version is at least 2.7
+PYTHON_VERSION=$(python -V 2>&1 |awk '{print $2}')
+if [ $(echo $PYTHON_VERSION |sed -e 's/\.//g') -lt 2700 ]; then
+	echo
+	echo "You have python '$PYTHON_VERSION' installed.  Python >= 2.7 is required"
+	exit 1;
+fi
+
 if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
 	if ! which locale > /dev/null ; then
 		echo
author
#4 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

Hello Peter;

I would question as to why we would do anything to support such an old version of Python that was EOLed over 5 years ago. Heck, even 2.7 will be EOLed in 2020.

Looking around, the only distribution that has 2.6 that still has any kind of support is CentOS6, and even that is in maintenance mode.

2.7 is a safe bet in my opinion.

Adam

Quoted 87 lines · Peter Seiderer

Hello Adam,

Quoted 11 lines · aduskett at gmail.com

From: Adam Duskett <[email protected]>

Older distributions such as CentOS6 come with python2.6, which causes build failures in packages such as host-libglib2 because they require python2.7 and above.

host-libglib2 will produce the error message:
/bin/sh: python2.7: command not found

Quoted 9 lines

Python2.7 is a hard-coded value in configure.ac. If one changes the value to just "python," the following stack trace is produced:

Traceback (most recent call last):
File "./gdbus-2.0/codegen/gdbus-codegen.in", line 55, in <module>
self.outfile.write(LICENSE_STR.format(config.VERSION))
ValueError : sys.exit(codegen_main.codegen_main())
zero length field name in format

Or avoid the python call (used only for re-generation of already delivered files) by patching libglib2 (fixes the libglib2 build in case of python2.7 without proper xml.parsers.expat installation):

gio/Makefile.am +1 -1
index 3039e00..b7ba228 100644
@@ -101,7 +101,7 @@ GDBUS_PYTHON_DEPS =                    \
   $(builddir)/gdbus-2.0/codegen/config.py    \
   $(srcdir)/gdbus-2.0/codegen/utils.py
 
-gdbus-daemon-generated.h gdbus-daemon-generated.c: $(srcdir)/dbus-daemon.xml $(GDBUS_PYTHON_DEPS)
+gdbus-daemon-generated.h gdbus-daemon-generated.c: $(srcdir)/dbus-daemon.xml
   $(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
       UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
       $(PYTHON) $(srcdir)/gdbus-2.0/codegen/gdbus-codegen.in \

Regards,
Peter

Quoted 40 lines

Instead of supporting an ancient version of Python that had its support ended in October os 2013, it would be more pragmatic only to support Python2.7 and above.

Luckily; CentOS6 has the centos-release-scl repository, which allows users to install python2.7, and Debian 8 comes with Python2.7 already, making this patch relatively low impact.

---
Changes v1 -> v2:
- Updated version requirement in prerequisite.txt

Changes v2 -> v3:
- Added more precise language to the commit message.
- Added an example stack trace and error caused by python2.6 and host-libglib2.

support/dependencies/dependencies.sh | 8 ++++++++

1 file changed, 8 insertions(+)
support/dependencies/dependencies.sh +0 -0
index 58c34d880f..d0b6bdc23a 100755
@@ -181,6 +181,14 @@ if test "${missing_progs}" = "yes" ; then
   exit 1

fi

support/dependencies/dependencies.sh +8 -0
+# Check that the python version is at least 2.7
+PYTHON_VERSION=$(python -V 2>&1 |awk '{print $2}')
+if [ $(echo $PYTHON_VERSION |sed -e 's/\.//g') -lt 2700 ]; then
+    echo
+    echo "You have python '$PYTHON_VERSION' installed.  Python >= 2.7 is required"
+    exit 1;
+fi
+

if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then
if ! which locale > /dev/null ; then
echo

#5 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

Quoted 5 lines · On 17/12/2018 14:10, ratbert90 wrote:

Hello Peter;

I would question as to why we would do anything to support such an old version of Python that was EOLed over 5 years ago. Heck, even 2.7 will be EOLed in 2020.

Looking around, the only distribution that has 2.6 that still has any kind of support is CentOS6, and even that is in maintenance mode.

RHEL6 will be retired November 30, 2020. SLES11 also hase Python 2.6 and will
be retired 31 Mar 2022.

Quoted 1 line

2.7 is a safe bet in my opinion.

Indeed, because it can be installed both on RHEL6 and on SLES11.

However, IIUC, it is *not* possible to install python 2.7 as the *default*
python on these distros, because some scripts that are used in normal operation don't work with python 2.7. So, the test that you added to dependencies.sh is probably too strict, because it checks that python -V gives at least 2.7...

Regards,
Arnout

#6 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

Hello;

Quoted 15 lines · Arnout Vandecappelle
Quoted 7 lines · On 17/12/2018 14:10, ratbert90 wrote:

Hello Peter;

I would question as to why we would do anything to support such an old version of Python that was EOLed over 5 years ago. Heck, even 2.7 will be EOLed in 2020.

Looking around, the only distribution that has 2.6 that still has any kind of support is CentOS6, and even that is in maintenance mode.

RHEL6 will be retired November 30, 2020. SLES11 also hase Python 2.6 and will
be retired 31 Mar 2022.

Quoted 7 lines
Quoted 1 line

2.7 is a safe bet in my opinion.

Indeed, because it can be installed both on RHEL6 and on SLES11.

However, IIUC, it is *not* possible to install python 2.7 as the *default*
python on these distros, because some scripts that are used in normal operation don't work with python 2.7.

In the case of RHEL; one can run: source /opt/rh/python27/enable which will add the appropriate paths for Python2.7 to be the default.

As far as SLES11 goes, I don't know how many people use it, but it has to be microscopic at this point.

Quoted 2 lines

So, the test that you added to dependencies.sh is
probably too strict, because it checks that python -V gives at least 2.7...

If one runs source /opt/rh/python27/enable in CentOS6, then running python -V
will give 2.7.13.

Quoted 3 lines

Regards,
Arnout

Thanks!
Adam

#7 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

On 2018-12-18 11:13 -0500, Adam Duskett spake thusly:

Quoted 17 lines

Hello;

Quoted 14 lines · Arnout Vandecappelle
Quoted 7 lines · On 17/12/2018 14:10, ratbert90 wrote:

Hello Peter;

I would question as to why we would do anything to support such an old version of Python that was EOLed over 5 years ago. Heck, even 2.7 will be EOLed in 2020.

Looking around, the only distribution that has 2.6 that still has any kind of support is CentOS6, and even that is in maintenance mode.

RHEL6 will be retired November 30, 2020. SLES11 also hase Python 2.6 and will
be retired 31 Mar 2022.

RHEL5 gets extended support until end of 2020, while RHEL6 gets extended support until mid-2024.

You would be amazed how old stuff tend to stick around in entrerpise-y context. ;-]

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

2.7 is a safe bet in my opinion.

Indeed, because it can be installed both on RHEL6 and on SLES11.

However, IIUC, it is *not* possible to install python 2.7 as the *default*
python on these distros, because some scripts that are used in normal operation don't work with python 2.7.

In the case of RHEL; one can run: source /opt/rh/python27/enable which will add the appropriate paths for Python2.7 to be the default.

Quoted 8 lines

As far as SLES11 goes, I don't know how many people use it, but it has to be microscopic at this point.

Quoted 2 lines

So, the test that you added to dependencies.sh is
probably too strict, because it checks that python -V gives at least 2.7...

If one runs source /opt/rh/python27/enable in CentOS6, then running python -V
will give 2.7.13.

Since there are practical workarounds for affected users, I'm fine that we require pythhon-2.7 now.

Note that, if libglib2 does require a host pytrhon-2.7 and we are not willing to change our own requirements, then we can always add host-python to libglib2's dependencies. But, meh...

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#8 lore raw

PATCH v3 1/2 dependencies.sh: Check for a host python version >= 2.7

In reply to aduskett at gmail.com
Quoted 45 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"aduskett" == aduskett <[email protected]> writes:

From: Adam Duskett <[email protected]>
Older distributions such as CentOS6 come with python2.6, which causes build failures in packages such as host-libglib2 because they require python2.7 and above.

host-libglib2 will produce the error message:
/bin/sh: python2.7: command not found

Python2.7 is a hard-coded value in configure.ac. If one changes the value to just "python," the following stack trace is produced:

Traceback (most recent call last):
File "./gdbus-2.0/codegen/gdbus-codegen.in", line 55, in <module>
self.outfile.write(LICENSE_STR.format(config.VERSION))
ValueError : sys.exit(codegen_main.codegen_main())
zero length field name in format

Instead of supporting an ancient version of Python that had its support ended in October os 2013, it would be more pragmatic only to support Python2.7 and above.

Luckily; CentOS6 has the centos-release-scl repository, which allows users to install python2.7, and Debian 8 comes with Python2.7 already, making this patch relatively low impact.

---
Changes v1 -> v2:
- Updated version requirement in prerequisite.txt

Changes v2 -> v3:
- Added more precise language to the commit message.
- Added an example stack trace and error caused by python2.6 and host-libglib2.

 support/dependencies/dependencies.sh | 8 ++++++++
 1 file changed, 8 insertions(+)
support/dependencies/dependencies.sh +0 -0
index 58c34d880f..d0b6bdc23a 100755

support/dependencies/dependencies.sh if test "${missing_progs}" = "yes" ; then · line 186

Quoted 6 lines
support/dependencies/dependencies.sh +3 -0
@@ -181,6 +181,14 @@ if test "${missing_progs}" = "yes" ; then
 	exit 1
 fi
 
+# Check that the python version is at least 2.7
+PYTHON_VERSION=$(python -V 2>&1 |awk '{print $2}')
+if [ $(echo $PYTHON_VERSION |sed -e 's/\.//g') -lt 2700 ]; then

This fails on the (fairly unlikely case) of 2.7.x where x < 10, so I have changed it to:

PYTHON_VERSION=$(python -V 2>&1 |awk '{ split($2, v, "."); print v[1] v[2] }')

To only look at the major.minor part and committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard