[Distutils] Accessing package data files in wheels
ben+python at benfinney.id.au
Sun Jun 28 03:48:00 CEST 2015
Justin Uang <justin.uang at gmail.com> writes:
> What is the recommended way to get access to a data file in my package
> if I'm using a wheel? pkg_resources seems like it's mainly useful
> because eggs might be used in a zipped form, but for wheels, I'm
> guaranteed that the data will be unpacked into a directory structure
> right? In that case, should I just use __file__ to manually find the
> location of the file?
An advantage of querying package resources using the ‘pkg_resources’ API
is that their lockation *doesn't* need to be known by your program. Let
the installation process put them in a sensible location for the system,
and discover that location at run-time using ‘pkg_resources’.
> I'm assuming I can still use pkg_resources, but it feels like I'm
> adding an unnecessary dependency on setuptools, given that setuptools
> isn't needed during installation but only when building the wheel.
You'll be doing the recipient a favour by allowing the package resources
to be in a different place from the executable files.
\ “Philosophy is questions that may never be answered. Religion |
`\ is answers that may never be questioned.” —anonymous |
More information about the Distutils-SIG