Skip to content

Commit 80b2153

Browse files
committed
📝 Update uv docs
1 parent c726fce commit 80b2153

File tree

4 files changed

+82
-71
lines changed

4 files changed

+82
-71
lines changed

docs/appendix/glossary.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ Glossary
566566
<update-uv-lock>` the Python environment, if necessary also with a
567567
:doc:`Python4DataScience:productive/envs/uv/dependency-bot`
568568
* :doc:`Python4DataScience:productive/envs/uv/cicd`
569+
* :doc:`Python4DataScience:productive/envs/uv/claude-cursor`
569570
* :doc:`Python4DataScience:productive/envs/uv/docker`
570571
* Check vulnerabilities with :ref:`uv-secure <check-vulnerabilities>`
571572

docs/libs/install.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,14 @@ You can easily update uv with:
278278
Python installation
279279
~~~~~~~~~~~~~~~~~~~
280280

281-
With ``uv`` not only older CPython versions can be installed, but also, for
282-
example, `PyPy <https://pypy.org>`_ with ``uv python install pypy@3.12`` or
283-
free-threaded Python 3.13 with ``uv python install --python-preference
284-
only-managed 3.13t``.
281+
The current Python version can be installed with ``uv python install``.
282+
Alternatively, a specific version can be installed with :samp:`uv python install
283+
{3.12}`. However, you can install not only older CPython versions, but also
284+
`PyPy <https://pypy.org>`_ with :samp:`uv python install pypy@{3.12}` or
285+
Free-threaded Python with :samp:`uv python install --python-preferenc
286+
only-managed {3.13t}`. You can see the Python versions that are already
287+
installed with ``uv python list``. You can call up an installed Python version
288+
with :samp:`uv run --python {3.12} python`.
285289

286290
Create project structure
287291
~~~~~~~~~~~~~~~~~~~~~~~~

docs/packs/apps.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ interfaces)`. We can also create them with ``uv init --package``:
5555

5656
.. code-block:: pycon
5757
58-
$ uv add --dev .
58+
$ uv add .
5959
Resolved 1 package in 1ms
6060
Audited in 0.01ms
6161
$ uv run python
@@ -66,9 +66,9 @@ interfaces)`. We can also create them with ``uv init --package``:
6666
.. _uv_lock:
6767

6868
:file:`uv.lock` file
69-
With ``uv add --dev .`` the :file:`uv.lock` file was also created alongside
70-
the :file:`pyproject.toml` file. :file:`uv.lock` is a cross-platform lock
71-
file that records the packages that are to be installed across all possible
69+
With ``uv add .`` the :file:`uv.lock` file was also created alongside the
70+
:file:`pyproject.toml` file. :file:`uv.lock` is a cross-platform lock file
71+
that records the packages that are to be installed across all possible
7272
Python features such as operating system, architecture and Python version.
7373

7474
Unlike :file:`pyproject.toml`, which specifies the general requirements of

docs/packs/distribution.rst

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,17 @@ as:
281281
:term:`Python Package Index` (:term:`PyPI`). In general, this could lead to
282282
source code, documentation, task managers, :abbr:`etc (et cetera)`.
283283

284+
.. error::
285+
If you receive the error in uv: :samp:`error: No \`project\` table found in:
286+
\`{/PATH/TO/}pyproject.toml\``, you probably haven’t defined a ``[project]``
287+
section. This can occur in repositories that only use the
288+
:file:`pyproject.toml` file to configure tools such as Black and Ruff, but
289+
do not define the project itself.
290+
291+
To resolve the issue, you can insert a ``[project]`` section that must
292+
contain at least ``name`` and ``version``. Alternatively, you can also use
293+
``uv run`` with the ``--no-project`` option.
294+
284295
.. seealso::
285296
* `Declaring project metadata
286297
<https://packaging.python.org/en/latest/specifications/pyproject-toml/#declaring-project-metadata-the-project-table>`_
@@ -518,6 +529,24 @@ structure for packages.
518529
└── mypack
519530
└── __init__.py
520531
532+
file:`.python-version`
533+
specifies which Python version should be used for developing the project.
534+
535+
.. error::
536+
If you receive the following error message: error: :samp:`error: The
537+
Python request from \`.python-version\` resolved to Python {U.V.W}, which
538+
is incompatible with the project's Python requirement: \`>={X.Y}\`. Use
539+
\`uv python pin\` to update the \`.python-version\` file to a compatible
540+
version.`, this indicates a conflict between the version specified in the
541+
:file:`.python-version` file and the ``requires-python`` specification in
542+
the :file:`pyproject.toml` file. You now have three different options:
543+
544+
* Update your :file:`.python-version` file with :samp:`uv python pin
545+
{X.Y.Z}`.
546+
* Override the Python version for a single command with :samp:`uv run
547+
--python {X.Y} {COMMAND}`.
548+
* Update ``requires-python``.
549+
521550
:file:`mypack/pyproject.toml`
522551
The file :file:`pyproject.toml` contains a ``scripts`` entry point
523552
``mypack:main``:
@@ -594,89 +623,66 @@ where :file:`pyproject.toml` is located:
594623
other hand only for chips with the x86 instruction set and a 64-bit
595624
architecture
596625

626+
.. seealso::
627+
* :pep:`427`
628+
597629
:file:`mypack-0.1.0.tar.gz`
598-
is a :term:`source distribution`.
630+
is a :term:`source distribution`
599631

