Reputation: 112
I am trying to create a pip package and when I create the package it always includes __pycache__
subdirectories. I am using MANIFEST.in to specify which file types should be included and that works well.
How do I tell MANIFEST.in to exclude specific folders anywhere in the package?
Edit: I am trying to exclude a directory, not just a file. There are several options in the manifest to exclude files, such as global-exclude
or recursive-exclude
. But there is no global-exclude-dir
option, which is why I asked here.
My setup.py looks like this:
from setuptools import setup, find_packages
setup(
name='my_package',
version='0.0.1',
install_requires=[
'importlib-metadata; python_version == "3.8"',
],
include_package_data=True,
package_dir={"my_package": "contrib"}, # renamed src to contrib
)
The manifest contains this:
global-include *.npy *.npz
global-include *.txt
# [+ current exclude-directory test]
The global-include
commands are working as intended. I tried the following to exclude any __pycache__
directories (thanks @phd for their suggestions):
prune __pycache__
prune */__pycache__
recursive-exclude */__pycache__ *
Upvotes: 2
Views: 3440
Reputation: 94511
prune __pycache__
prunes only top-level __pycache__
. To prune __pycache__
anywhere in the directory hierarchy use
prune */__pycache__
Upvotes: 2
Reputation: 112
The goal of this post was to include any __pycache__
directories from the pip package. This is not really possible because each __init__.py
creates a __pycache__
directory after the manifest is created.
For anyone looking for an answer on how to exclude folders when building a wheel using MANIFEST.in, both suggestions posted by phd are working:
prune */__pycache__
recursive-exclude */__pycache__ *
Upvotes: 2