Skip to content

Commit 6665d02

Browse files
committed
Introduce uv
1 parent 37f16c9 commit 6665d02

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

content/packaging.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,43 @@ These are the 3 files:
5151
.. literalinclude:: packaging-example-project/calculator/integrating.py
5252
:caption: integrating.py
5353

54+
55+
56+
57+
58+
Initializing the package
59+
^^^^^^^^^^^^^^^^^^^^^^^^
60+
61+
.. note::
62+
63+
In this part of the episode, we will introduce a *package build tool* called uv_ to
64+
initialize, build and publish the package.
65+
This choice is purely out of convenience there are numerous similar
66+
tools [1]_, which can be used interchangeably [2]_. We will soon see that the
67+
resulting package is `pip`-installable without using uv_.
68+
69+
To install uv, the preferred method is to use the
70+
`standalone installer provided here <https://docs.astral.sh/uv/getting-started/installation/#installation-methods>`__.
71+
Alternatively you can obtain ``uv`` via ``pip install uv`` or
72+
``conda install -c conda-forge uv`` [3]_.
73+
74+
75+
.. _uv: https://docs.astral.sh/uv/
76+
.. _pdm: https://pdm-project.org/en/latest/
77+
.. _hatch: https://hatch.pypa.io/
78+
.. _flit: https://flit.pypa.io/en/stable/
79+
80+
81+
Create a new folder with the name ``calculator-myname`` (replace with *myname* with your name),
82+
open terminal and run:
83+
84+
.. code-block:: console
85+
86+
$ uv init --lib
87+
$ uv init --lib --python 3.10 --no-pin-python
88+
89+
This result in the following set of files.
90+
5491
We will add a fourth file:
5592

5693
.. literalinclude:: packaging-example-project/calculator/__init__.py
@@ -412,3 +449,8 @@ for publishing your packages.
412449
you are using it.
413450
- PyPI is a place for Python packages
414451
- conda is similar but is not limited to Python
452+
453+
.. [1] In 2025, tools such as pdm_, hatch_, flit_ have similar functionality as uv_.
454+
.. [2] Some package build tools are simple and some have advanced features. Refer to
455+
`pyOpenSci's guide on the choosing the right tool <https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-build-tools.html>`__
456+
.. [3] `uv` is also included in the conda environment you have created in :doc:`software installation <installation>` episode.

software/environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- twine
1818
- poetry
1919
- flit
20+
- uv
2021
- scikit-learn
2122
- scalene
2223
- ruff

0 commit comments

Comments
 (0)