简体   繁体   English

如何为依赖于pypi外部软件包的程序编写setup.py

[英]How to write a setup.py for a program that depends on packages outside pypi

For instance, what if PIL , python-rsvg and libev3 are dependencies of the program? 例如,如果PILpython-rsvglibev3是程序的依赖项,该怎么办? These dependencies are not in pypi index, the latter two are Debian package names. 这些依赖项不在pypi索引中,后两个是Debian软件包名称。

You could use setuptools. 您可以使用setuptools。 setuptools allows you to add any kind of Python installable (any distutils/setuptools enabled package) as a dependency, no matter if it is on PyPI or not. setuptools允许您添加任何种类的Python可安装项(任何启用了distutils / setuptools的软件包)作为依赖项,无论它是否基于PyPI。

For example, to depend on PIL 1.1.6, use something like: 例如,要依赖PIL 1.1.6,请使用类似以下内容的东西:

setup(...,
      install_requires = ["http://effbot.org/downloads/Imaging-1.1.6.tar.gz"],
      ...)

See setuptools docs for more information. 有关更多信息,请参见setuptools文档。

只需不要将它们放在依赖项中,而在INSTALL或README文件中进行记录。

If you are packaging something to be installed on Debian (as implied), the best way to manage dependencies is to package your program as a .deb and express the dependencies the Debian way. 如果您要打包要在Debian上安装的东西(暗含),最好的管理依赖项的方法是将程序打包为.deb并以Debian方式表示依赖项。 (Note, PIL is available in Debian as python-imaging .) (注意,PIL在Debian中可以作为python-imaging 。)

由于setup.py也是Python代码,因此您可以在这些软件包上下载并运行setup.py。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM