如何强制virtualenv从pypi安装最新的setuptools和pip?

2024-10-06 12:40:32 发布

您现在位置:Python中文网/ 问答频道 /正文

是否可以强制virtualenv使用pypi提供的最新设置工具和pip?本质上,我在寻找--never-download标志的相对。

目前,当我制作一个新的virtualenv时,它使用与virtualenv捆绑在一起的本地(旧)版本。

$ v.mk testvenv
New python executable in testvenv/bin/python
Installing setuptools............done.
Installing pip...............done.
$ pip show setuptools
---
Name: setuptools
Version: 0.6c11
Location: /Users/cwilson/.virtualenvs/testvenv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Requires: 
$ pip search setuptools
[...]
setuptools                - Easily download, build, install, upgrade, and
                            uninstall Python packages
INSTALLED: 0.6c11
LATEST:    0.7.2
[...]

Tags: pip工具版本pypivirtualenv标志downloadpackages
3条回答

我需要最新的setuptools库,而--extra-search-dir标志对我不起作用(尽管它显然已经修复)。

然而,在不使用setuptools的情况下制作一个virtualenv,然后直接从PyPi安装,效果很好。 E、 g.要设置名为test的virtualenv:

virtualenv --no-setuptools test
source test/bin/activate
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
easy_install pip

使用测试

python -c 'import setuptools; print setuptools.__version__'

显示正确的版本。

出于安全原因,它不受支持。

Using virtualenv.py as an isolated script (i.e. without an associated virtualenv_support directory) is no longer supported for security reasons and will fail with an error. Along with this, --never-download is now always pinned to True, and is only being maintained in the short term for backward compatibility (Pull #412).

我也不能使用--extra-search-dir选项,因为它当前已损坏https://github.com/pypa/virtualenv/issues/327

看起来唯一的选择就是等待virtualenv维护人员更新捆绑包?

安装virtualenv后,可以使用pip install -U pip升级pip。

我相信您可以编写一个引导脚本来自动执行此步骤。

相关问题 更多 >