Skip to content

Commit f593d8b

Browse files
potiukutkarsharma2
authored andcommitted
Allow to switch breeze to use uv internally to create virtualenvs (#43587) (#43624)
Breeze sometimes creates "internal" virtualenvs in local ".build" directory when it needs - for example in order to run k8s tests or for release management commands. This PR adds capability to switch breeze to use `uv` instead of `pip` to install depdendencies in those envs. You can now switch breeze to use uv by `breeze setup config --use-uv` and switch back to pip by `breeze setup config --no-use-uv`. (cherry picked from commit a2a0ef0)
1 parent 9425ae0 commit f593d8b

17 files changed

+150
-66
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ jobs:
622622
kubernetes-versions-list-as-string: ${{ needs.build-info.outputs.kubernetes-versions-list-as-string }}
623623
kubernetes-combos-list-as-string: ${{ needs.build-info.outputs.kubernetes-combos-list-as-string }}
624624
include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }}
625+
use-uv: ${{ needs.build-info.outputs.force-pip && 'false' || 'true' }}
625626
debug-resources: ${{ needs.build-info.outputs.debug-resources }}
626627
if: >
627628
( needs.build-info.outputs.run-kubernetes-tests == 'true' ||

.github/workflows/k8s-tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ on: # yamllint disable-line rule:truthy
4444
description: "Whether to include success outputs"
4545
required: true
4646
type: string
47+
use-uv:
48+
description: "Whether to use uv"
49+
required: true
50+
type: string
4751
debug-resources:
4852
description: "Whether to debug resources"
4953
required: true
@@ -96,6 +100,9 @@ jobs:
96100
key: "\
97101
k8s-env-${{ steps.breeze.outputs.host-python-version }}-\
98102
${{ hashFiles('scripts/ci/kubernetes/k8s_requirements.txt','hatch_build.py') }}"
103+
- name: "Switch breeze to use uv"
104+
run: breeze setup-config --use-uv
105+
if: inputs.use-uv == 'true'
99106
- name: Run complete K8S tests ${{ inputs.kubernetes-combos-list-as-string }}
100107
run: breeze k8s run-complete-tests --run-in-parallel --upgrade --no-copy-local-sources
101108
env:

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ ARG AIRFLOW_VERSION="2.9.3"
4949

5050
ARG PYTHON_BASE_IMAGE="python:3.8-slim-bookworm"
5151

52-
ARG AIRFLOW_PIP_VERSION=24.2
53-
ARG AIRFLOW_UV_VERSION=0.4.1
52+
ARG AIRFLOW_PIP_VERSION=24.3.1
53+
ARG AIRFLOW_UV_VERSION=0.4.29
5454
ARG AIRFLOW_USE_UV="false"
5555
ARG UV_HTTP_TIMEOUT="300"
5656
ARG AIRFLOW_IMAGE_REPOSITORY="https://github.com/apache/airflow"

Dockerfile.ci

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,8 +1297,8 @@ ARG DEFAULT_CONSTRAINTS_BRANCH="constraints-main"
12971297
# It can also be overwritten manually by setting the AIRFLOW_CI_BUILD_EPOCH environment variable.
12981298
ARG AIRFLOW_CI_BUILD_EPOCH="10"
12991299
ARG AIRFLOW_PRE_CACHED_PIP_PACKAGES="true"
1300-
ARG AIRFLOW_PIP_VERSION=24.2
1301-
ARG AIRFLOW_UV_VERSION=0.4.1
1300+
ARG AIRFLOW_PIP_VERSION=24.3.1
1301+
ARG AIRFLOW_UV_VERSION=0.4.29
13021302
ARG AIRFLOW_USE_UV="true"
13031303
# Setup PIP
13041304
# By default PIP install run without cache to make image smaller
@@ -1321,8 +1321,8 @@ ARG AIRFLOW_VERSION=""
13211321
# Additional PIP flags passed to all pip install commands except reinstalling pip itself
13221322
ARG ADDITIONAL_PIP_INSTALL_FLAGS=""
13231323

1324-
ARG AIRFLOW_PIP_VERSION=24.2
1325-
ARG AIRFLOW_UV_VERSION=0.4.1
1324+
ARG AIRFLOW_PIP_VERSION=24.3.1
1325+
ARG AIRFLOW_UV_VERSION=0.4.29
13261326
ARG AIRFLOW_USE_UV="true"
13271327

13281328
ENV AIRFLOW_REPO=${AIRFLOW_REPO}\

dev/breeze/doc/ci/02_images.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ can be used for CI images:
447447
| `DEV_APT_DEPS` | | Dev APT dependencies installed in the first part of the image |
448448
| `ADDITIONAL_DEV_APT_DEPS` | | Additional apt dev dependencies installed in the first part of the image |
449449
| `ADDITIONAL_DEV_APT_ENV` | | Additional env variables defined when installing dev deps |
450-
| `AIRFLOW_PIP_VERSION` | `24.0` | PIP version used. |
451-
| `AIRFLOW_UV_VERSION` | `0.1.10` | UV version used. |
450+
| `AIRFLOW_PIP_VERSION` | `24.3.1` | PIP version used. |
451+
| `AIRFLOW_UV_VERSION` | `0.4.29` | UV version used. |
452452
| `AIRFLOW_USE_UV` | `true` | Whether to use UV for installation. |
453453
| `PIP_PROGRESS_BAR` | `on` | Progress bar for PIP installation |
454454

dev/breeze/doc/images/output-commands.svg

Lines changed: 21 additions & 21 deletions
Loading

dev/breeze/doc/images/output_setup_config.svg

Lines changed: 18 additions & 14 deletions
Loading
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
422c8c524b557fcf5924da4c8590935d
1+
96e10564034b282769a2c48ebf7176e2

dev/breeze/src/airflow_breeze/commands/release_management_commands.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ class VersionedFile(NamedTuple):
226226
file_name: str
227227

228228

229-
AIRFLOW_PIP_VERSION = "24.0"
230-
AIRFLOW_UV_VERSION = "0.1.10"
229+
AIRFLOW_PIP_VERSION = "24.3.1"
230+
AIRFLOW_UV_VERSION = "0.4.29"
231231
AIRFLOW_USE_UV = False
232232
WHEEL_VERSION = "0.36.2"
233233
GITPYTHON_VERSION = "3.1.40"
@@ -451,7 +451,11 @@ def _check_sdist_to_wheel_dists(dists_info: tuple[DistributionPackageInfo, ...])
451451
continue
452452

453453
if not venv_created:
454-
python_path = create_venv(Path(tmp_dir_name) / ".venv", pip_version=AIRFLOW_PIP_VERSION)
454+
python_path = create_venv(
455+
Path(tmp_dir_name) / ".venv",
456+
pip_version=AIRFLOW_PIP_VERSION,
457+
uv_version=AIRFLOW_UV_VERSION,
458+
)
455459
pip_command = create_pip_command(python_path)
456460
venv_created = True
457461

dev/breeze/src/airflow_breeze/commands/setup_commands.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ def version():
192192
@option_mysql_version
193193
@click.option("-C/-c", "--cheatsheet/--no-cheatsheet", help="Enable/disable cheatsheet.", default=None)
194194
@click.option("-A/-a", "--asciiart/--no-asciiart", help="Enable/disable ASCIIart.", default=None)
195+
@click.option(
196+
"-U/-u",
197+
"--use-uv/--no-use-uv",
198+
help="Enable/disable using uv for creating venvs by breeze.",
199+
default=None,
200+
)
195201
@click.option(
196202
"--colour/--no-colour",
197203
help="Enable/disable Colour mode (useful for colour blind-friendly communication).",
@@ -200,6 +206,7 @@ def version():
200206
def change_config(
201207
python: str,
202208
backend: str,
209+
use_uv: bool,
203210
postgres_version: str,
204211
mysql_version: str,
205212
cheatsheet: bool,
@@ -212,14 +219,22 @@ def change_config(
212219
asciiart_file = "suppress_asciiart"
213220
cheatsheet_file = "suppress_cheatsheet"
214221
colour_file = "suppress_colour"
222+
use_uv_file = "use_uv"
215223

224+
if use_uv is not None:
225+
if use_uv:
226+
touch_cache_file(use_uv_file)
227+
get_console().print("[info]Enable using uv[/]")
228+
else:
229+
delete_cache(use_uv_file)
230+
get_console().print("[info]Disable using uv[/]")
216231
if asciiart is not None:
217232
if asciiart:
218233
delete_cache(asciiart_file)
219-
get_console().print("[info]Enable ASCIIART![/]")
234+
get_console().print("[info]Enable ASCIIART[/]")
220235
else:
221236
touch_cache_file(asciiart_file)
222-
get_console().print("[info]Disable ASCIIART![/]")
237+
get_console().print("[info]Disable ASCIIART[/]")
223238
if cheatsheet is not None:
224239
if cheatsheet:
225240
delete_cache(cheatsheet_file)
@@ -235,23 +250,27 @@ def change_config(
235250
touch_cache_file(colour_file)
236251
get_console().print("[info]Disable Colour[/]")
237252

238-
def get_status(file: str):
253+
def get_supress_status(file: str):
239254
return "disabled" if check_if_cache_exists(file) else "enabled"
240255

256+
def get_status(file: str):
257+
return "enabled" if check_if_cache_exists(file) else "disabled"
258+
241259
get_console().print()
242260
get_console().print("[info]Current configuration:[/]")
243261
get_console().print()
244262
get_console().print(f"[info]* Python: {python}[/]")
245263
get_console().print(f"[info]* Backend: {backend}[/]")
264+
get_console().print(f"[info]* Use uv: {get_status(use_uv_file)}[/]")
246265
get_console().print()
247266
get_console().print(f"[info]* Postgres version: {postgres_version}[/]")
248267
get_console().print(f"[info]* MySQL version: {mysql_version}[/]")
249268
get_console().print()
250-
get_console().print(f"[info]* ASCIIART: {get_status(asciiart_file)}[/]")
251-
get_console().print(f"[info]* Cheatsheet: {get_status(cheatsheet_file)}[/]")
269+
get_console().print(f"[info]* ASCIIART: {get_supress_status(asciiart_file)}[/]")
270+
get_console().print(f"[info]* Cheatsheet: {get_supress_status(cheatsheet_file)}[/]")
252271
get_console().print()
253272
get_console().print()
254-
get_console().print(f"[info]* Colour: {get_status(colour_file)}[/]")
273+
get_console().print(f"[info]* Colour: {get_supress_status(colour_file)}[/]")
255274
get_console().print()
256275

257276

0 commit comments

Comments
 (0)