I am in the process of packaging up a python package that I'll refer to as MyPackage
.
The package structure is:
MyPackage/
script.py
data.json
The data.json
file comprises cached data that is read in script.py
.
I have figured out how to include data files (use of setuptools include_package_data=True
and to also include path to data file in the MANIFEST.in
file) but now when I pip install this package and import the installed MyPackage (currently testing install by pip
from the GitHub repository) I get a FileNotFound
exception (data.json) in the script that is to utilize MyPackage. However, I see that the data.json
file is indeed installed in Lib/site-packages/MyPackage
.
Am I doing something wrong here by trying to read in a json
file in a package?
Note that in script.py
I am attempting to read data.json
as open('data.json', 'r')
Am I screwing up something regarding the path to the data file?