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

作者你好,在IOS9.0.2中安装python,运行报错? #3

Open
jlzsss opened this issue Oct 18, 2015 · 26 comments
Open

作者你好,在IOS9.0.2中安装python,运行报错? #3

jlzsss opened this issue Oct 18, 2015 · 26 comments

Comments

@jlzsss
Copy link

jlzsss commented Oct 18, 2015

报错信息如下:
dyld: Library not loaded: /usr/lib/libpython2.7.dylib
Referenced from: /usr/bin/python
Reason: no suitable image found. Did find:
/usr/lib/libpython2.7.dylib: mmap() error 22 at address=0x00242000, size=0x0002A000 segment=__DATA in Segment::map() mapping /usr/lib/libpython2.7.dylib
/usr/lib/libpython2.7.dylib: mmap() error 22 at address=0x003D6000, size=0x0002A000 segment=__DATA in Segment::map() mapping /usr/lib/libpython2.7.dylib
Trace/BPT trap: 5

@Tatsh
Copy link

Tatsh commented Oct 31, 2015

build.sh partial patch (Xcode 7.1):

diff --git a/build.sh b/build.sh
index b25c269..073bdc8 100755
--- a/build.sh
+++ b/build.sh
@@ -32,7 +32,7 @@ echo "[Script by Linus Yang]"
 echo ""

 # sdk variable
-export IOS_VERSION="5.1"
+export IOS_VERSION="9.1"
 export DEVROOT=$("xcode-select" -print-path)"/Platforms/iPhoneOS.platform/Developer"
 export SDKROOT="$DEVROOT/SDKs/iPhoneOS${IOS_VERSION}.sdk"

@@ -69,7 +69,7 @@ fi
 # download python
 echo '[Fetching Python source code]'
 if [[ ! -a Python-${PYVER}.tar.xz ]]; then
-    curl -O http://www.python.org/ftp/python/${PYVER}/Python-${PYVER}.tar.xz
+    curl -L -O http://www.python.org/ftp/python/${PYVER}/Python-${PYVER}.tar.xz
 fi

 # extract dependency library
@@ -79,20 +79,20 @@ tar zxf "${PRELIB}" -C "${PRELIBFIX}"

 # get rid of old build
 rm -rf Python-${PYVER}
-tar Jxf Python-${PYVER}.tar.xz
+/usr/bin/tar Jxf Python-${PYVER}.tar.xz
 pushd ./Python-${PYVER} > /dev/null 2>&1

 # build for native machine
 echo '[Building for host system]'
 SAVESDK="$SDKROOT"
 export SDKROOT=""
-./configure > /dev/null 2>&1
-make > /dev/null 2>&1
+./configure
+make
 mv python.exe python.exe_for_build
 mv Parser/pgen Parser/pgen_for_build
 mv build "$PRELIBLOC/build_host"
 mv pybuilddir.txt pybuilddir_host.txt
-sed -i '' 's:build/:build_host/:g' pybuilddir_host.txt
+/usr/bin/sed -i '' 's:build/:build_host/:g' pybuilddir_host.txt
 make distclean > /dev/null 2>&1
 export SDKROOT="$SAVESDK"

@@ -103,7 +103,7 @@ patch -p1 < ../patches/Python-xcompile-${PYVER}.patch
 export CPPFLAGS="-I$SDKROOT/usr/include/ -I$PRELIBLOC/usr/include"
 export CFLAGS="$CPPFLAGS -pipe -isysroot $SDKROOT"
 export CXXFLAGS="$CFLAGS"
-export LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=3.0 -L$SDKROOT/usr/lib/ -L$PRELIBLOC/usr/lib"
+export LDFLAGS="-isysroot $SDKROOT -miphoneos-version-min=3.0 -L$SDKROOT/usr/lib/ -L$PRELIBLOC/usr/lib -segalign 4000"
 export CC="$NATICC"
 export CXX="$NATICXX"
 export LD="$DEVROOT/usr/bin/ld"
