Q: In creating a python distribution using setup.py and MANIFEST.IN, how can I define define the nested data directories that I do and don't want in the final installation directory (Complex example!)
Background: My program has a set of data directories (not source directories). Within each of these main directories, is are some subdirectories with user specific names. In my setup.py, I want to exclude my own data directories, while still including the other subdirectories that all users should have access to.
The file tree AS IT CURRENTLY EXISTS in my Pycharm DEVELOPMENT environment:
PycharmProjects
pythonProject
data_files_directory_1
subdirectory_to_be_EXcluded
data_file_to_be_EXcluded.txt
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
index.html
data_files_directory_2
subdirectory_to_be_EXcluded
data_file_to_be_EXcluded.txt
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
index.html
src
__init__.py
constants.py
helper1.py
helper2.py
main.py
Expected result:
The file tree I WANT AFTER INSTALLATION on target machine:
PycharmProjects
pythonProject
data_files_folder_1
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
data_files_folder_2
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
index.html
src
__init__.py
constants.py
helper1.py
helper2.py
main.py
Actual result:
PycharmProjects
pythonProject
data_files_directory_1
subdirectory_to_be_EXcluded
data_file_to_be_EXcluded.txt
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
index.html
data_files_directory_2
subdirectory_to_be_EXcluded
data_file_to_be_EXcluded.txt
subdirectory_to_be_INcluded
data_file_to_be_INcluded.txt
index.html
src
__init__.py
constants.py
helper1.py
helper2.py
main.py
What I tried / Source code:
MANIFEST.IN
...
graft data_files_directory_1
graft data_files_directory_2
...
setup.py
setup(
...
# include everything in MANIFEST.IN:
include_package_data=True,
# ...but exclude just these directories */subdirectory_to_be_EXcluded/* from all packages
exclude_package_data={"": ["*/subdirectory_to_be_EXcluded/*"]},
...
)
PROBLEM: As you can see, the exclusion request is being ignored.
I must confess that after heavy use of Google, YouTube and PyCharm documentation on setup.py and installers that I'm not really clear what the correct way is to include and exclude NON-source directories and files. It seems like many of the possible solutions are deprecated!
What is the correct way to do this?
Can someone point me at some good working examples?