-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes hostpython build with macOS venv
Running the freshly compiled host python binary from another Python process (e.g. sh module or os.system()) may get wrongly detected as if it was ran directly from the venv. This happens when `pyvenv.cfg` is present (e.g. venv/pyvenv.cfg). It makes `sysconfig.is_python_build()` returns `False` instead of `True` since it's using the compiled interpreter (e.g. ./build-dir/python). https://docs.python.org/3/library/sysconfig.html#sysconfig.is_python_build https://github.com/python/cpython/blob/v3.8.2/Lib/sysconfig.py#L127 This is because the `sys._home` attribute is used during the detection. The issue was first seen in macOS venv which generates the `pyvenv.cfg`. To compare both behaviours, try the following within and without a venv: ```python import os os.system("./build-dir/python -E -c 'import sysconfig; print(sysconfig._sys_home)'") ``` One would return `/usr/local/bin` and the other `None` Refs: - kivy/kivy-ios#401 - #2063
- Loading branch information
1 parent
e2b9cfe
commit b8f300f
Showing
6 changed files
with
31 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
pythonforandroid/recipes/hostpython3/patches/pyconfig_detection.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff -Nru Python-3.8.2/Lib/site.py Python-3.8.2-new/Lib/site.py | ||
--- Python-3.8.2/Lib/site.py 2020-04-28 12:48:38.000000000 -0700 | ||
+++ Python-3.8.2-new/Lib/site.py 2020-04-28 12:52:46.000000000 -0700 | ||
@@ -487,7 +487,8 @@ | ||
if key == 'include-system-site-packages': | ||
system_site = value.lower() | ||
elif key == 'home': | ||
- sys._home = value | ||
+ # this is breaking pyconfig.h path detection with venv | ||
+ print('Ignoring "sys._home = value" override') | ||
|
||
sys.prefix = sys.exec_prefix = site_prefix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
pythonforandroid/recipes/python3/patches/pyconfig_detection.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff -Nru Python-3.8.2/Lib/site.py Python-3.8.2-new/Lib/site.py | ||
--- Python-3.8.2/Lib/site.py 2020-04-28 12:48:38.000000000 -0700 | ||
+++ Python-3.8.2-new/Lib/site.py 2020-04-28 12:52:46.000000000 -0700 | ||
@@ -487,7 +487,8 @@ | ||
if key == 'include-system-site-packages': | ||
system_site = value.lower() | ||
elif key == 'home': | ||
- sys._home = value | ||
+ # this is breaking pyconfig.h path detection with venv | ||
+ print('Ignoring "sys._home = value" override') | ||
|
||
sys.prefix = sys.exec_prefix = site_prefix | ||
|