ResourcePackage 1.0.0 for Python

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. You can download it from the project page
on SourceForge.

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 simply by copying an __init__.py file and then
use
the resources saved/updated in the package directory like so:

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 __init__.py 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. Similarly, automatic packaging systems will pick
up your resources as regular Python modules being imported by your
source-code.

There are two utility scripts, extract.py and scan.py which can be
used to manually extract or embed resources in a resourcepackage
package
even if the package no longer has a resourcepackage-aware __init__.py
file. See these scripts for usage details.

ResourcePackage has been stable for many months now. There
is, at the moment, nothing more planned to be added or changed, as it
fulfills all of my needs for it. I am, of course, interested in suggestions you might
have for improving the package. You can
get the distribution from the project page at:

Usage Details

use resourcepackage.wxgenerators (or another generator package)
to provide special handling for particular file-types

set the "force" flag to always reload resources into their
corresponding modules

save your resources to the resource directory

on (re-)import of __init__.py, it will scan your resource
directory and update resource files with dates newer than their
corresponding python module

import your resources as Python modules and access their binary
content as package.module.data

name will be the name of the file (with extension) with spaces,
'.' and '-' characters converted to '_' characters.

Note: in version 1.0.0a2 and earlier, module names
dropped the file extension and lowercased the entire module name.
In 1.0.0a3 and forward neither of these transformations is
performed. As a result, "Index.html" will be show up in the
module
Index_html, instead of index in all newer version. Also as a
result, Index.html and index.html will be recognised as the same name
on case-ignoring filesystems, but if you've already got the source
files
on a case-ignoring system, they can't both exist :) .

When wanting to distribute your package:

Replace __init__.py with your run-time __init__.py (which can
just be an empty Python module, as with any Python package, which
doesn't need to know anything about ResourcePackage).

That eliminates all connections to ResourcePackage
and you now have a regular Python package with all of your resources
embedded in it's modules. This isn't technically necessary, but
it
will make the installation cleaner and more efficient for users of your
package.

Reference Documentation

Pydoc documentation is
available online for those wishing to browse it.

Changes

There have been a few changes in ResourcePackage during the
development period. In particular:

version 1.0.0 adds a few Unix #! lines to the extract and scan
scripts.

version 1.0.0b1 introduces an encoding comment at the top of
generated files. This avoids a spurious warning from Python 2.3b2
and above indicating that non-ASCII characters are being included in a
string.

version 1.0.0a3 had some significant incompatible changes from
version 1.0.0a2. If you downloaded ResourcePackage before
1.0.0a3,
you should expect some significant breakage, as the naming scheme for
modules, as well as the mechanisms for use in scanning__init__.py
changed significantly. See readme.txt in the source archive for
details.