如何让 VirtualEnv 使用自定义版本的 setuptools?
我工作的大公司使用自定义版本的Setuptools。这个 setuptools 的私有分支旨在解决我们组织特有的某些网络和安全困难。最重要的是,标准安装工具和分发工具都无法在我们的环境中按预期工作。
我想开始在系统上使用 Ian Bicking 出色的 VirtualEnv 工具,特别是在我们的测试系统中,我们需要能够为测试代码设置大量沙盒区域 - 例如在我们的持续集成环境中。
不幸的是,每当我尝试构建新的虚拟环境时,virtualenv 工具都会尝试获取并安装最新的官方版本的Setuptools。由于上述原因,这会失败,而且还因为公司防火墙会阻止该操作。
我不想安装官方版本:
setuptools-0.6c11-py2.4.egg
我想安装我们的自定义版本,它可能被称为:
setuptools-foo-0.6c11-py2.4.egg
这个鸡蛋总是可以保证在系统的全局站点包中找到。我还可以保证它存在于我们所有的公司鸡蛋服务器中。
你能帮我让我的 virtualenv 使用我定制的 setuptools 而不是常规版本的 setuptools 吗?
The large corporation that I work for uses a custom version of Setuptools. This private fork of setuptools is intended to deal with certain networking and security difficulties that are unique to our organization. The bottom line is that neither the standard Setuptools nor Distribute would work as expected on our environment.
Id like to start using Ian Bicking's excellent VirtualEnv tool on systems, particularly in our test systems where we need to be able to set up a large number of sandboxed areas for test-code - e.g. in our continuous integration environment.
Unfortunately any time I try to build a new virtual environment the virtualenv tool tries to obtain and install the latest official version of Setuptools. This would fail for the reason stated above, and also because the corporate firewall would block the action.
Instead of installing the official version:
setuptools-0.6c11-py2.4.egg
I'd like to install our customized version which might be called something like:
setuptools-foo-0.6c11-py2.4.egg
This egg can always be guaranteed to be found in the system's global site-packages. I can also guarantee that it's present in all of our corporate egg servers.
Can you help me make my virtualenv use my customized setuptools instead of the regular version of setuptools.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该名称硬编码在 virtualenv.py 中。您必须修补 virtualenv.py 或将修补后的 setuptools Egg 命名为“setuptools-0.6c11-py2.4.egg”
The name is hardcoded in virtualenv.py. You have to either patch virtualenv.py or name your patched setuptools egg 'setuptools-0.6c11-py2.4.egg'
我开始编写自己的包装脚本来导入 virtualenv。主要原因是我使用 dpkgs 来安装大部分依赖项,包括
distribute
,因此我希望在创建新环境时避免下载额外的副本 - 这样做的好处是运行速度更快。这是您可以用来开始的基线包装器。我添加了一条注释,您可以在其中插入一些代码来符号链接/将自定义 setuptools 代码复制到 virtualenv 中:
用法:
I've taken to writing my own wrapper scripts which import virtualenv. The main reason is that I use dpkgs to install most of my dependencies, including
distribute
, so I like to avoid downloading additional copies when I create a new environment - this has a bonus that it runs much faster.Here is a baseline wrapper you can use to start with. I've added a comment where you could insert some code to symlink/copy your custom setuptools code into the virtualenv:
Usage:
选项
--extra-search-dir
允许定义包含所需版本的 setuptools 的本地目录。 文档对此进行了解释。There's the option
--extra-search-dir
that allows to define a local directory containing the desired version of setuptools. This is explained in the docs.