.I am packaging a wheel which includes data files and I need to be able to get their path.
I have successfully added the files to the project using:
setup.py file:
from setuptools import setup
setup(...,
data_files=[('data', glob('data/**'))],
...)
$ python3 setup.py bdist_wheel
This gives me a wheel which (when unzipped) looks like:
my_project-0.0.0-py3-none-any.whl
├── my_project
│ ├── __init__.py
│ ├── awesome_feature.py
├── my_project-0.0.0.data
│ ├── data
│ │ ├── config.txt
│ │ ├── important_params.csv
│ │ ├── large_data_blob.dat
How can I reliably locate the data files from within this project?
In particular, projects which depend on my_project
will need to use these files and I need some way of finding the path of the data
folder and returning it to projects that depend on my_project
EDIT: I've tried locating the data with pkg_resources, but not had any luck. Following pip3 install my_project-0.0.0.whl
none of the data that was in the wheel seems to be in the installed package (judging by disk-usage).
I included the function:
def get_data_path():
import pkg_resources
return pkg_resources.resource_filename('my_project', 'data')
The path that returns is: /usr/local/lib/python3.4/dist-packages/my_project/data
, but that path doesn't exist?