What's the correct way to exclude files from a python wheel distribution package?
Editing the MANIFEST.in
does not have any effect and I can't find information about this detail.
What's the correct way to exclude files from a python wheel distribution package?
Editing the MANIFEST.in
does not have any effect and I can't find information about this detail.
I assume you are asking how to exclude __pycache__
directory and *.pyc
while packaging into a wheel file using bdist/sdist. If so, the following manifest commands worked for me.
global-exclude */__pycache__/*
global-exclude *.pyc
I have never had that problem.
Here's an excerpt from my setup.py
:
name='aenum',
version='2.0.2',
url='https://bitbucket.org/stoneleaf/aenum',
packages=['aenum'],
package_data={
'aenum' : [
'LICENSE',
'README',
'doc/aenum.rst',
'doc/aenum.pdf',
]
},
include_package_data=True,
license='BSD License',
description="Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants",
long_description=long_desc,
provides=['aenum'],
author='Ethan Furman',
author_email='...',
classifiers=[
...
],
and my MANIFEST.in
:
exclude aenum/*
include setup.py
include README
include aenum/__init__.py
include aenum/test.py
include aenum/test_v3.py
include aenum/LICENSE
include aenum/CHANGES
include aenum/README
include aenum/doc/aenum.pdf
include aenum/doc/aenum.rst
I would say the exclude aenum/*
is what does the trick for me, so probably an exclude <package_name>/__pycache__
would work for you.
find_packages
from setuptools does that, additionally you may specify direrctories to exclude, like:
packages=find_packages(exclude=['docs', 'tests']),
But compiled artifacts (pyc files and __pycache__
dir) should be excluded automatically.
Why would you be doing that? The __pycache__ directory will be generated anyway when a project is run for the first time on the target machine. It's simply an optimised bytecode representation of Python.
But anyway, you can write an script that unpacks the .whl file and does the modifications and then repacks the wheel.