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 file and then use the resources saved/updated in the package directory like so:

from mypackage.resources import open_ico
result = myStringLoadingFunction( )

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 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 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, and which can be used to manually extract or embed resources in a resourcepackage package even if the package no longer has a resourcepackage-aware 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:

Happy Packaging!

Usage Details

During development:

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:

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.


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