43 karma · joined April 24, 2022
For example, you can install oscclip to a temp dir with a dedicated venv and run it immediately:
$ pipx run --spec 'oscclip @ git+https://github.com/rumpelsepp/oscclip' osc-copy --help
Or install it more permanently: $ pipx install 'oscclip @ git+https://github.com/rumpelsepp/oscclip'
My own Zsh frontend for managing Python venvs and deps, zpy, makes use of pip-tools to accomplish the same, with its pipx clone, pipz: $ pipz runpkg 'oscclip @ git+https://github.com/rumpelsepp/oscclip' osc-copy --help
$ pipz install 'oscclip @ git+https://github.com/rumpelsepp/oscclip'---
Disclaimer before I continue with my own suggestions: I have made small code contributions to pip and pip-tools, and maintain a Zsh frontend to pip-tools+venv, called zpy.
---
Suggestions:
- each folder of code maps to its own default venv, and may map to more venvs for different Python runtimes
- each folder of code has a requirements.in file with top-level dependencies, and a requirements.txt as a lock file
- you can either add a shebang line for your script which explicitly invokes the venv's Python and link that file into ~/.local/bin/, or instead create an external launcher script in ~/.local/bin/.
---
Here's an example of how that might be done using zpy functions:
$ mkdir simple-scripts
$ cd simple-scripts
$ envin # or in subcommand form: zpy envin
==> creating -> ~/.local/share/venvs/280…/venv :: ~/Code/simple-scripts
$ pipacs httpx
==> appending -> requirements.in :: ~/Code/simple-scripts
httpx
==> compiling requirements.in -> requirements.txt :: ~/Code/simple-scripts
anyio==3.6.2 # via httpcore
certifi==2022.12.7 # via httpcore, httpx
h11==0.14.0 # via httpcore
httpcore==0.16.3 # via httpx
httpx==0.23.3 # via -r requirements.in
idna==3.4 # via anyio, rfc3986
rfc3986==1.5.0 # via httpx
sniffio==1.3.0 # via anyio, httpcore, httpx
==> syncing requirements.txt -> env :: ~/Code/simple-scripts
$ print -rl -- 'from httpx import get' 'print(get("https://ifconfig.co/json").json())' >do_it.py
$ vpyshebang do_it.py # or: zpy vpyshebang do_it.py
$ ln -s $PWD/do_it.py ~/.local/bin/do_it
If a Python runtime update breaks your venvs, you can probably fix things up using zpy's pipup function.If you ever want to use it as a pre-format to generate either TOML, JSON, or YAML, I used the official reference implementation to make a CLI converter between them and NestedText.
When generating one of these formats, you can use yamlpath queries to concisely but explicitly apply supported types to data elements.
- My CLI converter: https://github.com/AndydeCleyre/nestedtextto
- yamlpath info: https://github.com/wwkimball/yamlpath/wiki/Search-Expression...
I'm very happy to answer any questions about it right here or as GitHub issues.
If you want to play around with it, I made NestedTextTo (nt2 on PyPI), for CLI conversion between NestedText and YAML, TOML, or JSON, with a pretty cool (IMO) way to cast value types along the way.
https://nestedtext.org/en/stable/ (not my project)
https://github.com/AndydeCleyre/nestedtextto (my project)
Pip-tools is also a bit lower level, offering flexibility and compatibility which I relish, but also requiring more attention from the user to set things up as they wish.
If you or anyone else enjoying pip-tools is a Zsh user and interested in trying out my higher level functions to ease interactive use of pip-tools, venvs, and also isolated app installs (like pipx), I would love some feedback on zpy: https://github.com/AndydeCleyre/zpy
I'm very happy to answer any questions about it right here or as GitHub issues.
- jello (PyPI) - yamlpath (PyPI) - dasel
> Bash is powerful and always available
As someone who often works with Alpine Linux, this is an annoyingly popular myth.
It's an attempt to do this from outside the house.