Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

python - How to include license file in setup.py script?

I have written a Python extension module in C++. I plan to distribute the module with setuptools. There will be binary distributions for 32- and 64-bit Windows (built with setup.py bdist_egg) and a source distribution for UNIX-like platforms (built with setup.py sdist).

I plan to license the module under the BSD license. In my source tree, the file LICENSE.txt is in the top folder along with setup.py. How should I include it in the installation package?

I tried the following setup.py script:

from setuptools import setup, Extension
from glob import glob

setup(
    name = 'Foo',
    version = '0.1.0',
    ext_modules = [Extension('Foo', glob('Source/*.cpp'))],
    package_data = {'': ['LICENSE.txt']}
)

It did not work, the license file is not included in the installation package. Maybe because the setup.py file does not define any packages, only a single extension module.

How do I fix this?

question from:https://stackoverflow.com/questions/9977889/how-to-include-license-file-in-setup-py-script

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Write a setup.cfg file and in there specify:

[metadata]
license_files = LICENSE.txt

For this to work it seems like wheel is required to be installed. That is:

pip install wheel

If you have wheel already installed and it doesn't work, try to update it:

pip install --upgrade wheel

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...