potiuk commented on a change in pull request #19867:
URL: https://github.com/apache/airflow/pull/19867#discussion_r758667680
##########
File path: Breeze2
##########
@@ -0,0 +1,58 @@
+#!/usr/bin/env python3
+# isort: skip
+import os
+import sys
+
+# Python <3.4 does not have pathlib
+if sys.version_info.major != 3 or sys.version_info.minor < 7:
+ print("ERROR! Make sure you use Python 3.7+ !!")
+ sys.exit(1)
+
+import subprocess
+from os import execv
+from pathlib import Path
+
+AIRFLOW_SOURCES_DIR = Path(__file__).parent.resolve()
+BUILD_DIR = AIRFLOW_SOURCES_DIR / ".build"
+BUILD_BREEZE_DIR = BUILD_DIR / "breeze2"
+BUILD_BREEZE_CFG_SAVED = BUILD_BREEZE_DIR / "setup.cfg.saved"
+BUILD_BREEZE_VENV_DIR = BUILD_BREEZE_DIR / "venv"
+BUILD_BREEZE_VENV_BIN_DIR = BUILD_BREEZE_VENV_DIR / "bin"
+BUILD_BREEZE_VENV_PIP = BUILD_BREEZE_VENV_BIN_DIR / "pip"
+BUILD_BREEZE_VENV_BREEZE = BUILD_BREEZE_VENV_BIN_DIR / "Breeze2"
+
+BREEZE_SOURCE_PATH = AIRFLOW_SOURCES_DIR / "dev" / "breeze"
+BREEZE_SETUP_CFG_PATH = BREEZE_SOURCE_PATH / "setup.cfg"
+
+BUILD_BREEZE_DIR.mkdir(parents=True, exist_ok=True)
+
+
+def needs_installation() -> bool:
+ """Returns true if Breeze's virtualenv needs (re)installation"""
+ if not BUILD_BREEZE_VENV_DIR.exists() or not
BUILD_BREEZE_CFG_SAVED.exists():
+ return True
+ with open(BREEZE_SETUP_CFG_PATH) as current, open(BUILD_BREEZE_CFG_SAVED)
as saved:
+ current_config, saved_config = current.read(), saved.read()
+ return current_config != saved_config
+
+
+def save_config():
+ """Saves cfg file to virtualenv to check if there is a need for
reinstallation of the virtualenv"""
+ with open(BREEZE_SETUP_CFG_PATH) as current, open(BUILD_BREEZE_CFG_SAVED,
"w") as saved:
+ saved.write(current.read())
Review comment:
TIL :). The Path is amazing :D
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]