Skip to content

Commit 29cfed8

Browse files
committed
Document package build and installation with uv
1 parent 2f7ed60 commit 29cfed8

1 file changed

Lines changed: 74 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,77 @@ Adds dependencies required by the project.
3939
uv run pytest
4040
```
4141

42-
Runs the tests using the project's environment.
42+
Runs the tests using the project's environment.
43+
44+
## 6. GitHub Actions CI
45+
46+
Created a workflow in `.github/workflows/ci.yml` to install dependencies, run tests and build the package.
47+
48+
## 7. CI matrix
49+
50+
Tested the project on multiple operating systems and Python versions:
51+
52+
- OS: Ubuntu, Windows, macOS
53+
- Python: 3.12, 3.13
54+
55+
Results: all 6 jobs passed.
56+
57+
## 8. Build the package
58+
59+
```bash
60+
uv build
61+
```
62+
63+
Creates two distributions in the `dist/` directory:
64+
65+
- `hello_uv-0.1.0.tar.gz`: source distribution (sdist).
66+
- `hello_uv-0.1.0-py3-none-any.whl`: wheel.
67+
68+
Inspect the wheel content:
69+
70+
```bash
71+
unzip -l dist/hello_uv-0.1.0-py3-none-any.whl
72+
```
73+
74+
The wheel contains the package source code and metadata, but not the dependencies themselves.
75+
76+
## 9. Create a separate user environment
77+
78+
Create a new directory outside the project to simulate a user installing the package.
79+
(hello_uv_user)
80+
```bash
81+
uv venv --python 3.12
82+
source .venv/bin/activate
83+
```
84+
85+
## 10. Install the package
86+
87+
Install the wheel in the new environment:
88+
89+
```bash
90+
uv pip install ../hello_uv/dist/hello_uv-0.1.0-py3-none-any.whl
91+
```
92+
93+
Observations:
94+
95+
- `hello_uv` and its runtime dependencies (`xarray`, `numpy`, `requests`) are installed.
96+
- Transitive dependencies are installed automatically.
97+
- Development dependencies such as `pytest` are not installed.
98+
99+
## 11. Test the installed package
100+
101+
```bash
102+
python -c "from hello_uv import hello_world; print(hello_world())"
103+
```
104+
105+
Result:
106+
107+
```text
108+
Hello, World!
109+
```
110+
111+
## 12. Key takeaways
112+
113+
- `uv build`: builds the package using `uv_build`.
114+
- `uv add`: adds a dependency to a project and updates `pyproject.toml` and `uv.lock`.
115+
- `uv sync`: synchronizes the project environment with its lockfile.

0 commit comments

Comments
 (0)