[英]Keeping the same, shared virtualenvs when switching from pyenv-virtualenv to pipenv
I started looking at pipenv
and it seems to be pretty good.我开始看
pipenv
,它似乎很不错。 My only concern is, that most of my projects involve numpy
, scipy
and some other not-so-small libraries.我唯一担心的是,我的大部分项目都涉及
numpy
、 scipy
和其他一些不太小的库。
The current way manage my projects: I have pyenv
and pyenv-virtualenv
installed.当前管理我的项目的方式:我安装了
pyenv
和pyenv-virtualenv
。 I have a few (currently 4) specific virtualenvs
that each cater to a type of project.我有几个(目前4)具体
virtualenvs
每个迎合类型的项目。 The projects themselves have .pyenv-version
set, I have the autoload virtualenv feature of pyenv
enabled.项目本身设置了
.pyenv-version
,我启用了pyenv
的自动加载 virtualenv 功能。 If I need to share a project, I generate a requirements.txt
with pip freeze -l
from the virtualenv
.如果我需要共享一个项目,我会使用
pip freeze -l
从virtualenv
生成一个requirements.txt
。
So in my current setup, I have X
number of projects and Y, Y << X
number of virtualenvs
, all amounting to a few GB of harddisk space.因此,在我当前的设置中,我有
X
个项目和Y, Y << X
个virtualenvs
,总共有几 GB 的硬盘空间。 Note that because of large libraries like numpy
each of the virtualenvs
are pretty big, around 700-900 MB.请注意,由于像
numpy
这样的大型库,每个virtualenvs
都非常大,大约 700-900 MB。
My question:我的问题:
As far as I understand, pipenv
will, by default create a virtualenv
for all of my projects, so the harddisk space taken up by my virtualenvs
would increase considerably.据我了解,
pipenv
默认情况下会为我的所有项目创建一个virtualenv
,因此我的virtualenvs
占用的硬盘空间会大大增加。 What I'm interested in is:我感兴趣的是:
pipenv
environments across several projects, that use exactly the same dependencies?pipenv
环境? ie multiple pipenv
configs that load the same virtualenv
?virtualenv
多个pipenv
配置?pipenv
config files from a virtualenv
I set up with pyenv
?pyenv
设置的virtualenv
生成pipenv
配置文件? ie I would not use pipenv
to actually run my projects, I would not create any virtualenvs
with pipenv
, but I would create pipenv
config files for sharing the project (in this case, probably along side a requirements.txt
as well).pipenv
实际运行我的项目,我不会创建任何virtualenvs
与pipenv
,但我会创造pipenv
配置文件共享项目(在这种情况下,可能沿着侧requirements.txt
为好)。 edit : I rewrote most of the question to make it clearer.编辑:我重写了大部分问题以使其更清楚。
pipenv
doesn't seem to be a good fit for your specific workflow because it's project-centric rather than environment-centric. pipenv
似乎不太适合您的特定工作流程,因为它以项目为中心而不是以环境为中心。 pipenv
treats a virtual environment as volatile and reserves the right to alter it freely if circumstances call for it. pipenv
将虚拟环境视为易变的,并保留在情况需要时自由更改它的权利。 You can use it but in the case of alterations to your environments, it will be a pain to keep all projects synchronized due to pipenv
's stricter scrunity.您可以使用它,但在更改环境的情况下,由于
pipenv
更严格的审查,保持所有项目同步将是一件痛苦的事情。
You can explicitly specify a virtual environment for pipenv
to use for a project by creating a .venv
file in the project root with a path to it (normally, virtualenvs are created in a specific location with autogenerated names that include a hash of the path to the project).您可以通过在项目根目录中创建一个带有路径的
.venv
文件来明确指定pipenv
用于项目的虚拟环境(通常,virtualenvs 是在特定位置创建的,其自动生成的名称包含路径的哈希值)该项目)。 This seems to be undocumented.这似乎是无证的。
However, pipenv
, unlike virtualenv
, checks and enforces that the virtual environment has the exact set of modules satisfying conditions in Pipfile
and the exact "last tested configuration" specified in a generated Pipfile.lock
.但是,
pipenv
与virtualenv
不同,它检查并强制虚拟环境具有满足Pipfile
条件的确切模块集以及生成的Pipfile.lock
指定的确切“上次测试配置”。
Pipfile
from requirements.txt
, it will specify exact package versions and include all dependencies -- while by design, it's supposed to contain more intelligent information.requirements.txt
生成Pipfile
,它将指定确切的包版本并包含所有依赖项—— 而根据设计,它应该包含更智能的信息。 So, if you change any package version in an environment, you'll need to:因此,如果您更改环境中的任何软件包版本,则需要:
Pipfile.lock
s in affected projects (eg copy the changed one).Pipfile.lock
(例如复制更改的项目)。 With a generated Pipfile
, you may get away with deleting them instead.Pipfile
,您Pipfile
删除它们。Pipfile
s in affected projects to the new package versions (eg copy the changed one) if there was a changePipfile
更新为新的包版本(例如复制更改的版本)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.