I'm writing a Django application that is using pip & virtualenv to manage its development environment.
One of the dependencies, pkgme, comes with many data files which are its "backends" and are configured in its setup.py with data_files=$FOO
(rather than package_data
).
When pkgme looks for its backends, it looks in os.path.join(sys.prefix, "share", "pkgme", "backends")
. This works great when pkgme has been installed normally, and seems to match the documentation but does not work when pkgme is installed as an egg.
There, the data files are installed under $VIRTUAL_ENV/lib/python2.7/site-packages/pkgme-0.1-py2.7.egg/share
rather than the expected $VIRTUAL_ENV/share
.
Which leaves me with two questions:
os.path.join
above to find the data files regardless of whether we are using an egg installation or a traditional system installation? If so, what?Note that I know about pkgutil.get_data
, but would rather not use it. I'm not interested in the contents of these data files, I want to know their location instead, so I can execute them.
My current plan is to do this:
package_data
instead of data_files
pkgme.__file__
rather than sys.prefix
I ended up doing the following:
pkg_resources.resource_filename()
to find its own included backendssys.prefix
-based check for any backend that don't want to use PythonThe diff can be found here: http://bazaar.launchpad.net/~pkgme-committers/pkgme/trunk/revision/86