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

Kevin Dangoor dangoor at gmail.com
Tue Jul 12 18:01:37 CEST 2005


Hi Holger,

On 7/12/05, holger krekel <hpk at trillke.net> wrote:
> 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 :-)

Actually, I think you're in luck! This has already been written as
part of setuptools.

http://peak.telecommunity.com/DevCenter/setuptools

Specifically,

http://peak.telecommunity.com/DevCenter/PythonEggs#accessing-package-resources

The pkg_resources module provides some nice mechanisms for uniformly
getting at your package data. setuptools also provides nicer options
for including your data in distributions.

I believe you could include pkg_resources without introducing a
dependency on setuptools, but setuptools is really not a bad
dependency to have.

Does py.test require access to things that would be in the zipfile
beyond the default configuration? I'm curious to know how much work
would be required to get py.test running from a zip...

Kevin


More information about the py-dev mailing list