如何打包python模块依赖的共享对象? [英] How to package shared objects that python modules depend on?

查看:76
本文介绍了如何打包python模块依赖的共享对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用C ++实现的python软件包,我正在使用setuptools分发该软件包.我的C ++代码取决于某些共享库,特别是boost.python库.我应该如何分发这些共享对象?目前,我要求软件包用户单独安装boost C ++库,但我宁愿将所有内容捆绑在一个setuptools发行版中,以使他/她更轻松.目前,除了安装我的软件包之外,他们还必须设置Boost库及其 LD_LIBRARY_PATH 环境变量.

I have a python package implemented in C++ that I am distributing using setuptools. My C++ code depends on some shared objects, specifically the boost.python library. How should I distribute these shared objects? At the moment I ask the package user to install the boost C++ libraries separately but I would rather bundle everything in one setuptools distribution to make it easier for him/her. At the moment they must set up the boost libraries and their LD_LIBRARY_PATH environment variable in addition to installing my package.

推荐答案

声明依赖项

setup.py 中有一个名为 install_requires = ["] 的选项:例如:

Declaring dependencies

There is an option in setup.py called install_requires = [""] : Ex :

setup(
    name='django-cherrypy',
    version='0.1',
    packages=packages,
    license='LICENSE',
    description='cherrypy, running under django',
    long_description=open('README.md').read(),
    author='Calvin Cheng',
    author_email='calvin@calvinx.com',
    install_requires=['cherrypy-wsgiserver'],
    extra_requires=['newrelic'],
    url='https://github.com/od-eon/django-cherrypy',
)

此设置要求使用chrerryPy WSGI服务器库.

This setup ask for chrerryPy WSGI server library.

此处介绍了所有内容: http://pythonhosted.org/distribute/setuptools.html#declaring-dependencies

Everything is explained here : http://pythonhosted.org/distribute/setuptools.html#declaring-dependencies

PiPy中的缺陷:

Depedencies in PiPy :

  1. 在安装项目时,通过使用EasyInstall,setup.py安装或setup.py开发,并非所有依赖项已安装的文件将通过PyPI定位,下载,构建(如果必要),然后安装.
  2. 项目中的任何脚本都将是装有包装的包装盒,可验证包装盒的可用性在运行时指定依赖项,并确保正确版本会添加到sys.path中(例如,如果已经有多个版本已安装).
  3. Python Egg发行版将包含元数据文件列出依赖项

PyPI中没有的依赖项

Dependencies that aren’t in PyPI

如果您的项目依赖于未在PyPI中注册的软件包,只要它们可用,您仍然可以依靠它们下载为:

If your project depends on packages that aren’t registered in PyPI, you may still be able to depend on them, as long as they are available for download as:

  • 标准distutils sdist格式的鸡蛋,
  • 单个.py文件,
  • 或VCS存储库(Subversion,Mercurial或Git).您只需要向setup()的dependency_links参数添加一些URL.

这篇关于如何打包python模块依赖的共享对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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