只有在requirements.txt更改时,如何才能运行目标make install
?使用Makefile安装python requirements.txt only requirements.txt已更改
我不想每次升级包,当我做make install
我找到了一些解决方法通过创建假的文件_requirements.txt.pyc
但丑陋和脏。它会拒绝安装PIP要求第二次因为requirements.txt没有变化
$ make install-pip-requirements
make: Nothing to be done for 'install-pip-requirements'.
但我的目标是要做到:
# first time,
$ make install # create virtual environment, install requirements
# second time
$ make install # detected and skipping creating virtual env,
# detect that requirements.txt have no changes
# and skipping installing again all python packages
make: Nothing to be done for 'install'.
Python包的样子:
.
├── Makefile
├── README.rst
├── lambda_handler.py
└── requirements.txt
我使用文件,Makefile
,用于python中的一些自动化:
/opt/virtual_env:
# create virtual env if folder not exists
python -m venv /opt/virtual_env
virtual: /opt/virtual_env
# if requirements.txt is modified than execute pip install
_requirements.txt.pyc: requirements.txt
/opt/virtual_env/bin/pip install -r --upgrade requirements.txt
echo > _requirements.txt.pyc
requirements: SOME MAGIG OR SOME make flags
pip install -r requirements.txt
install-pip-requirements: _requirements.txt.pyc
install: virtual requirements
我相信
必须这样做更好的方法
;)
你能更详细地解释你的python包的外观吗?你使用任何类型的Python项目模板?你为什么用'sudo'运行make?为@ovanes更新了 – ovanes
,添加了文件夹树,并删除了sudo,因为与问题无关(假设我是root)。 –