UV package & Commands
-
[x] Make a list of commands and what they do
-
[x] tested uv install python
uv python find > lead to surprise of finding 3.9 to 3.11 all of which are under
/home/uberdev/.local/share/uv/python/
uv python install 3.9 > installs in above path
uv python uninstall 3.9 > deletes it from the path
- [x] tested uv run
uv run example.py > exec the script
uv run —no-project script.py > ignores the pjt environment, doesn’t take your OS environ also
- [x] uv add tested
uv add —srcipt example.py ‘pandas’ > this adds the ‘pandas’ on top of the script.py
uv add pandas > adds pandas to pyproject.toml
- [x] tested uv lock
uv lock > just uv.lock in the folder
uv lock —script script.py > has to add script.py.lock (ensure uv self update is executed)
- [x] tested uv tree
uv tree > provides dep tree on the project
uv tree —script script.py > provide dep tree on the script alone
- [x] Understand project structure
uv init > creates the project structure
uv sync > updates the .venv with the packages, however pip freeze shows all the packages in the system, which is not correct.
- When executed ‘python script.py’, if the package is not in pyproject.toml then it throws error
- [ ] Understand how distribution works
Python projects are typically distributed as both source distributions (sdists) and binary distributions (wheels). The former is typically aÂ
.tar.gz
 orÂ.zip
 file containing the project's source code along with some additional metadata, while the latter is aÂ.whl
 file containing pre-built artifacts that can be installed directly.uv build —sdist > builds tar.gz build files
uv build —wheel > build binary .whl file
uv build > gives both into ./dist folder
- [ ] Understandin entry points
https://docs.astral.sh/uv/concepts/projects/config/#entry-points
[project.scripts]
hello = "example:hello"
uv run hello > will execute the hello() function
The above did not work, then a bit of digging found below
https://docs.astral.sh/uv/concepts/projects/init/#applications
The projects are created in a fashion to be packaged or to be used as app
uv init —app testapp
which creates the tree like below
testapp ├── main.py ├── pyproject.toml └── README.md
When you want the package like those you see in mcp servers
uv init —package testpkg
testpkg/ ├── pyproject.toml ├── README.md └── src └── testpkg └── init.py
With the above understanding pushing to the pypi is for another day altogether
https://packaging.python.org/en/latest/guides/section-build-and-publish/