potiuk commented on a change in pull request #19992:
URL: https://github.com/apache/airflow/pull/19992#discussion_r762586811



##########
File path: Breeze2
##########
@@ -41,11 +43,21 @@ def save_config():
 
 if needs_installation():
     print(f"(Re)Installing Breeze's virtualenv in {BUILD_BREEZE_VENV_DIR}")
-    BUILD_BREEZE_VENV_DIR.mkdir(parents=True, exist_ok=True)
-    subprocess.run([sys.executable, "-m", "venv", f"{BUILD_BREEZE_VENV_DIR}"], 
check=True)
-    subprocess.run(
-        [f"{BUILD_BREEZE_VENV_PIP}", "install", "--upgrade", "-e", "."], 
cwd=BREEZE_SOURCE_PATH, check=True
+    EnvBuilder(system_site_packages=False, upgrade=True, with_pip=True, 
prompt="breeze").create(
+        str(BUILD_BREEZE_VENV_DIR)
     )
+    if os.name == 'nt':
+        subprocess.run(
+            [f"{BUILD_BREEZE_VENV_PYTHON}.exe", "-m", "pip", "install", 
"--upgrade", "-e", "."],
+            cwd=BREEZE_SOURCE_PATH,
+            check=True,
+        )
+    else:
+        subprocess.run(
+            [f"{BUILD_BREEZE_VENV_PYTHON}", "-m", "pip", "install", 
"--upgrade", "-e", "."],
+            cwd=BREEZE_SOURCE_PATH,
+            check=True,
+        )

Review comment:
       Some more info:  the main problem was "trying" to create venv from 
within the "frozen" python script (in bundled .exe file). I debugged it quite a 
bit  and I've learned quite a lot about those things. 
   
   The "frozen" python binary does not run using executable interpreter. This 
was a bit surprising -  it actually uses a python interpereter library, which 
you cannot "execute" modules with. And `sys.executable` is surprisingly the 
actual .exe file that was run :scream:  (so in our case ./Breeze2.exe).  
@edithturn  - that's why you got those repeating "creating environement| 
messages - the python code simply continued to re-run the `Breeze2.exe` on 
failure of trying to create an evnironment using the API.
   
   And creating using the API failed for a different reason. First of all 
ensurepip is run "implicitly" by "venv create" and pip installer when prepares 
a bundle, only uses modules thata are actually used by the python script (and 
ensurepip was not detected). 
   
   But even if I used `---hidden-import` flag of the `pyinstaller` and added it 
(Pyinstaller is actually quite configurable), the `ensurepip` when installing 
PIP in the environment, also uses the python interpreter executable :scream: 
and of course gets into another endless loop.
   




-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to