TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Makefile Tricks for Python Projects

84 点作者 celadevra_大约 2 年前

14 条评论

theptip大约 2 年前
Don’t do this… unless you have a very specific and non-standard usecase that requires it, like the author:<p>&gt; I work using git worktrees to have multiple branches checked out at the same time. By using this trick, I can run different commands and make sure the imported package is from that branch, instead of having to python3 -m pip install -e . around all the packages<p>For most usecases, you can wire up your imports and script entry points in poetry, and manage venvs there too. Or just use pyenv-virtualenv if you’re on MacOS to auto-use your per-project venv.<p>Again, the author&#x27;s requirements here are quite esoteric in my experience, and I’d really encourage folks to avoid this particular can of worms if at all possible.
评论 #36097041 未加载
评论 #36096776 未加载
potyarkin大约 2 年前
Similar in spirit, I made a reusable Makefile for my Python projects: <a href="https:&#x2F;&#x2F;github.com&#x2F;sio&#x2F;Makefile.venv">https:&#x2F;&#x2F;github.com&#x2F;sio&#x2F;Makefile.venv</a><p>It&#x27;s a shame that Python venv workflow is so opaque and unfriendly to new users that it requires extra automation tools.
评论 #36096603 未加载
Groxx大约 2 年前
There are quite a few things here that I&#x27;ve used for a few years with option projects at work - overall I like it.<p>A big part of that is due to an endless stream of people who couldn&#x27;t be bothered to learn what a venv was or how to use it, but... yeah, that&#x27;s what work is like sometimes. The makefile pretty much ended those issues, absolutely worth the effort put into it.
GloomyBoots大约 2 年前
I recently discovered just (<a href="https:&#x2F;&#x2F;just.systems" rel="nofollow">https:&#x2F;&#x2F;just.systems</a>), a make alternative that’s much more ergonomic IMO, and have been using it in my personal projects. It’s task-oriented, not goal-oriented, so not a perfect replacement, but works well for my needs.
评论 #36096401 未加载
markrages大约 2 年前
I remember when Python was simple.
评论 #36096838 未加载
maxs大约 2 年前
I prefer to stay in python, makefiles become very difficult to maintain. I use <a href="https:&#x2F;&#x2F;www.pyinvoke.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.pyinvoke.org&#x2F;</a>
teo_zero大约 2 年前
<p><pre><code> &gt; The reason to use $$(some-command) instead of the built-in function $(shell some-command) is that the expression will be evaluated every time it is called. [...] When using $(shell ...) the expression gets evaluated only once and reused across all the recipes. </code></pre> I don&#x27;t think the last sentence is true. As long as you define py using = and not := it will be evaluated every time it&#x27;s used.
BiteCode_dev大约 2 年前
Or use <a href="https:&#x2F;&#x2F;pydoit.org" rel="nofollow">https:&#x2F;&#x2F;pydoit.org</a> and a virtualenv and be happy.
评论 #36095997 未加载
评论 #36093177 未加载
p5a0u9l大约 2 年前
I’ve used make like this in the past, it’s handy. But zsh auto suggestion obviates the extra maintenance IMO. I type the command one time and it’s in my history. So my common dev actions are more flexibly maintained by recency than editing a file.<p>You could say the Makefile also serves as a form of (not great) documentation.
评论 #36096316 未加载
zelphirkalt大约 2 年前
I use Makefiles for managing multiple venvs for various jobs. For example running test and running in production have different requirements (no testing libraries). Or an environment for static analysis tools.
asicsp大约 2 年前
See also: &quot;Automate your Python project with Makefile&quot; <a href="https:&#x2F;&#x2F;antonz.org&#x2F;makefile-automation&#x2F;" rel="nofollow">https:&#x2F;&#x2F;antonz.org&#x2F;makefile-automation&#x2F;</a>
gigatexal大约 2 年前
I love this. Thanks for introducing me to so many things in make I didn’t know existed and doing so in a manner than is understandable. Kudos
nologic01大约 2 年前
well, if Python ends up subsumed into Mojo then Pythonistas might as well learn how to <i>build</i> their code :-)
waynesonfire大约 2 年前
Is there a Makefile trick to gpg sign a python package? I think the Python community would find that useful.
评论 #36095752 未加载