如何在Ubuntu上正确安装多个非包Distribute/virtualenv/pip生态系统?
我正在 Ubuntu 中开发 Python 应用程序。我想设置一个 Distribute/virtualenv/pip 生态系统 独立于任何系统 Python 包(我在 Synaptic 中管理,或者更确切地说,我让系统为我管理它们)来管理我的 Python 包。
我可以只安装 python-setuptools、python-virtualenv 和 python-pip 系统包,然后就可以愉快地生活了,但我也希望能够获得最新/特定版本的 Distribute、virtualenv 和 pip。这些没有 PPA,所以我必须手动安装它们。
最后一个复杂的问题是我希望能够对多个版本的 Python 执行此操作。也就是说,为 python2.6 设置一个生态系统,为 python 设置另一个生态系统,为 python3 设置另一个生态系统,或者在 64 位系统上为 chroot 32 位 Python。
我猜这个过程会是这样的:
- 使用 Python X 安装我自己的分发副本到我的主文件夹中的某个位置
- 使用独立分发,easy_install pip
- 使用独立 pip,安装 virtualenv
- 使用独立 virtualenv,创建虚拟环境
- 激活虚拟环境、安装包
- 对 Python Y、Z 和 Q 重复此操作
我需要什么安装/配置选项?
I am developing Python applications in Ubuntu. I want to setup a Distribute/virtualenv/pip ecosystem to manage my Python packages independently of any system Python packages (which I manage in Synaptic, or rather I let the system manage them for me).
I could just install the python-setuptools, python-virtualenv and python-pip system packages and be on my merry way, but I also want to be able to get latest/specific versions of Distribute, virtualenv and pip. There are no PPAs for these, so I'll have to install them manually.
A final complication, is that I want to be able to do this for multiple versions of Python. That is, set up one ecosystem for python2.6, another for python, another for python3, or on a 64-bit system another for chrooted 32-bit Python.
I'm guessing that the process would be something like:
- Using Python X install my own copy of Distribute to a location in my home folder
- Using indie Distribute, easy_install pip
- Using indie pip, install virtualenv
- Using indie virtualenv, create virtual environment
- Activate virtual environment, install packages
- Repeat for Python Y, Z and Q
What installation/configuration options am I looking for?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基于 沃克·黑尔IV 对类似(但不同!;))问题的回答,执行此操作有两个关键:
因此,工作流程是:
注意:
我编写了一个 bash 脚本,它在 Ubuntu 中执行基础操作:
输出看起来像这样(关闭下载并打开停用):
Based on Walker Hale IV's answer to a similar (but distinct! ;) ) question, there are two keys to doing this:
So the workflow is:
Notes:
I've written a bash script that does the basics in Ubuntu:
Output looks something like this (with downloading switched off and deactivation switched on):
正如@jfsebastian 所指出的,virtualenvwrapper 可以完成您所要求的大部分或全部工作。
http://virtualenvwrapper.readthedocs.org/
As noted by @j.f.sebastian, virtualenvwrapper does much or all of what you're asking for.
http://virtualenvwrapper.readthedocs.org/
详细阐述 JF Sebastian 和 nealmcb 的贡献,这些天我确实使用了 virtualenvwrapper 的系统打包版本(在 Ubuntu 上可用) 12.04 及更高版本)。
我使用的关键功能(回答这个问题)是:
allvirtualenv pip install -U pip
升级所有 virtualenv 中的 pip提到的环境变量 JFS 确实很有用: PIP_DOWNLOAD_CACHE、VIRTUALENV_USE_DISTRIBUTE、WORKON_HOME、VIRTUALENVWRAPPER_PYTHON。
更新 virtualenv 本身的唯一原因是获取最新版本的 setuptools(以前称为 Distribute,以前称为 setuptools)。我还没有必要这样做,但我怀疑从一个新的 virtualenv 开始并首先升级 Distribute/setuptools,然后升级 pip,然后安装其他库是最简单的。
如果绝对需要新版本的 virtualenv,则应该修改引导脚本。
Elaborating on JF Sebastian and nealmcb's contributions, these days I do indeed use my system packaged version of virtualenvwrapper (available on Ubuntu 12.04 and later).
The key features I use (in answer to this question) are:
mkvirtualenv --python=PYTHON_EXE
creates a virtualenv using a specific Python executable (doesn't have to be a system packaged version)allvirtualenv pip install -U pip
upgrades pip in all virtualenvsThe environment variables JFS mentioned are indeed useful to fiddle with: PIP_DOWNLOAD_CACHE, VIRTUALENV_USE_DISTRIBUTE, WORKON_HOME, VIRTUALENVWRAPPER_PYTHON.
The only reason to update virtualenv itself is to get the latest version of setuptools (previously known as Distribute, previously known as setuptools). I haven't had a need to do this yet, but I suspect it would be easiest to start with a fresh virtualenv and upgrade Distribute/setuptools first, then upgrade pip, then install other libraries.
If a new version of virtualenv is strictly necessary, a modification of the bootstrap script should do.