[pypy-dev] Re: Pypy frontend/ testall.py

Bengt Richter bokr at oz.net
Fri Mar 14 04:04:33 CET 2003


At 13:04 2003-03-10 +0000, Michael Hudson wrote:
>Armin Rigo <arigo at tunes.org> writes:
>
>> Hello Michael,
>>
>> On Mon, Mar 10, 2003 at 11:42:47AM +0000, Michael Hudson wrote:
>>> >> Additionally, when testing, an "import test" opens the "test" submodule of 
>>> >> Lib/pypy/interpreter.
>>> 
>>> ?  Shouldn't do, if $PYTHONPATH is pointing at the directory
>>> containing the pypy directory.
>>
>> It does, if the current directory is pypy/interpreter (for example when you
>> run python 'interactive.py').
>
>So don't do that, run
>
>$ PYTHONPATH=. python pypy/interperter/interactive.py
>
>then.  I can see this being tedious, though.
>
>interactive.py could remove the cwd from sys.path, but that also might
>be surprising.
>
>>> > Why is there an __init__.py file in our pypy/interpreter/test/ subdirectory?
>>> Because I wanted to import something from there at some point.
>>
>> Ok, but then:
>>
>>> > We will keep running again and again into this problem.
>>> Why?
>>
>> Because then you have no way to import the standard library 'test' package 
>
>I actually realised this bit :-) It's just that if you set up your
>paths the Right Way(tm) you shouldn't bump into this.
>
>Perhaps we should do a mass test -> pypytest (or something) renaming,
>for simplicity.
>
>Cheers,
>M.
>(relative imports are evil, have I mentioned this lately?)

I wonder if some kind of aliasing mechanism could solve this kind
of problem. E.g., if about to raise an exception for non-existent
file/directory, first check for a match to some rewrite patterns
in an alias file. They could be simple prefix replacements for
paths or more complex regex subs. Then, after rewriting, try the
modified path, and only after that fails raise the exception.

This would allow creation of platform-independent sys.path name
prefixes like, e.g., r"/$$py_lib" and generating, e.g., r"D:\python22\lib"
or the unix equivalent as the modified path prefix actually used.

All python system files could thus exist under a tree of platform-
independent alias prefixes, and pypy could define some for special
purposes. There could even be a mechanism for pushing/popping a
temporary prefix definition override.

Appropriate naming conventions should avoid problems.

(I have previously posted about virtualizing part of the file/directory
namespace accessed via python's open/file built-ins, and gotten objections
that this would not appear to i/o done via the os module or user-written
extension modules. I didn't pursue it further, but I still think something
platform-independent could be useful.)

my .02USD

Regards,
Bengt Richter
(Back from 2 wks on a sunny beach ;-)



More information about the Pypy-dev mailing list