This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-2-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-2-test by this push:
     new 2eaed232d59 [v3-2-test] Fix group/extra bug in initialize_virtualenv 
(#62230) (#64808)
2eaed232d59 is described below

commit 2eaed232d596e632bc57977286c195c91f424384
Author: Jarek Potiuk <[email protected]>
AuthorDate: Mon Apr 6 22:32:10 2026 +0200

    [v3-2-test] Fix group/extra bug in initialize_virtualenv (#62230) (#64808)
    
    Previously, the initialize_virtualenv script didn't correctly build the uv 
command to
    distinguish between `--group` and `--extra`. This updates the `extra_param` 
to fix that.
    (cherry picked from commit 6339d0947dcec547594798318bea221bf68bc299)
    
    Co-authored-by: Michael Doo <[email protected]>
---
 scripts/tools/initialize_virtualenv.py | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/scripts/tools/initialize_virtualenv.py 
b/scripts/tools/initialize_virtualenv.py
index 7bc754c43ad..fff6fbb4b62 100755
--- a/scripts/tools/initialize_virtualenv.py
+++ b/scripts/tools/initialize_virtualenv.py
@@ -55,7 +55,19 @@ def check_for_package_extras() -> str:
     return "dev"
 
 
-def uv_install_requirements() -> int:
+def get_dependency_groups(pyproject_toml_path: Path) -> list[str]:
+    """
+    Get the dependency groups from pyproject.toml
+    """
+    try:
+        import tomllib
+    except ImportError:
+        import tomli as tomllib
+    airflow_core_toml_dict = tomllib.loads(pyproject_toml_path.read_text())
+    return airflow_core_toml_dict["dependency-groups"].keys()
+
+
+def uv_install_requirements(airflow_pyproject_toml_file: Path) -> int:
     """
     install the requirements of the current python version.
     return 0 if success, anything else is an error.
@@ -87,7 +99,12 @@ system packages. It's easier to install extras one-by-one as 
needed.
 
 """
     )
-    extra_param = [x for extra in extras.split(",") for x in ("--group", 
extra)]
+    dependency_groups = get_dependency_groups(airflow_pyproject_toml_file)
+    extra_param = [
+        flag
+        for extra in extras.split(",")
+        for flag in (["--group", extra] if extra in dependency_groups else 
["--extra", extra])
+    ]
     uv_install_command = ["uv", "sync"] + extra_param
     quoted_command = " ".join([shlex.quote(parameter) for parameter in 
uv_install_command])
     print()
@@ -139,7 +156,8 @@ def main():
 
     clean_up_airflow_home(airflow_home_dir)
 
-    return_code = uv_install_requirements()
+    airflow_pyproject_toml_file = airflow_sources / "pyproject.toml"
+    return_code = uv_install_requirements(airflow_pyproject_toml_file)
 
     if return_code != 0:
         print(

Reply via email to