Skip to content

Commit 3b39d9f

Browse files
authored
Merge pull request #4 from esciencecenter-digital-skills/uv-teaser-fn
Add a teaser on `uv`
2 parents 4848931 + b7cee18 commit 3b39d9f

1 file changed

Lines changed: 26 additions & 9 deletions

File tree

episodes/12-virtual-environments.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,16 @@ There are several commonly used command line tools for managing Python virtual e
135135
- `conda`, package and environment management system
136136
(also included as part of the Anaconda Python distribution often used by the scientific community)
137137
- `poetry`, a modern Python packaging tool which handles virtual environments automatically
138+
- `uv`, a recent and fast package, environment, and project manager.
138139

139140
While there are pros and cons for using each of the above,
140141
all will do the job of managing Python virtual environments for you
141142
and it may be a matter of personal preference which one you go for.
142-
In this course, we will use `venv` to create and manage our virtual environment
143-
(which is the preferred way for Python 3.3+).
144-
The upside is that `venv` virtual environments created from the command line are
145-
also recognised and picked up automatically by the IDEs we will use in this course,
146-
as we will see in the next episode.
143+
In this course, we will use `venv` to create and manage our virtual environment, which
144+
is the tool that is part of the standard Python installation and the recommended manager
145+
for Python 3.5+. If you want to experiment with a fast alternative that can work
146+
as a drop-in replacement for `venv`, have a look at `uv` (see also the
147+
[callout below](#uv-callout)).
147148

148149
### Managing External Packages
149150

@@ -170,6 +171,22 @@ from remote package repositories and install them on your system, and
170171
So, you can use `conda` for both tasks instead of using `venv` and `pip`.
171172

172173

174+
::::::::::::::::::::::::::::::::::::::::::::::::::
175+
176+
<a id="uv-callout"></a>
177+
178+
::::::::::::::::::::::::::::::::::::::::: callout
179+
180+
## A recent addition: `uv`
181+
182+
[`uv`](https://docs.astral.sh/uv/) is becoming increasingly popular in the world of
183+
Python package and project managers. Similarly to `conda`, it combines the functionality
184+
of a package manager (finding and installing Python packages) and a virtual environment
185+
manager (isolating project dependecies), but it can also be used to create and manage
186+
Python projects, update dependencies, publishing packages, and much more. Its sub-commands
187+
`uv venv` and `uv pip` can be used as a drop-in replacement for `venv` and `pip`,
188+
respectively, which the additional advantage of being much faster!
189+
173190
::::::::::::::::::::::::::::::::::::::::::::::::::
174191

175192
### Many Tools for the Job
@@ -209,7 +226,7 @@ You can test your Python installation from the command line with:
209226

210227
```bash
211228
$ python3 --version # on Mac/Linux
212-
$ python --version # on Windows — Windows installation comes with a python.exe file rather than a python3.exe file
229+
$ python --version # on Windows — Windows installation comes with a python.exe file rather than a python3.exe file
213230
```
214231

215232
If you are using Windows and invoking `python` command causes your Git Bash terminal to hang with no error message or output, you may
@@ -312,7 +329,7 @@ Here are some references for each of the naming conventions:
312329
- [The Python Documentation](https://docs.python.org/3/library/venv.html)
313330
indicates that ".venv" is common
314331
- ["venv" vs ".venv" discussion](https://discuss.python.org/t/trying-to-come-up-with-a-default-directory-name-for-virtual-environments/3750)
315-
332+
316333

317334
::::::::::::::::::::::::::::::::::::::::::::::::::
318335

@@ -449,7 +466,7 @@ Version: 1.26.2
449466
Summary: Fundamental package for array computing in Python
450467
Home-page: https://numpy.org
451468
Author: Travis E. Oliphant et al.
452-
Author-email:
469+
Author-email:
453470
License: Copyright (c) 2005-2023, NumPy Developers.
454471
All rights reserved.
455472
...
@@ -639,7 +656,7 @@ In the above command, we tell the command line two things:
639656
As we can see, the Python interpreter ran our script, which threw an error -
640657
`inflammation-analysis.py: error: the following arguments are required: infiles`.
641658
It looks like the script expects a list of input files to process,
642-
so this is expected behaviour since we do not supply any.
659+
so this is expected behaviour since we do not supply any.
643660

644661
We should run our code as follows, passing one (or more) data file(s) as input:
645662

0 commit comments

Comments
 (0)