How to include license file in setup.py script?

前端 未结 5 1814
陌清茗
陌清茗 2021-02-01 14:55

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

5条回答
  •  一个人的身影
    2021-02-01 15:15

    New setuptools (40.x) allows metadata, including license, to be stored in the setup.cfg's "metadata" section. If you use older setuptools you could provide license using the "license" named argument in your setup():

    def read_text(file_name: str):
        return open(os.path.join(base_path, file_name)).read()
    
    
    setup(
        name = 'Foo',
        version = '0.1.0',
        ext_modules = [Extension('Foo', glob('Source/*.cpp'))],
        # package_data = {'': ['LICENSE.txt']}
        license=read_text("LICENSE.txt")
    )
    

提交回复
热议问题