3 ms·
Yes, I've used shiv and PEX in the past, and I love those. But that means "adding a build step". Also, as far as I understand, by default, those tools normally
by polyrand 3y ago
Yes, I've used shiv and PEX in the past, and I love those. But that means "adding a build step". Also, as far as I understand, by default, those tools normally decompress the generated zip file on startup, but the decompressed artefacts have to be manually cleaned.
I think they are worth for more complex apps (I actually have a draft blog post with some experiments I did using PEX + gunicorn), but for my use case, it's not worth the effort when I only need the standard library.
- networked 3y agoYou can try https://github.com/jaraco/pip-run https://github.com/jaraco/pip-run or https://github.com/PyAr/fades https://github.com/PyAr/fades (or eventually pipx: https://github.com/pypa/pipx/issues/913 https://github.com/pypa/pipx/issues/913). They don't require a build step. For example, #! /usr/bin/env -S pip-run Jinja2==3.* from jinja2 import Environment env = Environment(autoescape=True) template = env.from_string("Hello, {{ name }}!") print(template.render(name="world")) There is a downside. Because pip-run recreates the virtualenv every time, the script takes a second to start up. pipx will cache virtualenvs once the single-file script feature is released. I haven't used fades yet. Edit: fades caches virtualenvs. #! /usr/bin/env fades from jinja2 import Environment # fades Jinja2==3.* env = Environment(autoescape=True) template = env.from_string("Hello, {{ name }}!") print(template.render(name="world"))