Re: [pypy-dev] new autopath logic?
In a message of Wed, 05 May 2004 18:42:37 +0200, holger krekel writes:
Hi,
as many of you may know, we are using copies of pypy/tool/autopath.py in a couple of places in order to insert a correct Python search path for 'import pypy.xxx.yyy' to succeed. With "import autopath" as the first li ne all the test_*.py can be invoked directly from the commandline and directly run. However, autopath.py needs the information about the top-directory ('pypy' in our case) to be encoded. It would be nicer to have an autopath.py that is independent from a particular project.
So what about trying to automize it completly like this: Start from the directory where the invoked script/test is in and look upwards for a directory *not* containing __init__.py anymore: This would be the directory that needs to be ensured to be in sys.path. The last one would we the autopath.projectdir so you can reference non-python resource files in the project.
I checked a bit and for pypy this should work as well as for the other projects that use a clone of autopath.py. Opinions?
cheers,
holger
Sounds good. Maybe we write a PEP and get it into the standard library, too. Laura
[Laura Creighton Wed, May 05, 2004 at 06:44:21PM +0200]
In a message of Wed, 05 May 2004 18:42:37 +0200, holger krekel writes:
Hi,
as many of you may know, we are using copies of pypy/tool/autopath.py in a couple of places in order to insert a correct Python search path for 'import pypy.xxx.yyy' to succeed. With "import autopath" as the first li ne all the test_*.py can be invoked directly from the commandline and directly run. However, autopath.py needs the information about the top-directory ('pypy' in our case) to be encoded. It would be nicer to have an autopath.py that is independent from a particular project.
So what about trying to automize it completly like this: Start from the directory where the invoked script/test is in and look upwards for a directory *not* containing __init__.py anymore: This would be the directory that needs to be ensured to be in sys.path. The last one would we the autopath.projectdir so you can reference non-python resource files in the project.
I checked a bit and for pypy this should work as well as for the other projects that use a clone of autopath.py. Opinions?
cheers,
holger
Sounds good. Maybe we write a PEP and get it into the standard library, too.
wow, that took 2 minutes roundtrip :-) Yes, putting it in a standard place would be nicer than having to distribute it all over the project. For the time beeing this needs to be done, though. cheers, holger
holger krekel wrote:
[Laura Creighton Wed, May 05, 2004 at 06:44:21PM +0200]
Sounds good. Maybe we write a PEP and get it into the standard library, too.
wow, that took 2 minutes roundtrip :-)
Yes, putting it in a standard place would be nicer than having to distribute it all over the project. For the time beeing this needs to be done, though.
Well, until it gets into the standard library, you could spin it out as a separate project. Set up a quick distutils script to install it into the library path, and it's like it's in the standard library - and this would work with existing versions of Python too. This would add a dependency to PyPy, but as long as it is small and doesn't update too often, this shouldn't be too onerous. -Rocco
Hi Rocco, [Rocco Moretti Fri, May 14, 2004 at 09:04:02AM -0500]
holger krekel wrote:
[Laura Creighton Wed, May 05, 2004 at 06:44:21PM +0200]
Sounds good. Maybe we write a PEP and get it into the standard library, too.
wow, that took 2 minutes roundtrip :-)
Yes, putting it in a standard place would be nicer than having to distribute it all over the project. For the time beeing this needs to be done, though.
Well, until it gets into the standard library, you could spin it out as a separate project. Set up a quick distutils script to install it into the library path, and it's like it's in the standard library - and this would work with existing versions of Python too.
Yes, this would work but we want to avoid dependencies on stuff other than distributed in .../pypy/src as long as possible. The main point was that i want to have one single unmodified version of 'autopath.py' that can be used verbatim in multiple projects. I have meanwhile implemented such a version (based on looking for __init__.py upwards) and it works reasonably well with some obvious restrictions. With the upcoming 'std' library (containing Armin's and my new 'utest' packge) you will be able to do from std.magic import autopath with the kind-of-same desired effect. However, with the strict dependency rule above we cannot use this as 'std' is not guaruanteed to be in the path.
This would add a dependency to PyPy, but as long as it is small and doesn't update too often, this shouldn't be too onerous.
Let's at least try to keep the number of pre-installed dependencies at zero as along as we can :-) cheers, holger
participants (3)
-
holger krekel -
Laura Creighton -
Rocco Moretti