Skip to content

[WIP] Fix configure for python's recipes when building from macOS #1682

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pythonforandroid.recipe import Recipe
from pythonforandroid.python import GuestPythonRecipe
from pythonforandroid.logger import shprint
from pythonforandroid.patching import is_darwin
import sh


Expand Down Expand Up @@ -31,7 +32,8 @@ class Python2Recipe(GuestPythonRecipe):
'patches/fix-filesystem-default-encoding.patch',
'patches/fix-gethostbyaddr.patch',
'patches/fix-posix-declarations.patch',
'patches/fix-pwd-gecos.patch']
'patches/fix-pwd-gecos.patch',
('patches/fix-configure-darwin.patch', is_darwin)]

configure_args = ('--host={android_host}',
'--build={android_build}',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
--- Python-2.7.15/configure.orig 2018-04-30 00:47:33.000000000 +0200
+++ Python-2.7.15/configure 2019-02-06 00:44:09.636369760 +0100
@@ -5481,7 +5481,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
INSTSONAME="$LDLIBRARY".$SOVERSION
;;
- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|Darwin*)
LDLIBRARY='libpython$(VERSION).so'
BLDLIBRARY='-L. -lpython$(VERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@@ -5514,7 +5514,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>
BLDLIBRARY='-L. -lpython$(VERSION)'
RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib}
;;
- Darwin*)
+ DDarwin*)
LDLIBRARY='libpython$(VERSION).dylib'
BLDLIBRARY='-L. -lpython$(VERSION)'
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
@@ -8594,6 +8594,9 @@ then
LDSHARED='ld -b'
fi ;;
OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";;
+ Darwin*|Linux*|GNU*|QNX*)
+ LDSHARED='$(CC) -shared'
+ LDCXXSHARED='$(CXX) -shared';;
Darwin/1.3*)
LDSHARED='$(CC) -bundle'
LDCXXSHARED='$(CXX) -bundle'
@@ -8653,9 +8656,6 @@ then
BLDSHARED="$LDSHARED"
fi
;;
- Linux*|GNU*|QNX*)
- LDSHARED='$(CC) -shared'
- LDCXXSHARED='$(CXX) -shared';;
BSD/OS*/4*)
LDSHARED="gcc -shared"
LDCXXSHARED="g++ -shared";;
4 changes: 3 additions & 1 deletion pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pythonforandroid.python import GuestPythonRecipe
from pythonforandroid.recipe import Recipe
from pythonforandroid.patching import is_darwin


class Python3Recipe(GuestPythonRecipe):
Expand All @@ -21,7 +22,8 @@ class Python3Recipe(GuestPythonRecipe):
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
name = 'python3'

patches = ["patches/fix-ctypes-util-find-library.patch"]
patches = ['patches/fix-ctypes-util-find-library.patch',
('patches/fix-configure-darwin.patch', is_darwin)]

depends = ['hostpython3']
conflicts = ['python3crystax', 'python2', 'python2legacy']
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
--- Python-3.7.1/configure.orig 2018-10-20 08:04:19.000000000 +0200
+++ Python-3.7.1/configure 2019-02-06 00:56:36.200362640 +0100
@@ -5916,7 +5916,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>
PY3LIBRARY=libpython3.so
fi
;;
- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*)
+ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|OpenBSD*|Darwin*)
LDLIBRARY='libpython$(LDVERSION).so'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=LD_LIBRARY_PATH=`pwd`${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
@@ -5938,7 +5938,7 @@ $as_echo "#define Py_ENABLE_SHARED 1" >>
BLDLIBRARY='-Wl,+b,$(LIBDIR) -L. -lpython$(LDVERSION)'
RUNSHARED=SHLIB_PATH=`pwd`${SHLIB_PATH:+:${SHLIB_PATH}}
;;
- Darwin*)
+ DDarwin*)
LDLIBRARY='libpython$(LDVERSION).dylib'
BLDLIBRARY='-L. -lpython$(LDVERSION)'
RUNSHARED=DYLD_LIBRARY_PATH=`pwd`${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}
@@ -9252,6 +9252,9 @@ then
LDSHARED='$(CC) -b'
LDCXXSHARED='$(CXX) -b'
fi ;;
+ Darwin*|Linux*|GNU*|QNX*)
+ LDSHARED='$(CC) -shared'
+ LDCXXSHARED='$(CXX) -shared';;
Darwin/1.3*)
LDSHARED='$(CC) -bundle'
LDCXXSHARED='$(CXX) -bundle'
@@ -9279,41 +9282,6 @@ then
LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
fi ;;
- Darwin/*)
- # Use -undefined dynamic_lookup whenever possible (10.3 and later).
- # This allows an extension to be used in any Python
-
- dep_target_major=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
- sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'`
- dep_target_minor=`echo ${MACOSX_DEPLOYMENT_TARGET} | \
- sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'`
- if test ${dep_target_major} -eq 10 && \
- test ${dep_target_minor} -le 2
- then
- # building for OS X 10.0 through 10.2
- LDSHARED='$(CC) -bundle'
- LDCXXSHARED='$(CXX) -bundle'
- if test "$enable_framework" ; then
- # Link against the framework. All externals should be defined.
- BLDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
- LDSHARED="$LDSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
- LDCXXSHARED="$LDCXXSHARED "'$(PYTHONFRAMEWORKPREFIX)/$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK)'
- else
- # No framework, use the Python app as bundle-loader
- BLDSHARED="$LDSHARED "'-bundle_loader $(BUILDPYTHON)'
- LDSHARED="$LDSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
- LDCXXSHARED="$LDCXXSHARED "'-bundle_loader $(BINDIR)/python$(VERSION)$(EXE)'
- fi
- else
- # building for OS X 10.3 and later
- LDSHARED='$(CC) -bundle -undefined dynamic_lookup'
- LDCXXSHARED='$(CXX) -bundle -undefined dynamic_lookup'
- BLDSHARED="$LDSHARED"
- fi
- ;;
- Linux*|GNU*|QNX*)
- LDSHARED='$(CC) -shared'
- LDCXXSHARED='$(CXX) -shared';;
FreeBSD*)
if [ "`$CC -dM -E - </dev/null | grep __ELF__`" != "" ]
then