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.

PEP 723 – Embedding pyproject.toml in single-file scripts – peps.python.org

69 pointsby Chmouelalmost 2 years ago

8 comments

woodruffwalmost 2 years ago
For some additional context: PEP 722[1] proposes a similar technique, but only for the script&#x27;s requirements (and not the full TOML-formatted package metadata).<p>[1]: <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>
评论 #37027014 未加载
adamckayalmost 2 years ago
This will be useful, and definitely handy when sharing random scripts with a defined structure for its requirements. I&#x27;ve struggled to give scripts to non-developers to run recently and between getting them to configure a virtualenv and install dependencies by hand to using `pipx` it&#x27;s been a pain so hopefully this will alleviate some if it in the future.<p>Not sure, however, that I buy the argument that it&#x27;s going to be simpler for non-programmers to use TOML embedded inside a multiline string versus using something along the lines of requirements.txt - there&#x27;s going to be absolutely zero syntax highlighting so things like missing quotes or bracket&#x27;s will need to be carefully identified.<p>There&#x27;s also going to be inevitable differences between `__pyproject__` and `pyproject.toml` which could lead to more confusion, such as the `readme` key - that&#x27;s likely to be useful to include some help information alongside your script so it&#x27;s self documenting, but in `pyproject.toml` it must refer to another file and in `__pyproject__` I&#x27;d assume it can itself be a multiline string..?
SushiHippiealmost 2 years ago
Is there a reason, why the __pyproject__ variable is not a dict but a toml string?
评论 #37026416 未加载
评论 #37027353 未加载
评论 #37026414 未加载
评论 #37029146 未加载
theanonymousonealmost 2 years ago
Will it be part of the Python distribution (3.12?) or a specification for an independent package? Is there already an implementation, apart from the GitHub repository referenced in the article?
noirscapealmost 2 years ago
One thing I don&#x27;t quite get is why the proposal here is so insistent on triple quoted strings only. Shouldn&#x27;t a \n formatted string also be considered valid? Its practically just a string after all.<p>Other than that, this isn&#x27;t a bad proposal. Generally for single-file scripts, figuring out the imports isn&#x27;t too difficult but you do have the occasionally weirdly named pypi package vs installed import package.
评论 #37032407 未加载
评论 #37032398 未加载
thenipperalmost 2 years ago
This would be really great. I could see if pairing well with a tool like pipx for quickly sharing utility scripts.
thatxlineralmost 2 years ago
That’s funny because literally today I wrote a script runner that implements PEP 722
qrianalmost 2 years ago
It&#x27;s interesting that they tested for AI code completion compatibility. It makes sense as AI code completion is now a big part of tooling and standards should accomodate for common tools.
评论 #37028684 未加载