Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Python scripts assume that "/usr/bin/env python" is python2 #13009

Open Quuxplusone opened 12 years ago

Quuxplusone commented 12 years ago
Bugzilla Link PR12900
Status NEW
Importance P enhancement
Reported by Jed Brown (jed@59a2.org)
Reported on 2012-05-20 17:16:39 -0700
Last modified on 2013-09-29 06:13:17 -0700
Version trunk
Hardware PC Linux
CC anton@korobeynikov.info, austinenglish@gmail.com, daniel@zuster.org, Deil.Christoph@gmail.com, e.bachmakov@gmail.com, geek4civic@gmail.com, llvm-bugs@lists.llvm.org, mtahmed@uwaterloo.ca, muhammad.t.ahmad@intel.com, samuel@oriontransfer.org, uzytkownik2@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also

The build scripts are written in python2, but "/usr/bin/env python" is python3 on some systems (e.g. Arch Linux). There are at least two solutions

  1. Add a --with-python=/path/to/python configure flag so the user can choose a compatible version. Then invoke the scripts using ${PYTHON} path/to/script.py.

  2. Make the scripts hybrid python2/python3. This should be easy if you can assume python2.6 or later (to support importing print_function from future).

Quuxplusone commented 12 years ago

We have had some resistance in the past to moving to a newer Python than 2.4 (due to some BSDs), but honestly I think that moving to 2.6 is reasonably.

My preferred solution here would be to make our Python tools be hybrid python2/3.

Quuxplusone commented 12 years ago

RHEL5 is stuck on Python 2.4 and supported until 2017. It has been the main limitation for projects that I'm involved in. But most installations I have encountered already needed a newer version of Python and have upgraded.

Quuxplusone commented 11 years ago
I ran into this error trying to build ROOT (root.cern.ch, they now include a
copy of llvm in their SVN trunk):
https://savannah.cern.ch/bugs/?99139

What's the status on this one?
Any chance of fixing this quickly so that llvm 3.2 can be built with Python 3?
Quuxplusone commented 11 years ago
Just for reference, here's the errors you'll get if the python on your PATH is
a Python 3.

Plenty of these ImportErrors, but the build keeps going:

llvm[4]: Constructing LLVMBuild project information.
Traceback (most recent call last):
  File "/Users/deil/software/llvm_Python3/llvm/utils/llvm-build/llvm-build", line 3, in <module>
    import llvmbuild
  File "/Users/deil/software/llvm_Python3/llvm/utils/llvm-build/llvmbuild/__init__.py", line 1, in <module>
    from main import main
ImportError: No module named main
llvm[4]: Compiling HexagonMCAsmInfo.cpp for Debug+Asserts build

Then after a few minutes the build fails like this:

llvm[2]: Building Debug+Asserts Archive Library libLLVMCodeGen.a
llvm[1]: Constructing LLVMBuild project information.
Traceback (most recent call last):
  File "/Users/deil/software/llvm_Python3/llvm/utils/llvm-build/llvm-build", line 3, in <module>
    import llvmbuild
  File "/Users/deil/software/llvm_Python3/llvm/utils/llvm-build/llvmbuild/__init__.py", line 1, in <module>
    from main import main
ImportError: No module named main
llvm[1]: Building llvm-config BuildVariables.inc file.
llvm[1]: Compiling llvm-config.cpp for Debug+Asserts build
/Users/deil/software/llvm_Python3/llvm/tools/llvm-config/llvm-config.cpp:45:10:
fatal error: 'LibraryDependencies.inc' file not found
#include "LibraryDependencies.inc"
         ^
1 error generated.
rm: /Users/deil/software/llvm_Python3/build/tools/llvm-
config/Debug+Asserts/llvm-config.d.tmp: No such file or directory
make[1]: *** [/Users/deil/software/llvm_Python3/build/tools/llvm-
config/Debug+Asserts/llvm-config.o] Error 1
make: *** [all] Error 1
Quuxplusone commented 11 years ago

This is a major issue when building with MacPorts and Python3. It has been over a year, can we get some movement on this issue?

Quuxplusone commented 11 years ago

According to http://www.python.org/dev/peps/pep-0394/ there should be a python2 executable everywhere python2 is installed?

So how about /usr/bin/env python -> /usr/bin/env python2 ?

Quuxplusone commented 11 years ago

Note the date on the PEP. Recent distributions should have python2, but older installations (before 2010 or so) usually don't.

Quuxplusone commented 11 years ago

At the very least, it would be good if there was a PYTHON environment variable that one could specify.

Quuxplusone commented 11 years ago
(In reply to comment #8)
> At the very least, it would be good if there was a PYTHON environment
> variable that one could specify.

Not exactly an environment variable but there is CMake variable:

cmake ../llvm-3.3.src -DPYTHON_EXECUTABLE=/usr/bin/python2.7

(You can substitute /usr/bin/python2.7 by path that's working on your system).

At least quick search shown that FindPythonInterp allows to specified allow
versions (at least in newer CMake) but I haven't used CMake so I don't know how.