3 ms·
You can go a step further and have scripts runnable from anywhere without cloning any repo or setting up any venv, directly from PyPi: when you package your lib
by d4rkp4ttern 2y ago
You can go a step further and have scripts runnable from anywhere without cloning any repo or setting up any venv, directly from PyPi: when you package your lib called `mylib`, define cli scripts under [project.scripts] in your pyproject.toml,
[project.scripts]
mytool = "path.to.script:main"
and publish to PyPi. Then anyone can directly run your script via
uvx --from mylib mytool
As an example, for Langroid (an open-source agent-oriented LLM lib), I have a separate repo of example scripts `langroid-examples` where I've set up some specific scripts to be runnable this way:
https://github.com/langroid/langroid-examples?tab=readme-ov-file#run-scripts-with-no-repo-cloning-no-venv-setup https://github.com/langroid/langroid-examples?tab=readme-ov-...
E.g. to chat with an LLM
uvx --from langroid-examples chat --model ollama/qwen2.5-coder:32b
or chat with LLM + web-search + RAG
uvx --from langroid-examples chatsearch --model groq/llama-3.3-70b-versatile
- stavros 2y agoHm, I think you can just run something with 'uvx <name>' and it'll download and run it, am I misremembering? Maybe it's only when the tool and the lib have the same name, but I think I remember being able to just run 'uvx parachute'.
- d4rkp4ttern 2y agoYou're right, that's only when the tool and lib have the same name. In my case, I have several example scripts that I wanted to make runnable via a single examples lib
- stavros 2y agoThat's a really useful tip, thank you!