Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions content/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,43 @@
.. literalinclude:: packaging-example-project/calculator/integrating.py
:caption: integrating.py





Initializing the package
^^^^^^^^^^^^^^^^^^^^^^^^

.. note::

In this part of the episode, we will introduce a *package build tool* called uv_ to
initialize, build and publish the package.
This choice is purely out of convenience there are numerous similar
tools [1]_, which can be used interchangeably [2]_. We will soon see that the
resulting package is `pip`-installable without using uv_.

To install uv, the preferred method is to use the
`standalone installer provided here <https://docs.astral.sh/uv/getting-started/installation/#installation-methods>`__.
Alternatively you can obtain ``uv`` via ``pip install uv`` or
``conda install -c conda-forge uv`` [3]_.


.. _uv: https://docs.astral.sh/uv/
.. _pdm: https://pdm-project.org/en/latest/
.. _hatch: https://hatch.pypa.io/
.. _flit: https://flit.pypa.io/en/stable/


Create a new folder with the name ``calculator-myname`` (replace with *myname* with your name),
open terminal and run:

.. code-block:: console

$ uv init --lib
$ uv init --lib --python 3.10 --no-pin-python

This result in the following set of files.

We will add a fourth file:

.. literalinclude:: packaging-example-project/calculator/__init__.py
Expand Down Expand Up @@ -294,7 +331,7 @@
above.


Building a python package with grayskull and conda-build

Check failure on line 334 in content/packaging.rst

View workflow job for this annotation

GitHub Actions / Build

CRITICAL: Title level inconsistent:
********************************************************

Once build, the conda package can be installed locally. For this example, we
Expand Down Expand Up @@ -384,7 +421,7 @@



Publishing a python package

Check failure on line 424 in content/packaging.rst

View workflow job for this annotation

GitHub Actions / Build

CRITICAL: Title level inconsistent:
***************************

- Upload your package to `conda-forge <https://conda-forge.org/>`__:
Expand Down Expand Up @@ -412,3 +449,8 @@
you are using it.
- PyPI is a place for Python packages
- conda is similar but is not limited to Python

.. [1] In 2025, tools such as pdm_, hatch_, flit_ have similar functionality as uv_.
.. [2] Some package build tools are simple and some have advanced features. Refer to
`pyOpenSci's guide on the choosing the right tool <https://www.pyopensci.org/python-package-guide/package-structure-code/python-package-build-tools.html>`__
.. [3] `uv` is also included in the conda environment you have created in :doc:`software installation <installation>` episode.
1 change: 1 addition & 0 deletions software/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
- twine
- poetry
- flit
- uv
- scikit-learn
- scalene
- ruff
Expand Down
Loading