@@ -111,7 +111,7 @@ export OPT="-DNDEBUG -O3 -Wall -Wstrict-prototypes"

 # build for iphone
 echo '[Cross compiling for Darwin ARM]'
-./configure --prefix=/usr --enable-ipv6 --host=arm-apple-darwin --build=x86_64-apple-darwin --enable-shared --disable-toolbox-glue --with-signal-module --with-system-ffi --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes > /dev/null 2>&1
+./configure --prefix=/usr --enable-ipv6 --host=arm-apple-darwin --build=x86_64-apple-darwin --enable-shared --disable-toolbox-glue --with-signal-module --with-system-ffi --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes
 make
 mv "$PRELIBLOC/build_host" .
 make install prefix="$PWD/_install/usr" > /dev/null 2>&1
@@ -124,7 +124,7 @@ chmod +x "$LDIDLOC"
 # symlink binary
 cd "${NOWDIR}/Python-${PYVER}/_install/usr/bin"
 ln -sf python${PYSHORT} python
-sed -i '' "s:${NOWDIR}/Python-${PYVER}/_install::g" python${PYSHORT}-config
+/usr/bin/sed -i '' "s:${NOWDIR}/Python-${PYVER}/_install::g" python${PYSHORT}-config
 cd "${NOWDIR}"

 # make debian package

Fails at:

[Cross compiling for Darwin ARM]
./configure --prefix=/usr --enable-ipv6 --host=arm-apple-darwin --build=x86_64-apple-darwin --enable-shared --disable-toolbox-glue --with-signal-module --with-s
ystem-ffi --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes
+ ./configure --prefix=/usr --enable-ipv6 --host=arm-apple-darwin --build=x86_64-apple-darwin --enable-shared --disable-toolbox-glue --with-signal-module --with
-system-ffi --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes
checking build system type... x86_64-apple-darwin
checking host system type... arm-apple-darwin
checking for python interpreter for cross build... checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... darwin
checking EXTRAPLATDIR... $(PLATMACDIRS)
checking for --without-gcc... no
checking for arm-apple-darwin-gcc... /usr/bin/arm-apple-darwin9-gcc
checking whether the C compiler works... no
configure: error: in `/Users/tatsh/dev/python-for-ios/Python-2.7.6':
configure: error: C compiler cannot create executables
See `config.log' for more details

