[py-dev] any chance of py working from a zip?

holger krekel hpk at trillke.net
Tue Jul 12 16:30:37 CEST 2005


Hi Kevin, 

On Tue, Jul 12, 2005 at 10:19 -0400, Kevin Dangoor wrote:
> I would like to get py.test (in particular) working from an "egg" (a
> zip file with metadata) for easy distribution with other packages that
> are tested with py.test. Creating the egg required a trivial change to
> py/misc/_dist.py. However, attempting to run py.test fails for me
> 
>   File "build/bdist.darwin-8.1.0-Power_Macintosh/egg/py/test/config.py",
> line 91, in loadconfig
>   File "build/bdist.darwin-8.1.0-Power_Macintosh/egg/py/test/config.py",
> line 206, in importconfig
>   File "build/bdist.darwin-8.1.0-Power_Macintosh/egg/py/path/local/local.py",
> line 357, in pyimport
> py.error.ENOENT: [No such file or directory]:
> /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/py-0.8.0_alpha2-py2.4.egg/py/test/defaultconftest.py
> 
> It's attempting to do a file lookup on something within
> py-0.8.0_alpha2-py2.4.egg, which is not going to work since that's a
> zip file.
> 
> Am I correct in assuming that the package handling tricks within py
> basically mean that py.test simply won't be able to run from within a
> zipfile?

It's not really about tricks here.  It's the usual problem of accessing data 
(and in this case a default conftest file which happens to come with
the distribution) from an installed package.   

> If it's just the configuration part that has an issue, that may be a
> manageable problem to solve, but I wanted to see what people here
> thought, since I haven't looked deeply at the packaging of py.

We definitely want a uniform way to get to resources from within
a running program. So far one does something like: 

    mypath = py.magic.autopath() 
    resource_in_my_dir = mypath.dirpath("somefile.txt") 

which returns a path to the 'somefile.txt' file residing in the same 
directory as the module where the above code lives.  
autopath() currently returns a local path object and for
imports from zip-files it should rather return a "Zip-Path"
but unfortunately this hasn't been written yet (it shouldn't
be hard, though, compared to the subversion WC and URL paths
already implemented).  Where is the summer of code when you
need it :-) 

cheers, 

    holger



More information about the Pytest-dev mailing list