PEP 722: Dependency specification for single-file scripts

I’ve been exploring making a basic tool to launch scripts based on this specification, plus a non-standard x-requires-python block that gets used with ‘pyenv’ or ‘py’ to find the appropriate python executable. (I probably won’t make it build the appropriate Python with pyenv if it’s missing, but I may make it output the command you would need).

With respect to a proposed TOML based format from a merged proposal I’d note that despite implementing this in Python I’ve tried to make the time from start to running a script when a cached venv can be used as fast as possible[1] and just by importing a toml parser library this takes twice as long before doing any parsing[2]. This probably doesn’t matter if you’ve decided to implement such a thing in rust, and you may consider the overall time to still be small enough not to care, but I did want to point it out.


  1. This is somewhat limited by the launch time of Python itself, but it’s easy to make it much slower by importing certain modules. ↩︎

  2. I tested rtoml, pytomlpp, tomllib and tomlkit on my hardware - 2x was the best case. ↩︎

5 Likes