不存在/usr/bin/arm-apple-darwin9-gcc。iOS 9.1 SDK (clang)不知道该怎么。:(

@jdelman
Copy link

jdelman commented Nov 17, 2015

I was able to get it running on OS X El Capitan with Xcode 7 & the iOS 9.1 SDK.

See https://github.com/jdelman/python-for-ios and checkout branch arm64.

@Tatsh
Copy link

Tatsh commented Nov 17, 2015

Cool except jdelman@83381dc#diff-46cb3d86e30c6dd7e235dbd05f49b19fR16 . Doesn't this make os.environ always have an empty dict? from os import environ; environ

I do not know if there is a good workaround without using Objective-C at this point. _NSGetEnviron() is not documented and environ (global char **) apparently does not work as expected on OS X and iOS.

With Objective-C, and telling the compiler to use that language for that file (-x objective-c, rename to .m maybe works too), you could call [[NSProcessInfo processInfo] environment] but you would have to convert the NSDictionary of NSStrings back to a regular char ** ('KEY=VALUE' for each).

NSDictionary *objectiveCEnv = [[NSProcessInfo processInfo] environment];
for (NSString *aKey in objectiveCEnv) {
    char *tmp = [[NSString stringWithFormat:@"%@=%@", aKey, objectiveCEnv[aKey]] UTF8String];
   // ...
}

@jdelman
Copy link

jdelman commented Nov 17, 2015

Good point, I hacked it together haphazardly & blindly without realizing
the environment meant... the environment - I don't really know what I'm
doing.

I fired it up after that and saw I also couldn't import math, or urllib2
(couldn't "import _socket").

Are you saying you'd replace crt_externs.h with that Obj-C code?

On Mon, Nov 16, 2015 at 7:55 PM, Andrew Udvare [email protected]
wrote:

Cool except jdelman/python-for-ios@83381dc#diff-46cb3d86e30c6dd7e235dbd05f49b19fR16
jdelman@83381dc#diff-46cb3d86e30c6dd7e235dbd05f49b19fR16
. Doesn't this make os.environ always have an empty dict? from os import
environ; environ

I do not know if there is a good workaround without using Objective-C at
this point. _NSGetEnviron() is not documented and environ (global char
**) apparently does not work as expected on OS X and iOS.

With Objective-C, and telling the compiler to use that language for that
file (-x objective-c, rename to .m maybe works too), you could call [[NSProcessInfo
processInfo] environment] but you would have to convert the NSDictionary
of NSStrings back to a regular char ** ('KEY=VALUE' for each).

NSDictionary *objectiveCEnv = [[NSProcessInfo processInfo] environment];for (NSString *aKey in objectiveCEnv) {
char *tmp = [[NSString stringWithFormat:@"%@=%@", aKey, objectiveCEnv[aKey]] UTF8String];
// ...
}


Reply to this email directly or view it on GitHub
#3 (comment)
.

@Tatsh
Copy link

Tatsh commented Nov 17, 2015

Nah, I think if char **environ works on iOS, otherwise it will just return NULL. But the code already checks for that. You only needed to remove the direct call to _NSGetEnviron() because it does not exist on iOS (anymore I think). Otherwise you are missing a link to libSystem (libSystem is supposed to have it).

@Tatsh
Copy link

Tatsh commented Nov 17, 2015

Also with regard to some modules, I do not think all the modules worked in the previous build either.

@teknogeek
Copy link

@jdelman any news on this? Would love to get python working on iOS 9

@formoon
Copy link

formoon commented Dec 9, 2015

Mark and wait for ios9 version

@formoon
Copy link

formoon commented Dec 15, 2015

https://www.dropbox.com/s/qp862ppjz3rzi81/Python-2.7.8-arm64.zip?dl=0
This one seems work for me, find this link from:
http://iphonedevwiki.net/index.php/Updating_extensions_for_iOS_9

Only install python it self may work, but I install all deb package.
need ldid -S /usr/bin/python2.7 first else will get kill -9 error.

@jdelman
Copy link

jdelman commented Dec 18, 2015

@formoon What model iPhone are you running that on? Is it a 32-bit (iPhone 5 and earlier) or 64-bit (iPhone 5S and later) model?

@formoon
Copy link

formoon commented Dec 18, 2015

64bit iPhone6s.
andrew

发自我的 iPhone

在 2015年12月19日,06:05,Josh Delman [email protected] 写道:

@formoon What model iPhone are you running that on? Is it a 32-bit (iPhone 5 and earlier) or 64-bit (iPhone 5S and later) model?


Reply to this email directly or view it on GitHub.

@YangTakeshi
Copy link

YangTakeshi commented Sep 3, 2016

@formoon I had installed Python 2.7.6 for iOS (build 3),and ldid -S /usr/bin/python2.7,but I still get killed 9 error,ipad air2 (9.3.3)

@andrewfree
Copy link

@formoon I had installed Python 2.7.6 for iOS (build 3),and ldid -S /usr/bin/python2.7,but I still get killed 9 error,ipad air2 (9.3.3)

I am getting the same error after the same steps on iPhone 6S 9.3.3

@Tatsh
Copy link

Tatsh commented Sep 4, 2016

Building fixed for 9.3 but not everything works.

Tatsh@1525f3d

@liuxuan30
Copy link

liuxuan30 commented Sep 13, 2016

@jdelman I forked your repo and can build, however seeing 'No module named select' while trying to import subprocess. Any idea?

Seeing logs:

Failed to build these modules:
_bisect            _bsddb             _codecs_cn      
_codecs_hk         _codecs_iso2022    _codecs_jp      
_codecs_kr         _codecs_tw         _collections    
_csv               _ctypes            _ctypes_test    
_curses            _curses_panel      _elementtree    
_functools         _hashlib           _heapq          
_hotshot           _io                _json           
_locale            _lsprof            _multibytecodec 
_multiprocessing   _random            _socket         
_ssl               _struct            _testcapi       
array              audioop            binascii        
cmath              cPickle            crypt           
cStringIO          datetime           dbm             
fcntl              future_builtins    grp             
itertools          math               mmap            
operator           parser             pyexpat         
readline           resource           select          
strop              syslog             termios         
time               unicodedata      

@Tatsh
Copy link

Tatsh commented Sep 13, 2016

There is a ton of stuff to fix to make this work fully again (or usefully). Some of those are not fixable (easily) but most are. They require libraries to be present, some of which don't exist on Cydia. You really should go for modularism here and build those libraries as separate packages for Cydia and then build Python based on those. It will help many projects to have updated libraries.

@cclamb
Copy link

cclamb commented Oct 12, 2016

I was able to build a version for IOS 9 from jdelman's branch; is that going to be merged into this mainline? also, is anybody actively working these issues that @Tatsh references above?

@cclamb
Copy link

cclamb commented Oct 12, 2016

...also, this is a link to the DEB file I built and installed on 9.3.3 with the Pangu break:

https://drive.google.com/open?id=0B5vZIFDVHQ19d25KY2xlbUdLVzQ

Perhaps you guys could make this available as a release, with caveats?

@Tatsh
Copy link

Tatsh commented Oct 12, 2016

@cclamb if you made any improvements, please provide a patch or set of patches.

@cclamb
Copy link

cclamb commented Oct 12, 2016

No, I haven't touched the code yet, but I was able to build the arm64 branch of the repo @jdelman forked; maybe he could submit a pull request? I could not build from master on this repo, which is why I'm asking.

I'm happy to pitch in, but I don't see any specific issues in the issue tracker than need to be fixed, though I see a few things alluded to here. Is anybody actively tracking these yet?

@Tatsh
Copy link

Tatsh commented Oct 12, 2016

Well, jdelman@83381dc is not exactly the same as my patch. We need to merge these results. And then keep going. Also need to future-proof for iOS 10 in this effort. The code should compile for a non-jailbroken updated iOS 10 device, and still work with iOS 9.3.3, maybe 9.0.2 for those stuck behind.

@cclamb
Copy link

cclamb commented Oct 12, 2016

Ah, okay. So your patch isn't pushed. Do I just need to apply the patchfile above?

@Tatsh
Copy link

Tatsh commented Oct 12, 2016

Compare Tatsh@1525f3d with jdelman@83381dc and see what's new and what's improved in @jdelman's version. He seems to have a new patch there for the environ module.

Also note full paths (like /usr/bin/sed) in mine as the Makefile is for OS X, so we force the use of BSD coreutils instead of GNU. OS X comes with BSD, not GNU. Supporting both with conditionals in the Makefile could be an option in the future.

@masbog
Copy link

masbog commented Jan 31, 2017

@Tatsh always get error on compile for 64 bit from your repo,

configure: error: in `/Users/masbog/GitHub/python-for-ios/Python-2.7.6':

configure: error: C compiler cannot create executables

See `config.log' for more details

and config.log said :

-----------

confdefs.h.

-----------

/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1
#define _XOPEN_SOURCE 600
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200112L

configure: exit 77

any suggestion for fix it? i use xCode 8.2.1 ☹️

@Tatsh
Copy link

Tatsh commented Jan 31, 2017

I don't get that error and the only difference now is this (master branch on my repo):

diff --git a/build.sh b/build.sh
index 7f91eca..6b3c3c2 100755
--- a/build.sh
+++ b/build.sh
@@ -32,7 +32,7 @@ echo "[Script by Linus Yang]"
 echo ""

 # sdk variable
-export IOS_VERSION="9.3"
+export IOS_VERSION="10.2"
 export DEVROOT=$("xcode-select" -print-path)"/Platforms/iPhoneOS.platform/Developer"
 export SDKROOT="$DEVROOT/SDKs/iPhoneOS${IOS_VERSION}.sdk"

@masbog
Copy link

masbog commented Feb 1, 2017

damn... something wrong with my env... 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants