This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new 1e6c420caca [v3-1-test] Automatically add pydantic extra when
installing airflow 2 in breeze (#60264) (#60267)
1e6c420caca is described below
commit 1e6c420caca119d9a9ac555e90df737e938a8e5c
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Jan 9 01:12:06 2026 +0100
[v3-1-test] Automatically add pydantic extra when installing airflow 2 in
breeze (#60264) (#60267)
When installing Airflow 2 in Breeze, we need to add pydantic as
extra, because pydantic in Airflow 2 was not a required dependency
and installation of airflow even with constraints willl not
downgrade pydantic to the version that was supported in Airflow 2.
When we detect that airflow 2 is installed (either by specified
version number or by retrieving the version from the dist package)
we simply extend the extras with pydantic and that causes airflow
installation to downgrade pydantic to the version that is specified
in constraints of selected airflow version.
(cherry picked from commit 336b8161608409f6ff935af4e2be96e32fb0c0f2)
Co-authored-by: Jarek Potiuk <[email protected]>
---
scripts/in_container/install_airflow_and_providers.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/scripts/in_container/install_airflow_and_providers.py
b/scripts/in_container/install_airflow_and_providers.py
index 49fb52ffb62..1b3341ef954 100755
--- a/scripts/in_container/install_airflow_and_providers.py
+++ b/scripts/in_container/install_airflow_and_providers.py
@@ -393,6 +393,11 @@ def find_installation_spec(
github_repository=github_repository,
python_version=python_version,
)
+ if airflow_version.startswith("2."):
+ # We need to make sure that pydantic is added as extra for
Airflow 2.x
+ # because it's not in extras by default, and pydantic
incompatible version is
+ # installed by default in the container and breaks
serialization import
+ airflow_extras = _add_pydantic_to_extras(airflow_extras)
if airflow_extras:
airflow_distribution_spec += airflow_extras
# We always install latest task-sdk - it's independent from Airflow
@@ -490,6 +495,8 @@ def find_installation_spec(
sys.exit(1)
else:
compile_ui_assets = False
+ if use_airflow_version.startswith("2"):
+ airflow_extras = _add_pydantic_to_extras(airflow_extras)
console.print(f"\nInstalling airflow via
apache-airflow=={use_airflow_version}")
airflow_distribution_spec =
f"apache-airflow{airflow_extras}=={use_airflow_version}"
airflow_core_distribution_spec = (
@@ -559,6 +566,16 @@ def find_installation_spec(
return installation_spec
+def _add_pydantic_to_extras(airflow_extras: str) -> str:
+ console.print("[yellow]Adding pydantic to airflow extras for Airflow 2.x")
+ if airflow_extras:
+ airflow_extras = "[" + airflow_extras.strip("[]") + ",pydantic]"
+ else:
+ airflow_extras = "[pydantic]"
+ console.print(f"[yellow]New extras: {airflow_extras.strip('[]')}")
+ return airflow_extras
+
+
def download_airflow_source_tarball(installation_spec: InstallationSpec):
"""Download Airflow source tarball from GitHub."""
if not installation_spec.compile_ui_assets: