PYTHONPATH handling doesn't seem to match Python
PyPy doesn't seem to handle PYTHONPATH the same way Python does. Consider this: % echo $PWD:$PYTHONPATH /home/skipm/src/git/models/lenin:/home/skipm/src/tl_v11/prefix/lib/python2.7/site-packages:/opt/TWWfsw/libgtk+222/lib/python27/gtk-2.0 Now, run Python with that set as PYTHONPATH and see where directories land. I've trimmed out all the other elements which don't matter. Note that /home/skipm/src/tl_v11/prefix/lib/python2.7/site-packages appears in sys.path ahead of /opt/local/lib/python2.7/site-packages hornet% PYTHONPATH=$PWD:$PYTHONPATH python Python 2.7.2 (default, Nov 14 2012, 05:07:35) [GCC 4.4.6 [TWW]] on linux3 Type "help", "copyright", "credits" or "license" for more information.
import sys sys.path [..., '/home/skipm/src/tl_v11/prefix/lib/python2.7/site-packages', ..., '/opt/local/lib/python2.7/site-packages', ...]
Now, try the same experiment with PyPy. The relative order of those two directories is reversed: hornet% PYTHONPATH=$PWD:$PYTHONPATH pypy Python 2.7.3 (5acfe049a5b0cd0de158f62553a98f5ef364fd29, Jun 28 2013, 15:39:43) [PyPy 2.0.2] on linux3 Type "help", "copyright", "credits" or "license" for more information. And now for something completely different: ``"there should be one and only one obvious way to do it". PyPy variant: "there can be N half-buggy ways to do it"''
import sys sys.path [..., '/opt/local/lib/python2.7/site-packages', ..., '/home/skipm/src/tl_v11/prefix/lib/python2.7/site-packages', ...]
They each hold the copies of the internal development platform I work on. Since I am actively developing software using that platform, I prefer to have my development version ahead of our production install. Is there a way to make that work? Thx, Skip
Hi Skip, On Fri, Jun 28, 2013 at 10:41 PM, Skip Montanaro <skip.montanaro@gmail.com> wrote:
Now, try the same experiment with PyPy. The relative order of those two directories is reversed:
Sorry, I can't reproduce the problem you describe. More importantly I don't understand why '/opt/local/lib/python2.7/site-packages' ends up in sys.path at all on top of pypy. There is no reason to: pypy has no notion of '.../lib/python2.7', and certainly ending up with the same path as CPython looks very wrong to me (like it would be wrong to have CPython 2.6 and 2.7 both use '/opt/local/lib/python2.7/site-packages'). It's a custom-compiled pypy, so did you install it using the official script pypy/tool/release/package.py? If not, please give the paths where you copied things, starting with the pypy executable. Note that pypy is *not* supposed to be installed exactly like CPython. A bientôt, Armin.
On Fri, Jun 28, 2013 at 10:41 PM, Skip Montanaro <skip.montanaro@gmail.com> wrote:
Now, try the same experiment with PyPy. The relative order of those two directories is reversed:
Sorry, I can't reproduce the problem you describe. More importantly I don't understand why '/opt/local/lib/python2.7/site-packages' ends up in sys.path at all on top of pypy. There is no reason to: pypy has no notion of '.../lib/python2.7', and certainly ending up with the same path as CPython looks very wrong to me (like it would be wrong to have CPython 2.6 and 2.7 both use '/opt/local/lib/python2.7/site-packages').
It's a custom-compiled pypy, so did you install it using the official script pypy/tool/release/package.py? If not, please give the paths where you copied things, starting with the pypy executable. Note that pypy is *not* supposed to be installed exactly like CPython.
Armin, Thanks for the response. We have a lot of open source software packaged and provided for us by a company called The Written Word. That includes Python 2.7. Everything is installed with /opt/local as a replacement for /usr/local. For example: % PYTHONPATH= python -S -E Python 2.7.2 (default, Nov 14 2012, 05:07:35) [GCC 4.4.6 [TWW]] on linux3
import sys sys.path ['', '/opt/TWWfsw/curl722/lib/python27', '/opt/TWWfsw/cython017/lib/python27', '/opt/TWWfsw/distribute06/lib/python27', '/opt/TWWfsw/docutils08/lib/python27', '/opt/TWWfsw/git18/lib/python27', '/opt/TWWfsw/gnuplot44/lib/python27', '/opt/TWWfsw/jinja26/lib/python27', '/opt/TWWfsw/libcairo110/lib/python27', '/opt/TWWfsw/libgd20/lib/python27', '/opt/TWWfsw/libglib226/lib/python27', '/opt/TWWfsw/libgnutls210/lib/python27', '/opt/TWWfsw/libgtk+222/lib/python27', '/opt/TWWfsw/libgtk+222/lib/python27/gtk-2.0', '/opt/TWWfsw/libqt47/lib/python27', '/opt/TWWfsw/libxml27/lib/python27', '/opt/TWWfsw/libyaml01/lib/python27', '/opt/TWWfsw/libzeromq22/lib/python27', '/opt/TWWfsw/lxml22/lib/python27', '/opt/TWWfsw/matplotlib12/lib/python27', '/opt/TWWfsw/mysql5515r/lib/python27', '/opt/TWWfsw/nose11/lib/python27', '/opt/TWWfsw/numpy16/lib/python27', '/opt/TWWfsw/openldap24/lib/python27', '/opt/TWWfsw/pycrypto23/lib/python27', '/opt/TWWfsw/pygments14/lib/python27', '/opt/TWWfsw/scipy09/lib/python27', '/opt/TWWfsw/sphinx10/lib/python27', '/opt/TWWfsw/subversion17/lib/python27', '/opt/local/lib/python2.7/site-packages', '/opt/local/lib/python2.7/site-packages', '/opt/local/lib/python2.7/site-packages', '/opt/local/lib/python2.7/site-packages/snakemodels', '/opt/local/lib/python2.7/site-packages', '/opt/TWWfsw/python27/lib/python27.zip', '/opt/TWWfsw/python27/lib/python2.7/', '/opt/TWWfsw/python27/lib/python2.7/plat-linux3', '/opt/TWWfsw/python27/lib/python2.7/lib-tk', '/opt/TWWfsw/python27/lib/python2.7/lib-old', '/opt/TWWfsw/python27/lib/python2.7/lib-dynload']
Kind of weird that /opt/local/lib/python2.7/site-packages shows up four times. When I ran python ../../rpython/bin/rpython -Ojit targetpypystandalone that version of Python was executed. Accordingly, /opt/local/lib/python2.7/site-packages was in sys.path, as it should have been. It appears that the generated pypy-c wound up with that directory in its sys.path as well. I wasn't executing it from an installed location. I just set up an alias to execute it from the goal directory. OTOH, perhaps I should build it using /usr/bin/python: % PYTHONPATH= /usr/bin/python -S -E Python 2.7.3 (default, Apr 14 2012, 08:58:41) [GCC] on linux2
import sys sys.path ['', '/usr/lib/python27.zip', '/usr/lib64/python2.7/', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload']
(though I don't understand why /usr/lib/python2.7/site-packages isn't in sys.path here. Maybe site.py does that?) Skip
Hi Skip, On Sat, Jun 29, 2013 at 11:24 PM, Skip Montanaro <skip.montanaro@gmail.com> wrote:
that version of Python was executed. Accordingly, /opt/local/lib/python2.7/site-packages was in sys.path, as it should have been. It appears that the generated pypy-c wound up with that directory in its sys.path as well.
It doesn't matter much which version of Python is used to run the translation of PyPy, in the same way than it doesn't matter much which version of GCC is used to create CPython. It's certainly not meant to copy sys.path from the Python used for translation. I can't help you much more than this, however. If anyone else has anything to suggest, feel free. A bientôt, Armin.
On 06/29/2013 11:24 PM, Skip Montanaro wrote: [cut]
that version of Python was executed. Accordingly, /opt/local/lib/python2.7/site-packages was in sys.path, as it should have been. It appears that the generated pypy-c wound up with that directory in its sys.path as well. I wasn't executing it from an installed location. I just set up an alias to execute it from the goal directory. OTOH, perhaps I should build it using /usr/bin/python:
Do you by chance see this warning message when you start your pypy? debug: WARNING: Library path not found, using compiled-in sys.path. debug: WARNING: 'sys.prefix' will not be set. debug: WARNING: Make sure the pypy binary is kept inside its tree of files. debug: WARNING: It is ok to create a symlink to it from somewhere else. 'import site' failed If so, it means that somehow pypy does not find its stdlib and it just uses the builtin sys.path. Note that if you run pypy from within the hg checkout, this should not happen.
Do you by chance see this warning message when you start your pypy?
debug: WARNING: Library path not found, using compiled-in sys.path. debug: WARNING: 'sys.prefix' will not be set. debug: WARNING: Make sure the pypy binary is kept inside its tree of files. debug: WARNING: It is ok to create a symlink to it from somewhere else. 'import site' failed
No, nothing odd at all: % type pypy pypy is aliased to `/home/skipm/3rdParty/pypy-2.0.2-src/pypy/goal/pypy-c' % pypy Python 2.7.3 (5acfe049a5b0cd0de158f62553a98f5ef364fd29, Jun 29 2013, 21:26:14) [PyPy 2.0.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. And now for something completely different: ``A pink glittery rotating lambda''
participants (3)
-
Antonio Cuni
-
Armin Rigo
-
Skip Montanaro