If you are currently using setuptools
in the setup.py
for your project, and making use of python setup.py bdist_wheel
as the method to generate the .whl
file, add the following line to the MANIFEST.in
file which is already present at the root of your project.
recursive-include myproject *
Naturally, replace myproject
for the actual top level directory that will include the target .pl
scripts (or any other file).
As a demo, if your setup.py
is written approximately like so:
from setuptools import setup
from setuptools import find_packages
setup(
name='myproject',
version='0.0.0',
description='demo package',
long_description=open('README.md').read(),
classifiers=[
'Programming Language :: Python',
],
packages=find_packages(),
include_package_data=True,
zip_safe=False,
)
Running python setup.py bdist_wheel
will show output that looks like:
...
adding 'myproject/__init__.py'
adding 'myproject/config.py'
adding 'myproject/logging.ini'
adding 'myproject/myperlscript.pl'
adding 'myproject/scripta.py'
adding 'myproject/utils.py'
adding 'myproject/version.py'
adding 'test/__init__.py'
...
The files are packaged inside the .whl
:
$ unzip -t dist/myproject-0.0.0-py3-none-any.whl
Archive: dist/myproject-0.0.0-py3-none-any.whl
testing: myproject/__init__.py OK
testing: myproject/config.py OK
testing: myproject/logging.ini OK
testing: myproject/myperlscript.pl OK
...
Installing the resulting .whl
file in a new environment:
$ pip install -U myproject-0.0.0-py3-none-any.whl
Processing myproject-0.0.0-py3-none-any.whl
Installing collected packages: myproject
Successfully installed myproject-0.0.0
$ ls env/lib/python3.6/site-packages/myproject/
config.py logging.ini __pycache__ utils.py
__init__.py myperlscript.pl scripta.py version.py
Also note that if the MANIFEST.in
method is unwanted, include package_data={'': ['*']},
argument for the setup
call should also make it work with the recent versions of setuptools
.
Further addendum: The setuptools
package actually has a MANIFEST.in
that include this particular syntax, though restricted to specific filename extensions for the files they want to include. This is clearly a supported option despite some guides/documentation that might suggest otherwise. In fact, this is a feature provided by the core distutils
module that is shipped with Python by default. Related questions: