port select python and config error

Ryan Schmidt ryandesign at macports.org
Sun Oct 28 21:25:14 UTC 2018



On Oct 28, 2018, at 16:08, Mark Brethen wrote:

> Quite by accident I have discovered a flaw with my libreduce port as regards to "port select —set python". I had not set a default python version before I built the reduce libraries, unaware it was using apple's system python 2.7 to build. However, when I set a python version using port select —set python and add the python group, libreduce fails at configure. There is a file ‘ac_python_devel.m4’ in the source directory that is throwing the error (see attached). I’m not sure why builds with apple’s python and not macports.
> 
> <main.log><ac_python_devel.m4>

Which version of python did you select?

The error shown in your log is:

:info:configure checking for python... /opt/local/bin/python
:info:configure checking for a version of Python >= '2.1.0'...   File "<string>", line 1
:info:configure     import sys, string; 		ver = string.split(sys.version)[0]; 		print ver >= '2.1.0'
:info:configure                                                                         ^
:info:configure SyntaxError: invalid syntax
:info:configure no

If I pass that code to MacPorts python2.7 it works fine. If I pass it to MacPorts python3.5 it shows an invalid syntax error, because it is: python3 changed the syntax of the print command. It's now a function, not a language construct, so parentheses need to be used.

In addition, string.split is gone in python3.

Code that works with both python2 and python3 is:

import sys, string; ver = sys.version.split()[0]; print(ver >= '2.1.0')

You might suggest that to the developers of this software.

Using a string comparison operator on version numbers is probably wrong too.

If the configure script's code wasn't compatible with python3, who knows if the rest of the project's python code is. If it's not, easiest to just force the port to use /usr/bin/python. Setting "configure.python /usr/bin/python" might do that.



More information about the macports-dev mailing list