python:如何重建需要编译的依赖项 [英] python: how to rebuild dependencies that need compilation

查看:153
本文介绍了python:如何重建需要编译的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于大量依赖,我的python应用程序的虚拟环境的安装在部署过程中花费了太多时间.为了节省时间,我想在git中包括虚拟环境中的依赖项,以便它们在部署时就已经存在.

The installation of the virtual environment of my python application takes too much time during deployment due to a large amount of dependencies. In order to minize that time, I want to include the dependencies residing in the virtual environment in git, so that they are already there on deployment.

主要问题是由于机器之间的体系结构差异,需要重新构建C代码的依赖项.

The main issue with that is that dependencies with C code need to be rebuild because of architecture differences between machines.

是否可以在我的虚拟环境中重建所有需要编译的依赖项?

Is there a way to rebuild all dependencies that need compilation in my virtual environment?

推荐答案

车轮格式是您所需要的

流行的示例是lxml,在Linux上从源代码安装时,大约需要3分钟才能下载,编译和安装.

wheel format is what you need

Popular example is lxml, which when installing from source on Linux takes about 3 minutes to get downloaded, compiled and installed.

使用转轮格式并从本地转轮文件安装lxml只需不到一秒的时间.

Using wheel format and installing from local wheel file for lxml installs within fraction of a second.

有关如何使用它的详细说明,请参见更正的链接,该链接指向详细的SO回答如何配置pip a>包括说明如何利用车轮

For detailed instructions how I use it see corrected link to Detailed SO answer how to configure pip incl. instructions how to take advantage of wheels

有关更多信息:

  • pythonwheels page listing already available wheels.

车轮ReadTheDocs

使用pip制作轮子

一些注意事项:

  • 无论目标平台如何,纯python软件包都可以滚轮格式分发(除了可能与python版本有关).

  • pure python packages can be distributed in wheel format regardless of target platform (apart from being possibly python version dependent).

编译的python软件包应在将要安装它们的同一平台上构建.可能会有一些交叉编译选项,但是我对此没有真正的经验.

compiled python packages shall be build on the same platform, where you are going to install them. There might be some cross-compile options, but I do not have real experience with that.

有些人认为轮子是未来的包装格式",另一些人声称,它应该是在自己的立场上制造并使用自己的轮子.后一种情况是未将lxml作为转盘提供-请参见与转盘中的lxml相关的launchpad问题格式.如果您愿意,请考虑将您自己添加为受影响的人.

some do consider wheel of "package format of the future", others claim, that it is supposed to be build on your own side and use your own wheels. The later case is for lxml not being provided as a wheel - see launchpad issue related to lxml in wheel format. Consider adding there yourself as an affected person, if you care.

一旦您第一次使用轮子,就会喜欢它.

Once you manage using wheels the first time, you will love it.

这篇关于python:如何重建需要编译的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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