NEWSubscribe to Receive Free E-mail UpdatesSubscribe

How to include license file in setup.py script? | Python

The basics of how to configure, package and distribute your own Python projects. It assumes that you are already familiar with the contents of the Installing Packages page.

This article does not aim to cover best practices for Python project development as a whole. For example, it does not provide guidance or tool recommendations for version control, documentation, or testing. This is more about showing how to include license file in setup.py when you plan to distribute with license.


Example: Assume I’m planning to license the xyz module under the BSD license. In my source tree, the file LICENSE.txt is in the top folder along with setup.py.

Fix: Write a setup.cfg file and in there specify:
[metadata]
license_files = LICENSE.txt{codeBox}

For this to work it seems like wheel is required to be installed. That is:
pip install wheel{codeBox}

If you have wheel already installed and it doesn't work, try to update it:
pip install --upgrade wheel{codeBox}

Then when installing the package via pip install <path> the LICENSE file gets included.

Post a Comment

0 Comments