Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes hostpython build with macOS venv #2159

Merged
merged 1 commit into from
Apr 29, 2020
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
# installs java 1.8, android's SDK/NDK and p4a
- make -f ci/makefiles/osx.mk
- export JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
script: make testapps-no-venv/armeabi-v7a
script: make testapps/armeabi-v7a
- <<: *testapps
name: Rebuild updated recipes
script: travis_wait 30 make docker/run/make/rebuild_updated_recipes
Expand Down
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ testapps/%: virtualenv
python setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=$($@_APP_ARCH)

testapps-no-venv/%:
pip3 install Cython==0.28.6
pip3 install -e .
$(eval $@_APP_ARCH := $(shell basename $*))
cd testapps/on_device_unit_tests/ && \
python3 setup.py apk --sdk-dir $(ANDROID_SDK_HOME) --ndk-dir $(ANDROID_NDK_HOME) \
--arch=$($@_APP_ARCH)

clean:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Glad that we can remove this!

find . -type d -name "__pycache__" -exec rm -r {} +
find . -type d -name "*.egg-info" -exec rm -r {} +
Expand Down
5 changes: 5 additions & 0 deletions pythonforandroid/recipes/hostpython3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from os.path import exists, join, isfile

from pythonforandroid.logger import shprint
from pythonforandroid.patching import is_version_lt
from pythonforandroid.recipe import Recipe
from pythonforandroid.util import (
BuildInterruptingException,
Expand Down Expand Up @@ -35,6 +36,10 @@ class Hostpython3Recipe(Recipe):
'''The default url to download our host python recipe. This url will
change depending on the python version set in attribute :attr:`version`.'''

patches = (
('patches/pyconfig_detection.patch', is_version_lt("3.8.3")),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now applying to anything lower than 3.8.3. Since this issue was also impacting some recent version of the 3.7 branch I thought it would be easier to go that way than being ultra ranging inside MINOR and PATCH with a complex expression (given MAJOR.MINOR.PATCH)

)

@property
def _exe_name(self):
'''
Expand Down
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

4 changes: 3 additions & 1 deletion pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from shutil import copy2

from pythonforandroid.logger import info, warning, shprint
from pythonforandroid.patching import version_starts_with
from pythonforandroid.patching import version_starts_with, is_version_lt
from pythonforandroid.recipe import Recipe, TargetPythonRecipe
from pythonforandroid.util import (
current_directory,
Expand Down Expand Up @@ -55,6 +55,8 @@ class Python3Recipe(TargetPythonRecipe):
name = 'python3'

patches = [
('patches/pyconfig_detection.patch', is_version_lt("3.8.3")),

# Python 3.7.1
('patches/py3.7.1_fix-ctypes-util-find-library.patch', version_starts_with("3.7")),
('patches/py3.7.1_fix-zlib-version.patch', version_starts_with("3.7")),
Expand Down
13 changes: 13 additions & 0 deletions pythonforandroid/recipes/python3/patches/pyconfig_detection.patch
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