在Python软件包中包含* .pyd文件 [英] Include *.pyd files in Python Packages

查看:350
本文介绍了在Python软件包中包含* .pyd文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个python模块 module.pyd ,一旦将其手动放置到python安装文件夹的站点程序包中,它就可以正常工作.

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

当我将解决方案上传到云环境时,问题开始了,buildpack要求我将每个模块作为软件包传递给pip install module进行安装.我用简单的 __ init __.py 文件创建了一个文件夹,该文件仅导入了 module.pyd 的所有内容,因此我的模块被视为文件夹.

The problem starts when I upload my solution to a cloud enviroment, the buildpack requests that I pass every module as a package to be installed with pip install module. I ve created a folder with a simple __init__.py file that just imports everything of the module.pyd so that my module is treated like a folder.

然后我在这里阅读 http://peterdowns.com/posts/first- time-with-pypi.html 如何上传自己的模块,但成功了,但是在安装模块时,不会复制 module.pyd 文件.我还尝试通过存储库pip install git+repository直接安装它,但是发生了同样的事情.

Then I read here http://peterdowns.com/posts/first-time-with-pypi.html how to upload my own module and I succeeded, but when I install my module, the module.pyd file is not copied. I also tried to install it direct by the repository pip install git+repository but the same thing happened.

我在这里已阅读 https://docs.python.org/2/distutils/sourcedist.html#specifying-the-files-to-distribute ,我可能不得不明确地说我想在其中复制 *.pyd 文件一个MANIFEST.in文件,我已经完成了,但是似乎还行不通.

I have read here https://docs.python.org/2/distutils/sourcedist.html#specifying-the-files-to-distribute that I might have to explicitly say I want to copy *.pyd files in a MANIFEST.in file, I have done it, but it seems not working yet.

我目前正在使用python 2.7.10

I currently using python 2.7.10

我是python的新手,非常感谢你们的帮助

I am new on python so I d appreciate you guys help

推荐答案

只需使用MANIFEST.in:

recursive-include module *.pyd

这将包括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

也不要忘记在setup.pysetup()中添加include_package_data=True,以便在构建轮子和Win32安装程序时强制使用MANIFEST.in(否则MANIFEST.in仅用于源tarball/zip ).

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).

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',
    ]
)

这篇关于在Python软件包中包含* .pyd文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