Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可以在Makefiles中剪切依赖链吗?_Makefile_Gnu Make - Fatal编程技术网

可以在Makefiles中剪切依赖链吗?

可以在Makefiles中剪切依赖链吗?,makefile,gnu-make,Makefile,Gnu Make,我有以下生成文件(简化): #如何指定 #(a)如果(且仅当)任何.txt文件已更改,但 #(b)如果文件中的任何*.s已更改,则不触发重新编译? #安装:??? # ??? #这可能会触发重新编译 install1:requirements/*.txt 对于requirements/*.txt中的reqs;执行pip安装-r$$reqs;完成 pip冻结>安装1 #即使未修改需求/*txt,也会触发安装 第2期: 触摸要求/*.txt 安装1 #将requirements.in编译为req

我有以下生成文件(简化):

#如何指定
#(a)如果(且仅当)任何.txt文件已更改,但
#(b)如果文件中的任何*.s已更改,则不触发重新编译?
#安装:???
#   ???
#这可能会触发重新编译
install1:requirements/*.txt
对于requirements/*.txt中的reqs;执行pip安装-r$$reqs;完成
pip冻结>安装1
#即使未修改需求/*txt,也会触发安装
第2期:
触摸要求/*.txt
安装1
#将requirements.in编译为requirements.txt
编译:requirements/*.txt
requirements/%.txt:requirements/%.in
pip编译--升级--无注释$<
  • make compile
    (重新)将文件中的任何修改的
    。编译到相应的
    .txt
  • make install
    应(重新)安装
    .txt
    文件中的需求,只要其中任何一项发生更改,但应忽略将触发重新编译的
    文件中对
    .in的更改。上述
    install1
    install2
    目标均不满足这两个标准。这有可能吗

我认为make无法有效地处理两个..嗯。。独立的依赖树,至少如果它们是用模式规则静态定义的,就不会。没有办法知道哪个规则应该是哪个树的一部分。您可能会为每个主要目标包含一组不同的依赖性声明。您不使用
pip-sync
有什么原因吗?这似乎是保持virtualenv最新的需求列表的方法。作为机器间同步过程的一部分,我会自动对我的项目venvs运行它,即使需求文件没有更改。@jamesc
pip sync
是一个不错的选择,如果您有一个可以就地更新的可变虚拟环境,但对于不可变的环境(例如docker容器)来说就不是这样了。除了上面的
安装
目标是其他几个开发任务(例如运行测试或迁移)的先决条件,如果没有任何变化,理想情况下不会触发
pip同步
,那么您在docker中运行?在这种情况下,你能阐明你的目标吗?听起来,当需求发生变化时,您希望重新创建docker层,是这样吗?
# how to specify an install target that
# (a) installs the requirements if (and only if) any .txt file has changed but
# (b) without triggering recompilation if any *.in file has changed?

#install: ???
#   ???

# this may trigger recompilation
install1: requirements/*.txt
    for reqs in requirements/*.txt; do pip install -r $$reqs; done
    pip freeze > install1

# this always triggers installation even if requirements/*txt have not been modified
install2: 
    touch requirements/*.txt
    make install1

# compile requirements.in to requirements.txt
compile: requirements/*.txt

requirements/%.txt: requirements/%.in 
    pip-compile --upgrade --no-annotate $<