Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions airflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@

# Perform side-effects unless someone has explicitly opted out before import
# WARNING: DO NOT USE THIS UNLESS YOU REALLY KNOW WHAT YOU'RE DOING.
# This environment variable prevents proper initialization, and things like
# configs, logging, the ORM, etc. will be broken. It is only useful if you only
# access certain trivial constants and free functions (e.g. `__version__`).
if not os.environ.get("_AIRFLOW__AS_LIBRARY", None):
settings.initialize()

Expand Down
5 changes: 4 additions & 1 deletion airflow/operators/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,10 @@ def _get_airflow_version_from_target_env(self) -> str | None:

try:
result = subprocess.check_output(
[self.python, "-c", "from airflow import __version__; print(__version__)"], text=True
[self.python, "-c", "from airflow import __version__; print(__version__)"],
text=True,
# Avoid Airflow logs polluting stdout.
env={**os.environ, "_AIRFLOW__AS_LIBRARY": "true"},
)
target_airflow_version = result.strip()
if target_airflow_version != airflow_version:
Expand Down