pipenv:部署工作流
我正在考虑从 pip & 切换virtualenv 到 pipenv.但是在研究了文档之后,我仍然对 pipenv 的创建者如何构建部署工作流程一无所知.
I am thinking about switching from pip & virtualenv to pipenv. But after studying the documentation I am still at a loss on how the creators of pipenv structured the deployment workflow.
例如,在开发中我有一个 Pipfile
&定义环境的 Pipfile.lock
.使用我想部署的部署脚本
For example, in development I have a Pipfile
& a Pipfile.lock
that define the environment. Using a deployment script I want to deploy
-
git pull
通过 Github 到生产服务器 -
pipenv install
在部署用户的主目录中创建/刷新环境
-
git pull
via Github to production server -
pipenv install
creates/refreshes the environment in the home directory of the deployment user
但我需要一个特定目录中的venv,该目录已经在systemd或supervisor中配置.例如:command=/home/ubuntu/production/application_xy/env/bin/gunicorn module:app
But I need a venv in a specific directory which is already configured in systemd or supervisor. E.g.: command=/home/ubuntu/production/application_xy/env/bin/gunicorn module:app
pipenv 在某些位置创建 env,例如/home/ultimo/.local/share/virtualenvs/application_xy-jvrv1OSi
pipenv creates the env in some location such as
/home/ultimo/.local/share/virtualenvs/application_xy-jvrv1OSi
使用 pipenv
部署应用程序的预期工作流程是什么?
What is the intended workflow to deploy an application with pipenv
?
您几乎没有选择.
你可以通过
pipenv run
运行你的gunicorn:
You can run your gunicorn via
pipenv run
:
pipenv 运行 gunicorn 模块:app
这会产生轻微的开销,但优点是还可以从 $PROJECT_DIR/.env
(或其他 $PIPENV_DOTENV_LOCATION
)加载环境.
This creates a slight overhead, but has the advantage of also loading environment from $PROJECT_DIR/.env
(or other $PIPENV_DOTENV_LOCATION
).
您可以设置
PIPENV_VENV_IN_PROJECT
环境变量.这会将 pipenv 的 virtualenv 保存在$PROJECT_DIR/.venv
而不是全局位置.
You can set the
PIPENV_VENV_IN_PROJECT
environment variable. This will keep pipenv's virtualenv in$PROJECT_DIR/.venv
instead of the global location.
您可以使用现有的 virtualenv 并从中运行 pipenv.如果 Pipenv 从一个虚拟环境运行,它不会尝试创建自己的虚拟环境.
You can use an existing virtualenv and run pipenv from it. Pipenv will not attempt to create its own virtualenv if it's run from one.
你可以使用奇怪的 pipenv 创建的 virtualenv 路径.
You can just use the weird pipenv-created virtualenv path.