Include *.pyd files in Python Packages

后端 未结 1 1470
Happy的楠姐
Happy的楠姐 2021-02-15 18:07

I have a python module module.pyd that works pretty fine once it is put manually onto the site-packages of python installation folder.

The problem star

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-15 18:17

    Just use the MANIFEST.in:

    recursive-include module *.pyd
    

    This will include all pyd files in the module directory.

    Your package layout should be the following:

    module/
    --- __init__.py
    --- _module.pyd
    --- module.py
    MANIFEST.in
    README.rst
    setup.py
    

    And don't forget to add include_package_data=True in setup() in your setup.py in order to force using MANIFEST.in when building wheels and win32 installers (else MANIFEST.in will only be used for source tarball/zip).

    Minimal example of setup():

    README_rst = ''
    with open('README.rst', mode='r', encoding='utf-8') as fd:
        README_rst = fd.read()
    
    setup(
        name='module',
        version='0.0.1',
        description='Cool short description',
        author='Author',
        author_email='author@mail.com',
        url='repo.com',
        packages=['module'],
        long_description=README_rst,
        include_package_data=True,
        classifiers=[
            # Trove classifiers
            # The full list is here: https://pypi.python.org/pypi?%3Aaction=list_classifiers
            'Development Status :: 3 - Alpha',
        ]
    )
    

    0 讨论(0)
提交回复
热议问题