600632
.. seealso::
601-
For more information on ``sdist``, see `Core metadata specifications
602-
<https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_
603-
and `PyPA specifications
604-
<https://packaging.python.org/en/latest/specifications/>`_.
633+
* `Core metadata specifications
634+
<https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_
635+
* `PyPA specifications
636+
<https://packaging.python.org/en/latest/specifications/>`_
605637

606638
Testing
607639
-------
608640

609-
.. tab:: Linux/macOS
610-
611-
.. code-block:: console
612-
613-
$ mkdir test_env
614-
$ cd test_env
615-
$ python3 -m venv .venv
616-
$ . .venv/bin/activate
617-
$ python -m pip install dist/dataprep-0.1.0-cp313-cp313-macosx_13_0_arm64.whl
618-
Processing ./dist/dataprep-0.1.0-cp313-cp313-macosx_13_0_arm64.whl
619-
Collecting Cython (from dataprep==0.1.0)
620-
Using cached Cython-3.0.11-py2.py3-none-any.whl.metadata (3.2 kB)
621-
622-
Successfully installed Cython-3.0.11 dataprep-0.1.0 numpy-2.1.2 pandas-2.2.3 python-dateutil-2.9.0.post0 pytz-2024.2 six-1.16.0 tzdata-2024.2
623-
624-
.. tab:: Windows
625-
626-
.. code-block:: console
627-
628-
> mkdir test_env
629-
> cd test_env
630-
> python -m venv .venv
631-
> .venv\Scripts\activate.bat
632-
> python -m pip install dist/dataprep-0.1.0-cp313-cp313-win_amd64.whl
633-
Processing ./dist/dataprep-0.1.0-cp313-cp313-win_amd64.whl
634-
Collecting Cython (from dataprep==0.1.0)
635-
Using cached Cython-3.0.11-cp313-cp313-win_amd64.whl.metadata (3.2 kB)
636-
637-
Successfully installed Cython-3.0.11 dataprep-0.1.0 numpy-2.1.2 pandas-2.2.3 python-dateutil-2.9.0.post0 pytz-2024.2 six-1.16.0 tzdata-2024.2
638-
639641
You can then check the :term:`Wheel` file with:
640642

641643
.. code-block:: console
642644
643-
$ mkdir test_env
644-
$ cd !$
645-
cd test_env
646-
$ python3 -m venv .venv
647-
$ . .venv/bin/activate
648-
$ python -m pip install dist/dataprep-0.1.0-py3-none-any.whl
649-
Processing ./dist/dataprep-0.1.0-py3-none-any.whl
650-
Collecting pandas
651-
Using cached pandas-1.3.4-cp39-cp39-macosx_10_9_x86_64.whl (11.6 MB)
652-
653-
Successfully installed dataprep-0.1.0 numpy-1.21.4 pandas-1.3.4 python-dateutil-2.8.2 pytz-2021.3 six-1.16.0
654-
655-
Then you can check the wheel with:
656-
657-
.. code-block:: console
658-
659-
$ python -m pip install check-wheel-contents
660-
$ check-wheel-contents dist/*.whl
661-
dist/dataprep-0.1.0-py3-none-any.whl: OK
645+
$ uv add --dev check-wheel-contents
646+
Resolved 17 packages in 8ms
647+
Built mypack @ file:///Users/veit/sandbox/mypack
648+
Prepared 1 package in 442ms
649+
Uninstalled 1 package in 0.89ms
650+
Installed 10 packages in 5ms
651+
+ annotated-types==0.7.0
652+
+ attrs==24.2.0
653+
+ check-wheel-contents==0.6.0
654+
+ click==8.1.7
655+
~ mypack==0.1.0 (from file:///Users/veit/sandbox/mypack)
656+
+ packaging==24.1
657+
+ pydantic==2.9.2
658+
+ pydantic-core==2.23.4
659+
+ typing-extensions==4.12.2
660+
+ wheel-filename==1.4.1
661+
$ uv run check-wheel-contents dist/*.whl
662+
dist/dataprep-0.1.0-py3-none-any.whl: OK
662663
663664
Alternatively, you can also install the package in a new project, for example in
664665
:samp:`myapp`:
665666

666667
.. code-block:: console
667668
668-
$ python -m pip install dist/dataprep-0.1.0-py3-none-any.whl
669-
Processing ./dist/dataprep-0.1-py3-none-any.whl
670-
Collecting pandas
671-
672-
Installing collected packages: numpy, pytz, six, python-dateutil, pandas, dataprep
673-
Successfully installed dataprep-0.1 numpy-1.21.4 pandas-1.3.4 python-dateutil-2.8.2 pytz-2021.3 six-1.16.0
669+
$ uv init --app myapp
670+
$ cd myapp
671+
$ uv add ../mypack/dist/mypack-0.1.0-py3-none-any.whl
672+
Resolved 8 packages in 130ms
673+
Installed 1 package in 3ms
674+
+ mypack==0.1.0 (from file:///Users/veit/sandbox/mypack/dist/mypack-0.1.0-py3-none-any.whl)
674675
675-
You can then call Python and import your ``loaders`` module:
676+
You can then call ``mypack`` with ``uv run``:
676677

677-
.. code-block:: python
678+
.. code-block:: console
679+
680+
$ uv run mypack
681+
Hello from mypack!
678682
679-
from dataprep import loaders
683+
.. seealso::
684+
* `Troubleshooting build failures
685+
<https://docs.astral.sh/uv/reference/troubleshooting/build-failures/>`_
680686

681687
.. note::
682688
There are still many instructions that include a step to call

0 commit comments

Comments
 (0)