TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Pip.wtf: Inline dependencies for small Python scripts

57 pointsby forgottoflossover 1 year ago

5 comments

Flimmover 1 year ago
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 未加载
deividover 1 year ago
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>
diarrheaover 1 year ago
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 未加载
greenshover 1 year ago
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_ireover 1 year ago
Cool. I&#x27;m surprised this didn&#x27;t exist earlier.<p>Now someone upload it to pypi for even more hilarity.
评论 #38390376 未加载