I have a new library that has to include a lot of subfolders of small datafiles, and I'm trying to add them as package data. Imagine I have my library as so:
library
- foo.py
- bar.py
data
subfolderA
subfolderA1
subfolderA2
subfolderB
subfolderB1
...
I want to add all of the data in all of the subfolders through setup.py
, but it seems like I manually have to go into every single subfolder (there are 100 or so) and add an __init__.py
file. Furthermore, will setup.py
find these files recursively, or do I need to manually add all of these in setup.py
like:
package_data={
'mypackage.data.folderA': ['*'],
'mypackage.data.folderA.subfolderA1': ['*'],
'mypackage.data.folderA.subfolderA2': ['*']
},
I can do this with a script, but seems like a super pain. How can I achieve this in setup.py
?
PS, the hierarchy of these folders is important because this is a database of material files and we want the file tree to be preserved when we present them in a GUI to the user, so it would be to our advantage to keep this file structure intact.
data_dir
: pkg_dir = op.abspath(op.dirname(file)) data_dir = op.join(pkg_dir, 'data') Then I could do in my program open('data_dir/somedatafile', 'r') Where data_dir will refer to wherever they were installed. – Travistravus