[Python-Dev] import vs. data files (Fwd: ResourcePackage 1.0.0a2 available...)

Just van Rossum just@letterror.com
Mon, 13 Jan 2003 20:59:41 +0100


FWIW, I find the project below an interesting approach to the data file
problem -- there's no import magic at all and should be compatible with
any packaging scheme.

Just

> From: "Mike C. Fletcher" <mcfletch@rogers.com>
> Subject: ResourcePackage 1.0.0a2 available...
> Date: Mon, 13 Jan 2003 11:45:24 -0500
> Newsgroups: comp.lang.python
> Message-ID: <mailman.1042476451.9009.python-list@python.org>
> 
> ResourcePackage is a mechanism for automatically managing resources
> (i.e. non-Python files: small images, documentation files, binary
> data) embedded in Python modules (as Python source code),
> particularly for those wishing to create re-usable Python packages
> which require their own resource-sets.
> 
> ResourcePackage allows you to set up resource-specific sub-packages
> within your package.  It creates a Python module for each resource
> placed in the resource package's directory during development.  You
> can set up these packages with a simple file-copy and then use the
> resources saved/updated in the package directory like so:
> 
>     from mypackage.resources import open_icon
>     result = myStringLoadingFunction( open_icon.data )
> 
> ResourcePackage scans the package-directory on import to refresh
> module contents, so simply saving an updated version of the file will
> make it available the next time your application is run.
> 
> When you are ready to distribute your package, you need only replace
> the copied file with a dummy __init__.py to disable the scanning
> support and eliminate all dependencies on resourcepackage (that is,
> your users do not need to have resourcepackage installed once this is
> done).  Users of your packages do not need to do anything special
> when creating their applications to give you access to your
> resources, as they are simply Python packages/modules included in
> your package's hierarchy.  Your package's code (other than the
> mentioned __init__.py) doesn't change.
> 
> Note: there is code in resource package to allow you to manually
> refresh your package directories w/out copying in __init__.py.  I
> haven't yet wrapped that as a script, but intend to for the 1.0
> release. ResourcePackage is currently in 1.0 alpha status, it appears
> to work properly, but it has only had minimal testing.  You can get
> the distribution from the project page at:
> 
>     http://sourceforge.net/projects/resourcepackage/
> 
> I'm interested in any bug reports, enhancement requests or comments.
> 
> Enjoy all,
> Mike Fletcher
> 
> _______________________________________
>   Mike C. Fletcher
>   Designer, VR Plumber, Coder
>   http://members.rogers.com/mcfletch/