Sometimes, we want to include non-Python files with setup.py.
In this article, we’ll look at how to include non-Python files with setup.py.
How to include non-Python files with setup.py?
To include non-Python files with setup.py, we can call the setup
function with the package_data
argument.
For instance, we write
from setuptools import setup, find_packages
setup(
name='your_project_name',
version='0.1',
description='A description.',
packages=find_packages(exclude=['ez_setup', 'tests', 'tests.*']),
package_data={'': ['license.txt']},
include_package_data=True,
install_requires=[],
)
to call setup
with package_data
set to {'': ['license.txt']}
to include license.txt in our package.
Having empty string as the key means include the file in all packages.
Conclusion
To include non-Python files with setup.py, we can call the setup
function with the package_data
argument.