如何理解 makefile 和 python

发布于 2024-09-18 00:51:10 字数 530 浏览 15 评论 0原文

我试图了解 makefile 如何将一些 .ui 文件编译为 .py (PyQt -> Python)。这是我正在使用的自动生成的 makefile:

# Makefile for a PyQGIS plugin 
UI_FILES = Ui_UrbanAnalysis.py

RESOURCE_FILES = resources.py

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

%.py : %.qrc
    pyrcc4 -o $@  $<

%.py : %.ui
    pyuic4 -o $@ $<

当我键入:

$ make

我收到以下消息:

make: *** No rule to make target `compile', needed by `default'.  Stop.

我做错了什么?

谢谢。

I'm trying to understand how a makefile works for compiling some .ui files to .py (PyQt -> Python). This is the makefile that I am using that was autogenerated:

# Makefile for a PyQGIS plugin 
UI_FILES = Ui_UrbanAnalysis.py

RESOURCE_FILES = resources.py

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

%.py : %.qrc
    pyrcc4 -o $@  
lt;

%.py : %.ui
    pyuic4 -o $@ 
lt;

When I type:

$ make

I get the following message:

make: *** No rule to make target `compile', needed by `default'.  Stop.

What am I doing incorrectly?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

匿名。 2024-09-25 00:51:10

并不是说我知道您想要实现的构建步骤,但是这两行:

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

看起来像目标行,因此它们可能应该是:

default: compile

compile: $(UI_FILES) $(RESOURCE_FILES)

因为 make 可能正在尝试解释 compile:... 行作为不会执行任何操作的操作,并且意味着没有 compile 目标。


另一件事,您可能想用来

PHONY: default compile

告诉 make 这些是抽象目标并且不代表文件。就像良好的实践一样。

Not that I know the build steps you are trying to achieve, but both of these lines:

default: compile
    compile: $(UI_FILES) $(RESOURCE_FILES)

look like target lines, so they should probably be:

default: compile

compile: $(UI_FILES) $(RESOURCE_FILES)

As it was make is probably trying to interpret the compile:... line as an action which won't do anything and means that there is no compile target.


One more thing, you might want to use

PHONY: default compile

to tell make that these are abstract targets and do not represent files. Just as a matter of good practice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文