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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Pip.wtf: Inline dependencies for small Python scripts

57 点作者 forgottofloss超过 1 年前

5 条评论

Flimm超过 1 年前
A development version of pipx supports a feature that address this pain point. See pull request #916 [1]<p>In your script <i>example.py</i>, you would specify your dependencies in a special comment like this:<p><pre><code> # Requirements: # requests import requests ... </code></pre> Then you could run the script like this:<p><pre><code> pipx run file:example.py </code></pre> This would install the dependencies in a temporary virtual environment, and run the script in that virtual environment.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;pypa&#x2F;pipx&#x2F;pull&#x2F;916">https:&#x2F;&#x2F;github.com&#x2F;pypa&#x2F;pipx&#x2F;pull&#x2F;916</a>
评论 #38397483 未加载
deivid超过 1 年前
Why not use something like shiv[0]? You can bundle all your dependencies into one file and distribute that.<p>[0] <a href="https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;shiv&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;shiv&#x2F;</a>
diarrhea超过 1 年前
I was going to mention that an official solution to this problem is around the corner, but the corresponding PEP has been rejected. Anyone know what happened there?<p><a href="https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0722&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;peps.python.org&#x2F;pep-0722&#x2F;</a>
评论 #38390290 未加载
greensh超过 1 年前
nix can do something similar via nix shell <a href="https:&#x2F;&#x2F;nixos.org&#x2F;manual&#x2F;nix&#x2F;stable&#x2F;command-ref&#x2F;nix-shell.html#use-as-a--interpreter" rel="nofollow noreferrer">https:&#x2F;&#x2F;nixos.org&#x2F;manual&#x2F;nix&#x2F;stable&#x2F;command-ref&#x2F;nix-shell.ht...</a>
评论 #38393349 未加载
extraduder_ire超过 1 年前
Cool. I&#x27;m surprised this didn&#x27;t exist earlier.<p>Now someone upload it to pypi for even more hilarity.
评论 #38390376 未加载