【发布时间】:2021-10-13 04:48:58
【问题描述】:
我正在通过 Makefile 运行一些命令,我必须创建一个新的 python virtualenv,激活它并在一个 Make recipe/goal 中安装要求,然后在运行其他 recipe/goal 之前重用它,但问题是,我必须像这样在每个后续的 Make Goal 中激活该环境
SHELL := bash
# For Lack of a better mechanism will have to activate the venv on every Make recipe because every step is in its own shell
.ONESHELL:
install:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
test: install
source .venv/bin/activate
pytest
synth: install
source .venv/bin/activate
cdk synth --no-color
diff: install
source .venv/bin/activate
cdk diff --no-color
bootstrap: install
source .venv/bin/activate
cdk bootstrap --no-color
deploy: install
source .venv/bin/activate
cdk deploy --no-color
.PHONY: install test synth diff bootstrap deploy
有没有更好的方法来做到这一点,即让我不必在每个目标上都做source .venv/bin/activate?
换句话说,我基本上可以在同一个 SHELL 中的 Makefile 中运行所有 make 目标吗?
【问题讨论】: