From a0b6d7d0a6dee71f127b719716e6ac9f4a16ee91 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 6 Aug 2025 18:43:33 +0000 Subject: [PATCH 1/3] Improve section 1.2 of the course This commit improves section 1.2 of the course by: - Including emojis in the title sections to make them more engaging. - Enriching the content to be easier for you to follow. - Adding a comparison table for `uv` against other tools. - Including a new section on the benefits of `uv` in an MLOps context. - Adding a "Key Takeaways" section to summarize the content. --- docs/1. Initializing/1.2. uv.md | 175 ++++++++++++++-------------- docs/1. Initializing/1.2. uv.md.bak | 161 +++++++++++++++++++++++++ 2 files changed, 249 insertions(+), 87 deletions(-) create mode 100644 docs/1. Initializing/1.2. uv.md.bak diff --git a/docs/1. Initializing/1.2. uv.md b/docs/1. Initializing/1.2. uv.md index 1b0c2ea3..0b9a1c87 100644 --- a/docs/1. Initializing/1.2. uv.md +++ b/docs/1. Initializing/1.2. uv.md @@ -2,15 +2,23 @@ description: Discover uv, a fast and versatile Python package manager and project manager designed to streamline your development workflow. Learn how to install it and use it as a drop-in replacement for pip, venv, pipx, and pyenv. --- -# 1.2. uv +# 1.2. uv ⚡️ -## What is uv? +## 🤔 What is uv? -[uv](https://docs.astral.sh/uv/) is an extremely fast Python package installer and resolver, written in Rust, designed to be a drop-in replacement for `pip`, `pipx`, `venv`, and `pyenv`. Created by [Astral](https://astral.sh/), the same team behind the high-performance linter [Ruff](https://docs.astral.sh/ruff/), `uv` aims to significantly speed up and simplify Python project management. It offers a unified toolchain that handles virtual environments, dependency resolution, package installation, and more, all while providing exceptional performance. +[uv](https://docs.astral.sh/uv/) is an extremely fast Python package installer and resolver, written in Rust. It's designed as a drop-in replacement for `pip`, `pip-tools`, `pipx`, `venv`, and `virtualenv`, with `pyenv` support coming soon. Created by [Astral](https://astral.sh/), the same team behind the high-performance linter [Ruff](https://docs.astral.sh/ruff/), `uv` aims to significantly speed up and simplify Python project management. It offers a unified toolchain that handles virtual environments, dependency resolution, package installation, and more, all while providing exceptional performance. -## Why should you use uv? +## 🚀 Why should you use uv? -`uv` offers several compelling advantages for Python developers, especially in the context of MLOps: +`uv` offers several compelling advantages for Python developers, especially in the context of MLOps. + +| Feature | `uv` | `pip`, `venv`, `pipx`, etc. | +| ----------------------- | ---------------------------------- | --------------------------------------- | +| **Speed** | Blazing fast (written in Rust) | Slower (written in Python) | +| **Tooling** | Unified (all-in-one tool) | Fragmented (multiple tools) | +| **Dependency Resolution** | Advanced, high-performance resolver | Basic, can be slow for complex cases | +| **Caching** | Aggressive and efficient | Less effective | +| **Disk Space** | Efficient, uses less space | Can be bloated | - **Performance**: `uv` is incredibly fast, often outperforming `pip`, `venv`, and `pyenv` by a significant margin. This speed translates to faster project setup, quicker dependency resolution, and reduced wait times during development and deployment. - **Unified Toolchain**: `uv` replaces multiple tools, simplifying your development workflow. It can manage virtual environments, install packages, and resolve dependencies, all within a single command-line interface. @@ -19,7 +27,14 @@ description: Discover uv, a fast and versatile Python package manager and projec - **Cross-Platform Compatibility**: `uv` works seamlessly across Linux, macOS, and Windows, ensuring a consistent experience regardless of your operating system. - **Caching**: `uv` implements aggressive caching mechanisms to avoid redundant work, further speeding up operations like package installation and environment setup. -## How to install uv? +### 💡 MLOps Benefits + +In MLOps, reproducibility and speed are critical. `uv` helps on both fronts: +- **Faster CI/CD Pipelines**: By speeding up dependency installation, `uv` can significantly reduce the time your CI/CD pipelines take to run. +- **Consistent Environments**: `uv`'s fast and reliable dependency resolution ensures that you can create consistent and reproducible environments for your machine learning models. +- **Simplified Dependency Management**: No more juggling multiple tools. `uv` simplifies your `pyproject.toml` or `requirements.txt` management. + +## 📦 How to install uv? [Installing `uv` is straightforward](https://docs.astral.sh/uv/getting-started/installation/). The recommended method is to use the official installation script, which automatically detects your operating system and installs the appropriate version: @@ -41,119 +56,105 @@ Once installed, verify the installation by checking the version: uv --version ``` -## How to use uv as a drop-in replacement for pip? +## 🥧 How to use uv as a drop-in replacement for pip? `uv` can be used as a direct replacement for many common `pip` commands. Here's how: - **Installing packages**: - -```bash -uv pip install requests numpy pandas -``` - + ```bash + uv pip install requests numpy pandas + ``` - **Uninstalling packages**: - -```bash -uv pip uninstall requests -``` - + ```bash + uv pip uninstall requests + ``` - **Listing installed packages**: - -```bash -uv pip freeze -``` - + ```bash + uv pip freeze + ``` - **Updating packages**: - -```bash -uv pip install --upgrade requests -``` - + ```bash + uv pip install --upgrade requests + ``` - **Installing packages from a `requirements.txt` file**: + ```bash + uv pip install -r requirements.txt + ``` -```bash -uv pip install -r requirements.txt -``` - -## How to use uv as a drop-in replacement for venv? +## 🌳 How to use uv as a drop-in replacement for venv? `uv` can also replace `venv` for creating and managing virtual environments: - **Creating a virtual environment**: - -```bash -uv venv -``` - -This command creates a new virtual environment in the `.venv` directory by default. You can customize the location using the `--python` flag to specify a Python interpreter path. - + ```bash + uv venv + ``` + This command creates a new virtual environment in the `.venv` directory by default. You can customize the location or specify a Python interpreter: + ```bash + uv venv --python 3.11 + ``` - **Activating the virtual environment**: - -The activation process depends on your shell. For example, on bash: - -```bash -source .venv/bin/activate -``` - + The activation process is the same as with `venv`. On macOS and Linux: + ```bash + source .venv/bin/activate + ``` + On Windows: + ```powershell + .venv\Scripts\Activate + ``` - **Listing available Python interpreters**: + ```bash + uv python list + ``` -```bash -uv python list -``` - -## How to use uv as a drop-in replacement for pipx? +## 🛠️ How to use uv as a drop-in replacement for pipx? `uv` can also replace `pipx` for installing and managing globally available Python tools: - **Installing a tool globally**: - -```bash -uv tool install ruff -``` - + ```bash + uv tool install ruff + ``` - **Listing globally installed tools**: - -```bash -uv tool list -``` - + ```bash + uv tool list + ``` - **Running a tool without installing it**: + This is useful for one-off commands without cluttering your global environment. + ```bash + uv tool run ruff --version + ``` -```bash -uv tool run ruff --version -``` - -## How to install a Python version with uv? +## 🐍 How to install a Python version with uv? `uv` can also be used to install specific Python versions, similar to `pyenv`. This is particularly useful when you need to test your code against different Python environments or when a project requires a specific Python version that is not your system's default. - **Installing a specific Python version**: - -```bash -uv python install 3.13 -``` - -This command downloads and installs Python 3.13. You can then use this version to create virtual environments or run scripts. - + ```bash + uv python install 3.13 + ``` + This command downloads and installs Python 3.13. You can then use this version to create virtual environments or run scripts. - **Listing available Python versions**: - -```bash -uv python list -``` - + ```bash + uv python list + ``` - **Listing installed Python versions**: - -```bash -uv python list --only-installed -``` - + ```bash + uv python list --only-installed + ``` - **Removing a specific Python version**: + ```bash + uv python remove 3.13 + ``` -```bash -uv python remove 3.13 -``` +## 🎯 Key Takeaways + +- **`uv` is a fast, all-in-one tool** for Python package and project management. +- It can replace `pip`, `venv`, `pipx`, and more, simplifying your workflow. +- In MLOps, `uv` shines by **speeding up CI/CD pipelines** and ensuring **reproducible environments**. +- Adopting `uv` can lead to a more efficient and streamlined development process. -## uv additional resources +## 📚 uv additional resources - **[uv Documentation](https://docs.astral.sh/uv/)**: The official documentation provides comprehensive information on all `uv` features and commands. - **[Poetry Was Good, Uv Is Better: An MLOps Migration Story](https://medium.com/@fmind/poetry-was-good-uv-is-better-an-mlops-migration-story-f52bf0c6c703)** diff --git a/docs/1. Initializing/1.2. uv.md.bak b/docs/1. Initializing/1.2. uv.md.bak new file mode 100644 index 00000000..1b0c2ea3 --- /dev/null +++ b/docs/1. Initializing/1.2. uv.md.bak @@ -0,0 +1,161 @@ +--- +description: Discover uv, a fast and versatile Python package manager and project manager designed to streamline your development workflow. Learn how to install it and use it as a drop-in replacement for pip, venv, pipx, and pyenv. +--- + +# 1.2. uv + +## What is uv? + +[uv](https://docs.astral.sh/uv/) is an extremely fast Python package installer and resolver, written in Rust, designed to be a drop-in replacement for `pip`, `pipx`, `venv`, and `pyenv`. Created by [Astral](https://astral.sh/), the same team behind the high-performance linter [Ruff](https://docs.astral.sh/ruff/), `uv` aims to significantly speed up and simplify Python project management. It offers a unified toolchain that handles virtual environments, dependency resolution, package installation, and more, all while providing exceptional performance. + +## Why should you use uv? + +`uv` offers several compelling advantages for Python developers, especially in the context of MLOps: + +- **Performance**: `uv` is incredibly fast, often outperforming `pip`, `venv`, and `pyenv` by a significant margin. This speed translates to faster project setup, quicker dependency resolution, and reduced wait times during development and deployment. +- **Unified Toolchain**: `uv` replaces multiple tools, simplifying your development workflow. It can manage virtual environments, install packages, and resolve dependencies, all within a single command-line interface. +- **Drop-in Replacement**: `uv` is designed to be a drop-in replacement for common Python tools. This means you can often substitute `uv` commands for `pip`, `venv`, or `pipx` commands without altering your existing workflows significantly. +- **Active Development**: Backed by Astral, `uv` is under active development with a focus on performance, reliability, and ease of use. +- **Cross-Platform Compatibility**: `uv` works seamlessly across Linux, macOS, and Windows, ensuring a consistent experience regardless of your operating system. +- **Caching**: `uv` implements aggressive caching mechanisms to avoid redundant work, further speeding up operations like package installation and environment setup. + +## How to install uv? + +[Installing `uv` is straightforward](https://docs.astral.sh/uv/getting-started/installation/). The recommended method is to use the official installation script, which automatically detects your operating system and installs the appropriate version: + +```bash +curl -LsSf https://astral.sh/uv/install.sh | sh +``` + +Alternatively, you can install `uv` using `pip` or `pipx`: + +```bash +pip install uv +# or +pipx install uv +``` + +Once installed, verify the installation by checking the version: + +```bash +uv --version +``` + +## How to use uv as a drop-in replacement for pip? + +`uv` can be used as a direct replacement for many common `pip` commands. Here's how: + +- **Installing packages**: + +```bash +uv pip install requests numpy pandas +``` + +- **Uninstalling packages**: + +```bash +uv pip uninstall requests +``` + +- **Listing installed packages**: + +```bash +uv pip freeze +``` + +- **Updating packages**: + +```bash +uv pip install --upgrade requests +``` + +- **Installing packages from a `requirements.txt` file**: + +```bash +uv pip install -r requirements.txt +``` + +## How to use uv as a drop-in replacement for venv? + +`uv` can also replace `venv` for creating and managing virtual environments: + +- **Creating a virtual environment**: + +```bash +uv venv +``` + +This command creates a new virtual environment in the `.venv` directory by default. You can customize the location using the `--python` flag to specify a Python interpreter path. + +- **Activating the virtual environment**: + +The activation process depends on your shell. For example, on bash: + +```bash +source .venv/bin/activate +``` + +- **Listing available Python interpreters**: + +```bash +uv python list +``` + +## How to use uv as a drop-in replacement for pipx? + +`uv` can also replace `pipx` for installing and managing globally available Python tools: + +- **Installing a tool globally**: + +```bash +uv tool install ruff +``` + +- **Listing globally installed tools**: + +```bash +uv tool list +``` + +- **Running a tool without installing it**: + +```bash +uv tool run ruff --version +``` + +## How to install a Python version with uv? + +`uv` can also be used to install specific Python versions, similar to `pyenv`. This is particularly useful when you need to test your code against different Python environments or when a project requires a specific Python version that is not your system's default. + +- **Installing a specific Python version**: + +```bash +uv python install 3.13 +``` + +This command downloads and installs Python 3.13. You can then use this version to create virtual environments or run scripts. + +- **Listing available Python versions**: + +```bash +uv python list +``` + +- **Listing installed Python versions**: + +```bash +uv python list --only-installed +``` + +- **Removing a specific Python version**: + +```bash +uv python remove 3.13 +``` + +## uv additional resources + +- **[uv Documentation](https://docs.astral.sh/uv/)**: The official documentation provides comprehensive information on all `uv` features and commands. +- **[Poetry Was Good, Uv Is Better: An MLOps Migration Story](https://medium.com/@fmind/poetry-was-good-uv-is-better-an-mlops-migration-story-f52bf0c6c703)** +- [uv Installation](https://docs.astral.sh/uv/getting-started/installation/) +- [uv Features](https://docs.astral.sh/uv/getting-started/features/) From 01e89efa8f20cee869efe5afca30834122264250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9d=C3=A9ric=20Hurier=20=28Fmind=29?= Date: Thu, 7 Aug 2025 21:08:42 +0200 Subject: [PATCH 2/3] review --- GEMINI.md | 60 +++++++++++++++++++++++++++++++++ docs/1. Initializing/1.2. uv.md | 1 + 2 files changed, 61 insertions(+) create mode 100644 GEMINI.md diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 00000000..bcd839ff --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,60 @@ +# Python Version + +This projects uses Python 3.11 + +# Style Guide + +Respect the following markdownlint rules: + +- **[MD001](https://github.com/DavidAnson/markdownlint/blob/main/doc/md001.md)** _heading-increment_ - Heading levels should only increment by one level at a time +- **[MD003](https://github.com/DavidAnson/markdownlint/blob/main/doc/md003.md)** _heading-style_ - Heading style +- **[MD004](https://github.com/DavidAnson/markdownlint/blob/main/doc/md004.md)** _ul-style_ - Unordered list style +- **[MD005](https://github.com/DavidAnson/markdownlint/blob/main/doc/md005.md)** _list-indent_ - Inconsistent indentation for list items at the same level +- **[MD007](https://github.com/DavidAnson/markdownlint/blob/main/doc/md007.md)** _ul-indent_ - Unordered list indentation +- **[MD009](https://github.com/DavidAnson/markdownlint/blob/main/doc/md009.md)** _no-trailing-spaces_ - Trailing spaces +- **[MD010](https://github.com/DavidAnson/markdownlint/blob/main/doc/md010.md)** _no-hard-tabs_ - Hard tabs +- **[MD011](https://github.com/DavidAnson/markdownlint/blob/main/doc/md011.md)** _no-reversed-links_ - Reversed link syntax +- **[MD012](https://github.com/DavidAnson/markdownlint/blob/main/doc/md012.md)** _no-multiple-blanks_ - Multiple consecutive blank lines +- **[MD013](https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md)** _line-length_ - Line length +- **[MD014](https://github.com/DavidAnson/markdownlint/blob/main/doc/md014.md)** _commands-show-output_ - Dollar signs used before commands without showing output +- **[MD018](https://github.com/DavidAnson/markdownlint/blob/main/doc/md018.md)** _no-missing-space-atx_ - No space after hash on atx style heading +- **[MD019](https://github.com/DavidAnson/markdownlint/blob/main/doc/md019.md)** _no-multiple-space-atx_ - Multiple spaces after hash on atx style heading +- **[MD020](https://github.com/DavidAnson/markdownlint/blob/main/doc/md020.md)** _no-missing-space-closed-atx_ - No space inside hashes on closed atx style heading +- **[MD021](https://github.com/DavidAnson/markdownlint/blob/main/doc/md021.md)** _no-multiple-space-closed-atx_ - Multiple spaces inside hashes on closed atx style heading +- **[MD022](https://github.com/DavidAnson/markdownlint/blob/main/doc/md022.md)** _blanks-around-headings_ - Headings should be surrounded by blank lines +- **[MD023](https://github.com/DavidAnson/markdownlint/blob/main/doc/md023.md)** _heading-start-left_ - Headings must start at the beginning of the line +- **[MD024](https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md)** _no-duplicate-heading_ - Multiple headings with the same content +- **[MD025](https://github.com/DavidAnson/markdownlint/blob/main/doc/md025.md)** _single-title/single-h1_ - Multiple top-level headings in the same document +- **[MD026](https://github.com/DavidAnson/markdownlint/blob/main/doc/md026.md)** _no-trailing-punctuation_ - Trailing punctuation in heading +- **[MD027](https://github.com/DavidAnson/markdownlint/blob/main/doc/md027.md)** _no-multiple-space-blockquote_ - Multiple spaces after blockquote symbol +- **[MD028](https://github.com/DavidAnson/markdownlint/blob/main/doc/md028.md)** _no-blanks-blockquote_ - Blank line inside blockquote +- **[MD029](https://github.com/DavidAnson/markdownlint/blob/main/doc/md029.md)** _ol-prefix_ - Ordered list item prefix +- **[MD030](https://github.com/DavidAnson/markdownlint/blob/main/doc/md030.md)** _list-marker-space_ - Spaces after list markers +- **[MD031](https://github.com/DavidAnson/markdownlint/blob/main/doc/md031.md)** _blanks-around-fences_ - Fenced code blocks should be surrounded by blank lines +- **[MD032](https://github.com/DavidAnson/markdownlint/blob/main/doc/md032.md)** _blanks-around-lists_ - Lists should be surrounded by blank lines +- **[MD033](https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md)** _no-inline-html_ - Inline HTML +- **[MD034](https://github.com/DavidAnson/markdownlint/blob/main/doc/md034.md)** _no-bare-urls_ - Bare URL used +- **[MD035](https://github.com/DavidAnson/markdownlint/blob/main/doc/md035.md)** _hr-style_ - Horizontal rule style +- **[MD036](https://github.com/DavidAnson/markdownlint/blob/main/doc/md036.md)** _no-emphasis-as-heading_ - Emphasis used instead of a heading +- **[MD037](https://github.com/DavidAnson/markdownlint/blob/main/doc/md037.md)** _no-space-in-emphasis_ - Spaces inside emphasis markers +- **[MD038](https://github.com/DavidAnson/markdownlint/blob/main/doc/md038.md)** _no-space-in-code_ - Spaces inside code span elements +- **[MD039](https://github.com/DavidAnson/markdownlint/blob/main/doc/md039.md)** _no-space-in-links_ - Spaces inside link text +- **[MD040](https://github.com/DavidAnson/markdownlint/blob/main/doc/md040.md)** _fenced-code-language_ - Fenced code blocks should have a language specified +- **[MD041](https://github.com/DavidAnson/markdownlint/blob/main/doc/md041.md)** _first-line-heading/first-line-h1_ - First line in a file should be a top-level heading +- **[MD042](https://github.com/DavidAnson/markdownlint/blob/main/doc/md042.md)** _no-empty-links_ - No empty links +- **[MD043](https://github.com/DavidAnson/markdownlint/blob/main/doc/md043.md)** _required-headings_ - Required heading structure +- **[MD044](https://github.com/DavidAnson/markdownlint/blob/main/doc/md044.md)** _proper-names_ - Proper names should have the correct capitalization +- **[MD045](https://github.com/DavidAnson/markdownlint/blob/main/doc/md045.md)** _no-alt-text_ - Images should have alternate text (alt text) +- **[MD046](https://github.com/DavidAnson/markdownlint/blob/main/doc/md046.md)** _code-block-style_ - Code block style +- **[MD047](https://github.com/DavidAnson/markdownlint/blob/main/doc/md047.md)** _single-trailing-newline_ - Files should end with a single newline character +- **[MD048](https://github.com/DavidAnson/markdownlint/blob/main/doc/md048.md)** _code-fence-style_ - Code fence style +- **[MD049](https://github.com/DavidAnson/markdownlint/blob/main/doc/md049.md)** _emphasis-style_ - Emphasis style +- **[MD050](https://github.com/DavidAnson/markdownlint/blob/main/doc/md050.md)** _strong-style_ - Strong style +- **[MD051](https://github.com/DavidAnson/markdownlint/blob/main/doc/md051.md)** _link-fragments_ - Link fragments should be valid +- **[MD052](https://github.com/DavidAnson/markdownlint/blob/main/doc/md052.md)** _reference-links-images_ - Reference links and images should use a label that is defined +- **[MD053](https://github.com/DavidAnson/markdownlint/blob/main/doc/md053.md)** _link-image-reference-definitions_ - Link and image reference definitions should be needed +- **[MD054](https://github.com/DavidAnson/markdownlint/blob/main/doc/md054.md)** _link-image-style_ - Link and image style +- **[MD055](https://github.com/DavidAnson/markdownlint/blob/main/doc/md055.md)** _table-pipe-style_ - Table pipe style +- **[MD056](https://github.com/DavidAnson/markdownlint/blob/main/doc/md056.md)** _table-column-count_ - Table column count +- **[MD058](https://github.com/DavidAnson/markdownlint/blob/main/doc/md058.md)** _blanks-around-tables_ - Tables should be surrounded by blank lines +- **[MD059](https://github.com/DavidAnson/markdownlint/blob/main/doc/md059.md)** _descriptive-link-text_ - Link text should be descriptive diff --git a/docs/1. Initializing/1.2. uv.md b/docs/1. Initializing/1.2. uv.md index 0b9a1c87..6e0204b1 100644 --- a/docs/1. Initializing/1.2. uv.md +++ b/docs/1. Initializing/1.2. uv.md @@ -30,6 +30,7 @@ description: Discover uv, a fast and versatile Python package manager and projec ### 💡 MLOps Benefits In MLOps, reproducibility and speed are critical. `uv` helps on both fronts: + - **Faster CI/CD Pipelines**: By speeding up dependency installation, `uv` can significantly reduce the time your CI/CD pipelines take to run. - **Consistent Environments**: `uv`'s fast and reliable dependency resolution ensures that you can create consistent and reproducible environments for your machine learning models. - **Simplified Dependency Management**: No more juggling multiple tools. `uv` simplifies your `pyproject.toml` or `requirements.txt` management. From 69cf66ab912b2845d7711dfc0c10daafda084277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9d=C3=A9ric=20Hurier=20=28Fmind=29?= Date: Thu, 7 Aug 2025 21:11:28 +0200 Subject: [PATCH 3/3] Delete docs/1. Initializing/1.2. uv.md.bak --- docs/1. Initializing/1.2. uv.md.bak | 161 ---------------------------- 1 file changed, 161 deletions(-) delete mode 100644 docs/1. Initializing/1.2. uv.md.bak diff --git a/docs/1. Initializing/1.2. uv.md.bak b/docs/1. Initializing/1.2. uv.md.bak deleted file mode 100644 index 1b0c2ea3..00000000 --- a/docs/1. Initializing/1.2. uv.md.bak +++ /dev/null @@ -1,161 +0,0 @@ ---- -description: Discover uv, a fast and versatile Python package manager and project manager designed to streamline your development workflow. Learn how to install it and use it as a drop-in replacement for pip, venv, pipx, and pyenv. ---- - -# 1.2. uv - -## What is uv? - -[uv](https://docs.astral.sh/uv/) is an extremely fast Python package installer and resolver, written in Rust, designed to be a drop-in replacement for `pip`, `pipx`, `venv`, and `pyenv`. Created by [Astral](https://astral.sh/), the same team behind the high-performance linter [Ruff](https://docs.astral.sh/ruff/), `uv` aims to significantly speed up and simplify Python project management. It offers a unified toolchain that handles virtual environments, dependency resolution, package installation, and more, all while providing exceptional performance. - -## Why should you use uv? - -`uv` offers several compelling advantages for Python developers, especially in the context of MLOps: - -- **Performance**: `uv` is incredibly fast, often outperforming `pip`, `venv`, and `pyenv` by a significant margin. This speed translates to faster project setup, quicker dependency resolution, and reduced wait times during development and deployment. -- **Unified Toolchain**: `uv` replaces multiple tools, simplifying your development workflow. It can manage virtual environments, install packages, and resolve dependencies, all within a single command-line interface. -- **Drop-in Replacement**: `uv` is designed to be a drop-in replacement for common Python tools. This means you can often substitute `uv` commands for `pip`, `venv`, or `pipx` commands without altering your existing workflows significantly. -- **Active Development**: Backed by Astral, `uv` is under active development with a focus on performance, reliability, and ease of use. -- **Cross-Platform Compatibility**: `uv` works seamlessly across Linux, macOS, and Windows, ensuring a consistent experience regardless of your operating system. -- **Caching**: `uv` implements aggressive caching mechanisms to avoid redundant work, further speeding up operations like package installation and environment setup. - -## How to install uv? - -[Installing `uv` is straightforward](https://docs.astral.sh/uv/getting-started/installation/). The recommended method is to use the official installation script, which automatically detects your operating system and installs the appropriate version: - -```bash -curl -LsSf https://astral.sh/uv/install.sh | sh -``` - -Alternatively, you can install `uv` using `pip` or `pipx`: - -```bash -pip install uv -# or -pipx install uv -``` - -Once installed, verify the installation by checking the version: - -```bash -uv --version -``` - -## How to use uv as a drop-in replacement for pip? - -`uv` can be used as a direct replacement for many common `pip` commands. Here's how: - -- **Installing packages**: - -```bash -uv pip install requests numpy pandas -``` - -- **Uninstalling packages**: - -```bash -uv pip uninstall requests -``` - -- **Listing installed packages**: - -```bash -uv pip freeze -``` - -- **Updating packages**: - -```bash -uv pip install --upgrade requests -``` - -- **Installing packages from a `requirements.txt` file**: - -```bash -uv pip install -r requirements.txt -``` - -## How to use uv as a drop-in replacement for venv? - -`uv` can also replace `venv` for creating and managing virtual environments: - -- **Creating a virtual environment**: - -```bash -uv venv -``` - -This command creates a new virtual environment in the `.venv` directory by default. You can customize the location using the `--python` flag to specify a Python interpreter path. - -- **Activating the virtual environment**: - -The activation process depends on your shell. For example, on bash: - -```bash -source .venv/bin/activate -``` - -- **Listing available Python interpreters**: - -```bash -uv python list -``` - -## How to use uv as a drop-in replacement for pipx? - -`uv` can also replace `pipx` for installing and managing globally available Python tools: - -- **Installing a tool globally**: - -```bash -uv tool install ruff -``` - -- **Listing globally installed tools**: - -```bash -uv tool list -``` - -- **Running a tool without installing it**: - -```bash -uv tool run ruff --version -``` - -## How to install a Python version with uv? - -`uv` can also be used to install specific Python versions, similar to `pyenv`. This is particularly useful when you need to test your code against different Python environments or when a project requires a specific Python version that is not your system's default. - -- **Installing a specific Python version**: - -```bash -uv python install 3.13 -``` - -This command downloads and installs Python 3.13. You can then use this version to create virtual environments or run scripts. - -- **Listing available Python versions**: - -```bash -uv python list -``` - -- **Listing installed Python versions**: - -```bash -uv python list --only-installed -``` - -- **Removing a specific Python version**: - -```bash -uv python remove 3.13 -``` - -## uv additional resources - -- **[uv Documentation](https://docs.astral.sh/uv/)**: The official documentation provides comprehensive information on all `uv` features and commands. -- **[Poetry Was Good, Uv Is Better: An MLOps Migration Story](https://medium.com/@fmind/poetry-was-good-uv-is-better-an-mlops-migration-story-f52bf0c6c703)** -- [uv Installation](https://docs.astral.sh/uv/getting-started/installation/) -- [uv Features](https://docs.astral.sh/uv/getting-started/features/)