Giter VIP home page Giter VIP logo

python-apple-support's Introduction

Python Apple Support

This is a meta-package for building a version of Python that can be embedded into a macOS, iOS, tvOS or watchOS project.

This branch builds a packaged version of Python 3.13.0. Other Python versions are available by cloning other branches of the main repository:

It works by downloading, patching, and building a fat binary of Python and selected pre-requisites, and packaging them as static libraries that can be incorporated into an XCode project. The binary modules in the Python standard library are statically compiled, but are distributed as objects that can be dynamically loaded at runtime.

It exposes almost all the modules in the Python standard library except for:

  • dbm.gnu
  • tkinter
  • readline
  • nis (Deprecated by PEP594)
  • ossaudiodev (Deprecated by PEP594)
  • spwd (Deprecated by PEP594)

The following standard library modules are available on macOS, but not the other Apple platforms:

  • curses
  • grp
  • multiprocessing
  • posixshmem
  • posixsubprocess
  • syslog

The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV devices; and arm64_32 for watchOS. It also supports device simulators on both x86_64 and M1 hardware. This should enable the code to run on:

  • macOS 11 (Big Sur) or later, on:
    • MacBook (including MacBooks using Apple Silicon)
    • iMac (including iMacs using Apple Silicon)
    • Mac Mini (including Apple Silicon Mac minis)
    • Mac Studio (all models)
    • Mac Pro (all models)
  • iOS 12.0 or later, on:
    • iPhone (6s or later)
    • iPad (5th gen or later)
    • iPad Air (all models)
    • iPad Mini (2 or later)
    • iPad Pro (all models)
    • iPod Touch (7th gen or later)
  • tvOS 9.0 or later, on:
    • Apple TV (4th gen or later)
  • watchOS 4.0 or later, on:
    • Apple Watch (4th gen or later)

Quickstart

The easist way to use these packages is by creating a project with Briefcase. Briefcase will download pre-compiled versions of these support packages, and add them to an Xcode project (or pre-build stub application, in the case of macOS).

Pre-built versions of the frameworks can be downloaded from the Github releases page and added to your project.

Alternatively, to build the frameworks on your own, download/clone this repository, and then in the root directory, and run:

  • make (or make all) to build everything.
  • make macOS to build everything for macOS.
  • make iOS to build everything for iOS.
  • make tvOS to build everything for tvOS.
  • make watchOS to build everything for watchOS.

This should:

  1. Download the original source packages
  2. Patch them as required for compatibility with the selected OS
  3. Build the packages as Xcode-compatible XCFrameworks.

The resulting support packages will be packaged as a .tar.gz file in the dist folder.

Each support package contains:

  • VERSIONS, a text file describing the specific versions of code used to build the support package;
  • bin, a folder containing shell aliases for the compilers that are needed to build packages. This is required because Xcode uses the xcrun alias to dynamically generate the name of binaries, but a lot of C tooling expects that CC will not contain spaces.
  • platform-site, a folder that contains site customization scripts that can be used to make your local Python install look like it is an on-device install for each of the underlying target architectures supported by the platform. This is needed because when you run pip you'll be on a macOS machine with a specific architecture; if pip tries to install a binary package, it will install a macOS binary wheel (which won't work on iOS/tvOS/watchOS). However, if you add the platform-site folder to your PYTHONPATH when invoking pip, the site customization will make your Python install return platform and sysconfig responses consistent with on-device behavior, which will cause pip to install platform-appropriate packages.
  • Python.xcframework, a multi-architecture build of the Python runtime library
  • python-stdlib, the code and binary modules comprising the Python standard library. On iOS, tvOS and watchOS, there are 2 copies of every binary module - one for physical devices, and one for the simulator. The simulator binaries are "fat", containing code for both x86_64 and arm64.

For a detailed instructions on using the support package in your own project, see the usage guide

Building binary wheels

When building binary wheels, you may need to use the libraries built by this project as inputs (e.g., the cffi module uses libffi). To support this, this project is able to package these dependencies as "wheels" that can be added to the dist directory of the Mobile Forge project.

To build these wheels, run:

  • make wheels to make all wheels for all mobile platforms
  • make wheels-iOS to build all the iOS wheels
  • make wheels-tvOS to build all the tvOS wheels
  • make wheels-watchOS to build all the watchOS wheels

Historical support

The following versions were supported in the past, but are no longer maintained:

python-apple-support's People

Contributors

afh avatar ambv avatar cculianu avatar dependabot[bot] avatar efroemling avatar eldare avatar freakboy3742 avatar mhsmith avatar mkhon avatar rmartin16 avatar samschott avatar samueljohn avatar tnymlr avatar weitieda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-apple-support's Issues

Why is Python being built with --without-pymalloc

Is there any particular reason? The default is to use pymalloc nowadays, so when I build an extension using an installed Python version, it is built against the 'm' ABI and won't work with the Python embedded by briefcase.

OpenSSL

Hi all,
I'm not able to import OpenSSL
using
from OpenSSL import SSL
Is there really this module ?

Minimal Python

Hi,

I would like to use Python as a scripting language on Android and iOS, to reuse lots of code. On Android libpython + std lib is no more than 6Mo, but with Python-Apple-Support by default the size for iOS is insanely huge.

Is there a way to build a minimal Python distribution (without openssl, bzip, sqlite, etc) ?
Thanks in advance.

Support IPv6

I needed IPv6 support for my project, simply changing --disable-ipv6 to --enable-ipv6 worked fine for me. Perhaps make this the default or configurable?

unknow? ???

$ make iOS to build everything for iOS.

Unpack sources

mkdir -p build/iOS/bzip2-1.0.6-iphonesimulator.x86_64
tar zxf downloads/bzip2-1.0.6.tgz --strip-components 1 -C build/iOS/bzip2-1.0.6-iphonesimulator.x86_64
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.
make: *** [build/iOS/bzip2-1.0.6-iphonesimulator.x86_64/Makefile] Error 1

Native Binary Package: Cryptodome -- Help/Advice/Etc needed

Hi,

I am the developer of the iOS app "Electron Cash", which uses rubicon-objc and briefcase. Our app is here and it's out already: https://itunes.apple.com/us/app/electron-cash/id1359700089?ls=1&mt=8

I have you guys to thank for developing these wonderful tools to get the app up and running!

However -- I have come to realize that performance of my app suffers a bit, and would like to be able to include native crypto packages such as pycryptodome.

So -- I have no idea where to begin. I managed to cross-compile pycryptodome and tried to "drop it in" to my project. It fails with OSError on import, unable to open/import the .so files. Is this because it has .so files -- which I think iOS doesn't allow, correct? And I presume .so file importing is turned-off on the libPython.a you guys supply -- right?

I noticed numpy does a few special things to statically build and link to the main executable. This is the strategy I have to adopt, correct?

Any chance I can somehow leverage this Python-Apple-Support system to build Cryptodome and add it to my app_packages?

Any guidance is appreciated! Thanks!

No module named 'encodings' error

Hi! When I try launch template .xcodeproj with precompiled python binaries, I got these debug output:

2018-03-18 14:20:35.485239+0300 HelloPybee[66124:4105073] PythonHome is: /Users/jasf/Library/Developer/CoreSimulator/Devices/A24A9373-8EDC-4AD2-8030-B091237C356C/data/Containers/Bundle/Application/4F743C7C-DF80-41D2-A6DD-4D97EBFAFCC2/HelloPybee.app/Library/Python
2018-03-18 14:20:35.488258+0300 HelloPybee[66124:4105073] PYTHONPATH is: PYTHONPATH=/Users/jasf/Library/Developer/CoreSimulator/Devices/A24A9373-8EDC-4AD2-8030-B091237C356C/data/Containers/Bundle/Application/4F743C7C-DF80-41D2-A6DD-4D97EBFAFCC2/HelloPybee.app/Library/Application Support/com.example.hellopybee.appname/app:/Users/jasf/Library/Developer/CoreSimulator/Devices/A24A9373-8EDC-4AD2-8030-B091237C356C/data/Containers/Bundle/Application/4F743C7C-DF80-41D2-A6DD-4D97EBFAFCC2/HelloPybee.app/Library/Application Support/com.example.hellopybee.appname/app_packages
2018-03-18 14:20:35.488451+0300 HelloPybee[66124:4105073] Initializing Python runtime
HelloPybee was compiled with optimization - stepping may behave oddly; variables may not be available.
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000000114da3380 (most recent call first):

I try different versions of Python, and always get these error. Please help and thanks for you work! :)

adding packages to your frameworks

It's not clear to me how to add python packages (with compiled components) to your projects (i.e., pip install $something). If I want to use Pandas in an iOS app, how can I go about this?

App approval in the iOS store

I was wondering if there are any known issues with using the python iOS frameworks in apps that are approved and are in Apple's app store. I can report that I have successfully gotten to the Testlight stage with Apple with no issues, but I know apple can be restrictive with their final approval process. Are there examples of apps that have gone through final approval, anything to watch out for? Thanks

No module named '_sysconfigdata_m_ios_darwin' error

Hi, I downloaded a project by using "Python-3.6-iOS-support.b1" . It can run successfully with those 4 .framework files. But when I substitute them with "Python-3.6-iOS-support.b7" (four .a files in it) , it can build successfully but cannot run. The error messages are as follows:

2018-08-06 17:53:47.242895+0800 Dishuhu Malala Arkuyaya[41445:3576603] PythonHome is: /Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources
2018-08-06 17:53:47.245397+0800 Dishuhu Malala Arkuyaya[41445:3576603] Initializing Python runtime
Failed to import the site module
Traceback (most recent call last):
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/site.py", line 547, in
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/site.py", line 533, in main
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/site.py", line 285, in addusersitepackages
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/site.py", line 258, in getusersitepackages
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/site.py", line 248, in getuserbase
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/sysconfig.py", line 635, in get_config_var
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/sysconfig.py", line 584, in get_config_vars
File "/Users/loyvsteve/Library/Developer/CoreSimulator/Devices/202A2C2F-45DD-4A61-A575-477E2D757C4C/data/Containers/Bundle/Application/E967194F-3628-42D1-A963-AE523028D3E9/Dishuhu Malala Arkuyaya.app/Library/Python.framework/Resources/lib/python36.zip/sysconfig.py", line 455, in _init_posix
ModuleNotFoundError: No module named '_sysconfigdata_m_ios_darwin'

Minimize and compress the standard library

The lib/pythonX.Y directory can be replaced with lib/pythonXY.zip, which drastically reduces the size of the distribution. To further reduce the size needed for the standard library, it's possible to only include the pyc files in the zip file.

The size of lib/python3.5 for a macOS x86_64 distribution:

  • as is: 117 MB
  • without the test directory: 63 MB
  • with only the opt-2.pyc files: 23 MB
  • zipped: 9.2 MB

It should be possible to reduce this even more, as the python35.zip included with Windows x86-64 embeddable Python 3.5.2 distribution is only 2.2 MB. Perhaps it's possible to use make_zip.py from the CPython repository that is used to created the Windows embeddable distributions.

Error while building for iOS/macOS

xcrun libtool -no_warning_for_no_symbols -static -o build/iOS/Support/OpenSSL/libOpenSSL.a build/iOS/libssl.a build/iOS/libcrypto.a

Build target Python

cd build/macOS/Python-3.6.4-macosx.x86_64 && PATH=/Users/sekkit/Work/Python-Apple-support/build/macOS/Python-3.6.4-macosx.x86_64/dist/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/sw/bin:/sw/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin make all install
/bin/sh: Workbooks.app/Contents/SharedSupport/path-bin: No such file or directory
make: *** [build/macOS/Python-3.6.4-macosx.x86_64/dist/lib/libpython3.6m.a] Error 127

import Numpy Compiler Error

I try to use PyImport_AppendInittab import PyInit_multiarray.
But Xcode Show Compiler Error

Undefined symbols for architecture arm64:
  "_PyInit_multiarray", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture arm64

Python 3.5 and 2.7 Failed to build on 8.3

Both stopped when compiling python for iOS

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/sqlite3.h:5479:16: note:
'sqlite3_enable_shared_cache' has been explicitly marked deprecated here
SQLITE_API int sqlite3_enable_shared_cache(int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_2_0, __IPHONE_5_0);
^
1 warning generated.
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -miphoneos-version-min=7.0 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -I./Modules/_sqlite -DMODULE_NAME='"sqlite3"' -DSQLITE_OMIT_LOAD_EXTENSION -c ./Modules/_sqlite/prepare_protocol.c -o Modules/prepare_protocol.o
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -miphoneos-version-min=7.0 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -I./Modules/_sqlite -DMODULE_NAME='"sqlite3"' -DSQLITE_OMIT_LOAD_EXTENSION -c ./Modules/_sqlite/row.c -o Modules/row.o
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -miphoneos-version-min=7.0 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -I./Modules/_sqlite -DMODULE_NAME='"sqlite3"' -DSQLITE_OMIT_LOAD_EXTENSION -c ./Modules/_sqlite/statement.c -o Modules/statement.o
./Modules/_sqlite/statement.c:334:19: warning: 'sqlite3_transfer_bindings' is deprecated [-Wdeprecated-declarations]
(void)sqlite3_transfer_bindings(self->st, new_st);
^
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk/usr/include/sqlite3.h:4552:34: note:
'sqlite3_transfer_bindings' has been explicitly marked deprecated here
SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
^
1 warning generated.
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -miphoneos-version-min=7.0 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -I./Modules/_sqlite -DMODULE_NAME='"sqlite3"' -DSQLITE_OMIT_LOAD_EXTENSION -c ./Modules/_sqlite/util.c -o Modules/util.o
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -miphoneos-version-min=7.0 -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -I. -I./Include -DPy_BUILD_CORE -I./../OpenSSL.framework/Headers -c ./Modules/_ssl.c -o Modules/_ssl.o
./Modules/_ssl.c:67:10: fatal error: 'openssl/rsa.h' file not found
#include "openssl/rsa.h"
^
1 error generated.
make[1]: *** [Modules/_ssl.o] Error 1
make: *** [build/iOS/Python-3.5.3-iphonesimulator.x86_64/dist/lib/libpython3.5m.a] Error 2

and after the error occurred I've checked OpenSSL build folder it doesn't seems to be a problem here.

tree build/iOS/OpenSSL.framework/Headers
build/iOS/OpenSSL.framework/Headers
└── openssl
├── aes.h -> ../../crypto/aes/aes.h
├── asn1.h -> ../../crypto/asn1/asn1.h
├── asn1_mac.h -> ../../crypto/asn1/asn1_mac.h
├── asn1t.h -> ../../crypto/asn1/asn1t.h
├── bio.h -> ../../crypto/bio/bio.h
├── blowfish.h -> ../../crypto/bf/blowfish.h
├── bn.h -> ../../crypto/bn/bn.h
├── buffer.h -> ../../crypto/buffer/buffer.h
├── camellia.h -> ../../crypto/camellia/camellia.h
├── cast.h -> ../../crypto/cast/cast.h
├── cmac.h -> ../../crypto/cmac/cmac.h
├── cms.h -> ../../crypto/cms/cms.h
├── comp.h -> ../../crypto/comp/comp.h
├── conf.h -> ../../crypto/conf/conf.h
├── conf_api.h -> ../../crypto/conf/conf_api.h
├── crypto.h -> ../../crypto/crypto.h
├── des.h -> ../../crypto/des/des.h
├── des_old.h -> ../../crypto/des/des_old.h
├── dh.h -> ../../crypto/dh/dh.h
├── dsa.h -> ../../crypto/dsa/dsa.h
├── dso.h -> ../../crypto/dso/dso.h
├── dtls1.h -> ../../ssl/dtls1.h
├── e_os2.h -> ../../e_os2.h
├── ebcdic.h -> ../../crypto/ebcdic.h
├── ec.h -> ../../crypto/ec/ec.h
├── ecdh.h -> ../../crypto/ecdh/ecdh.h
├── ecdsa.h -> ../../crypto/ecdsa/ecdsa.h
├── engine.h -> ../../crypto/engine/engine.h
├── err.h -> ../../crypto/err/err.h
├── evp.h -> ../../crypto/evp/evp.h
├── hmac.h -> ../../crypto/hmac/hmac.h
├── idea.h -> ../../crypto/idea/idea.h
├── krb5_asn.h -> ../../crypto/krb5/krb5_asn.h
├── kssl.h -> ../../ssl/kssl.h
├── lhash.h -> ../../crypto/lhash/lhash.h
├── md4.h -> ../../crypto/md4/md4.h
├── md5.h -> ../../crypto/md5/md5.h
├── mdc2.h -> ../../crypto/mdc2/mdc2.h
├── modes.h -> ../../crypto/modes/modes.h
├── obj_mac.h -> ../../crypto/objects/obj_mac.h
├── objects.h -> ../../crypto/objects/objects.h
├── ocsp.h -> ../../crypto/ocsp/ocsp.h
├── opensslconf.h -> ../../crypto/opensslconf.h
├── opensslv.h -> ../../crypto/opensslv.h
├── ossl_typ.h -> ../../crypto/ossl_typ.h
├── pem.h -> ../../crypto/pem/pem.h
├── pem2.h -> ../../crypto/pem/pem2.h
├── pkcs12.h -> ../../crypto/pkcs12/pkcs12.h
├── pkcs7.h -> ../../crypto/pkcs7/pkcs7.h
├── pqueue.h -> ../../crypto/pqueue/pqueue.h
├── rand.h -> ../../crypto/rand/rand.h
├── rc2.h -> ../../crypto/rc2/rc2.h
├── rc4.h -> ../../crypto/rc4/rc4.h
├── ripemd.h -> ../../crypto/ripemd/ripemd.h
├── rsa.h -> ../../crypto/rsa/rsa.h
├── safestack.h -> ../../crypto/stack/safestack.h
├── seed.h -> ../../crypto/seed/seed.h
├── sha.h -> ../../crypto/sha/sha.h
├── srp.h -> ../../crypto/srp/srp.h
├── srtp.h -> ../../ssl/srtp.h
├── ssl.h -> ../../ssl/ssl.h
├── ssl2.h -> ../../ssl/ssl2.h
├── ssl23.h -> ../../ssl/ssl23.h
├── ssl3.h -> ../../ssl/ssl3.h
├── stack.h -> ../../crypto/stack/stack.h
├── symhacks.h -> ../../crypto/symhacks.h
├── tls1.h -> ../../ssl/tls1.h
├── ts.h -> ../../crypto/ts/ts.h
├── txt_db.h -> ../../crypto/txt_db/txt_db.h
├── ui.h -> ../../crypto/ui/ui.h
├── ui_compat.h -> ../../crypto/ui/ui_compat.h
├── whrlpool.h -> ../../crypto/whrlpool/whrlpool.h
├── x509.h -> ../../crypto/x509/x509.h
├── x509_vfy.h -> ../../crypto/x509/x509_vfy.h
└── x509v3.h -> ../../crypto/x509v3/x509v3.h

Any clue on how to solve on this one?

sys/random.h not found in when compiling 2.7.13

Python/random.c:7:10: fatal error: 'sys/random.h' file not found
#include <sys/random.h>
         ^

Keep getting this error. Seems to be related to this ticket. https://bugs.python.org/issue29057

Commenting the include statement out seems to work.

And on some platforms appletvos.arm64, watchos.arm7k. I'm getting:

Python/random.c:117:19: error: implicit declaration of function 'getentropy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            res = getentropy(buffer, len);
                  ^

armv7 missed

I downloaded the iOS pre-built framework. However, I got the error: armv7 missed.

#ifdef arm
#include "pyconfig-armv7.h"
#endif

Cannot get the Python 3.5 package to compile on XCode 8

Hi,

I tried to compile the repo on XCode 8.1. The compile only fails for Python with the following message:

# Configure target Python
cp -f /Users/proffan/Projects/Development/ios/Python-Apple-support/patch/Python/Setup.embedded build/iOS/Python-3.5.2-iphonesimulator.x86_64/Modules/Setup.embedded
cd build/iOS/Python-3.5.2-iphonesimulator.x86_64 && PATH=/Users/proffan/Projects/Development/ios/Python-Apple-support/build/macOS/Python-3.5.2-macosx.x86_64/python/bin:/usr/local/sbin:/usr/local/bin:/Users/proffan/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin ./configure CC="xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk -miphoneos-version-min=7.0 " LD="xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.1.sdk -miphoneos-version-min=7.0 " --host=x86_64-apple-iOS --build=x86_64-apple-darwin16.1.0 --prefix=/Users/proffan/Projects/Development/ios/Python-Apple-support/build/iOS/Python-3.5.2-iphonesimulator.x86_64/dist --without-pymalloc --without-doc-strings --disable-ipv6 --without-ensurepip ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no
checking build system type... x86_64-apple-darwin16.1.0
checking host system type... Invalid configuration `x86_64-apple-iOS': system `iOS' not recognized
configure: error: /bin/sh ./config.sub x86_64-apple-iOS failed
make: *** [build/iOS/Python-3.5.2-iphonesimulator.x86_64/Makefile] Error 1

I think the problem is with the --host option, but I have no idea how to change that line.

Thank you again for your great work.

Why are tests etc. in framework?

There seems to be a whole lot of non-runtime type stuff in the frameworks.

E.G. the python/include directory is in there as is lib/pythonx.x/test directory.

I apologize if I missed it, but is there a command/script/makefile target etc. to make a slim runtime-only version of the frameworks?

Thanks, ssteinerX

The Problem with Xcode Swift IOS

Hi
first of all thanks for your grate work.
I am trying to embed python into swift IOS but when ever i try to call the function Py_Initialize() i get the error

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00000001083c83c0 (most recent call first):
(lldb) 

Version using: Python-3.5-iOS-support.b3 and tried 3.4
I imported libz.tbd and libsqlite.tbd and what should i set PYTHONHOME from environment variables?
Thanks a lot.

Error while building "building for OSX, but linking against dylib built for iOS"

Xcode 9.4, MacOS 10.13.4.

When I build python build finishes with error below:

compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/include/python3.6m -c'
xcrun: _configtest.c
xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk _configtest.o -o _configtest
clang: warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX' [-Wincompatible-sysroot]
ld: warning: URGENT: building for OSX, but linking in object file (_configtest.o) built for iOS. Note: This will be an error in the future.
ld: building for OSX, but linking against dylib built for iOS (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/lib/libSystem.tbd). file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang: warning: using sysroot for 'iPhoneSimulator' but targeting 'MacOSX' [-Wincompatible-sysroot]
ld: warning: URGENT: building for OSX, but linking in object file (_configtest.o) built for iOS. Note: This will be an error in the future.
ld: building for OSX, but linking against dylib built for iOS (/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/lib/libSystem.tbd). file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/usr/lib/libSystem.tbd' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
failure.
removing: _configtest.c _configtest.o
Traceback (most recent call last):
  File "setup.py", line 394, in <module>
    setup_package()
  File "setup.py", line 386, in setup_package
    setup(**metadata)
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/command/build_ext.py", line 80, in run
    self.run_command('build_src')
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/command/build_src.py", line 148, in run
    self.build_sources()
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/command/build_src.py", line 159, in build_sources
    self.build_library_sources(*libname_info)
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/command/build_src.py", line 294, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/Users/andrejlazarev/Projects/Python-Apple-support/build/iOS/packages/numpy/numpy/distutils/command/build_src.py", line 377, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 675, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
make: *** [build/iOS/packages/numpy/build/temp.iphonesimulator.x86_64-3.6/libpymath.a] Error 1

When I try to build simple program with commands:

xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -miphoneos-version-min=8.0 -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/andrejlazarev/Projects/Python-Apple-support/build/macOS/python/include/python3.6m -c _configtest.c

xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk _configtest.o -o _configtest

It seems to build as expected:

$ ./_configtest
dyld: mach-o, but built for simulator (not macOS)
Abort trap: 6

What I'm doing wrong?

Fix python building to include hashlib's c helper function

I submitted PR #36 through #39 for this already, but am creating an issue here just for completeness.

The basic idea is hashlib uses a C helper function to query openssl lib for the hash functions provided by it (such as ripemd160). The 1-line change PR I submitted adds the compilation of the C function to the final built libPython.a, so that hashlib can do its magic and provide all hash functions.

Without it, only a very basic set of hash functions are compiled in to libPython.a's modules. With it, you get more hash functions. It's a win/win as far as I can tell. ;)

Unable to submit app which contains the Python.framework

I tried to submit an app to iTunes connect which contains your Python.framework and I get this error:

Dear developer,

We have discovered one or more issues with your recent delivery for "Reroo – find cheap last minute train tickets". To process your delivery, the following issues must be corrected:

This bundle is invalid - The Info.plist file for /Payload/Reroo.app/Library/Python.framework is missing or could not be read.

Invalid Bundle - The bundle at '/Payload/Reroo.app/Library/Python.framework' does not contain a bundle executable.

Once these issues have been corrected, you can then redeliver the corrected binary.

Import framework to Swift framework

Hi,

I am having trouble using the Python 2.7 framework on iOS. I copied the framework into the working directory and then linked it with my own framework. I keep getting "No such module" error when I import Python.

I have a bunch of files written in Python and I'd like to access a function within the file. Is there any tutorial I could follow that would show me how to configure and use this framework correctly?

Thanks,
A

unknow2 ???

"inflateInit2", referenced from:
_PyZlib_decompress in libPython.a(zlibmodule.o)
_PyZlib_decompressobj in libPython.a(zlibmodule.o)
"_crc32", referenced from:
_PyZlib_crc32 in libPython.a(zlibmodule.o)
(maybe you meant: _BZ2_crc32Table)
"deflateInit2", referenced from:
_PyZlib_compressobj in libPython.a(zlibmodule.o)
"_deflateCopy", referenced from:
_PyZlib_copy in libPython.a(zlibmodule.o)
"_inflateCopy", referenced from:
_PyZlib_uncopy in libPython.a(zlibmodule.o)
"_deflateEnd", referenced from:
_Comp_dealloc in libPython.a(zlibmodule.o)
_PyZlib_flush in libPython.a(zlibmodule.o)
_PyZlib_compress in libPython.a(zlibmodule.o)
"_PyInit_multiarray", referenced from:
_main in main.o
"_PyInit_fftpack_lite", referenced from:
_main in main.o
"_PyInit_umath", referenced from:
_main in main.o
"_inflate", referenced from:
_PyZlib_objdecompress in libPython.a(zlibmodule.o)
_PyZlib_unflush in libPython.a(zlibmodule.o)
_PyZlib_decompress in libPython.a(zlibmodule.o)
"_adler32", referenced from:
_PyZlib_adler32 in libPython.a(zlibmodule.o)
"_PyInit__umath_linalg", referenced from:
_main in main.o
"_inflateEnd", referenced from:
_Decomp_dealloc in libPython.a(zlibmodule.o)
_PyZlib_unflush in libPython.a(zlibmodule.o)
_PyZlib_decompress in libPython.a(zlibmodule.o)
"_deflate", referenced from:
_PyZlib_objcompress in libPython.a(zlibmodule.o)
_PyZlib_flush in libPython.a(zlibmodule.o)
_PyZlib_compress in libPython.a(zlibmodule.o)
"_PyInit_lapack_lite", referenced from:
_main in main.o
"deflateInit", referenced from:
_PyZlib_compress in libPython.a(zlibmodule.o)
"_PyInit_mtrand", referenced from:

download the py2.7 package from here directly
but couldnt build success,miss someother lib?

"ld: framework not found Python"

So I'm not sure if I'm approaching this the wrong way (probably an issue on my end) but basically I've been able to build the Python framework for iOS. In my app I essentially have a Python library that I'd like to integrate with, that library interacts with some native Obj-C code. So after adding the Python.framework to my project. I setup the Framework Search Path to point to $(PROJECT_DIR)/MyApp/Support which is the directory that contains the Python.framework. I've also added it as a Linked Framework/Embedded Binary however once I build my project I get ld: framework not found Python when it attempts to link to the framework, which is unusual because the framework exists in that directory.

How to embed python-source library

Hello. Is there a file where library names (ex. nltk - pure python) can be added so that they are also embedded in the built python framework?

Py_Initialize: can't initialize sys in XCode 8

I just download the latest release for iOS platform, drag into project and run the hello world.

xcode output:
Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

code in ViewController.m:

#import <Python/Python.h>
- (void)viewDidLoad {
    Py_Initialize();
    PyRun_SimpleString("print(\"Hello world!\")");
    Py_Finalize();
}

Frameworks:
...
libsqlite.tbz
libz.tbz

Enviorment:
XCode 8
iOS 9.3

I cannot work out how to actually get a framework out of this thing

I am probably missing something obvious here, so apologies in advance.

I've run make iOS on two different machines, in the 2.7, 3.5, and 3.6 branches, and in no case does it result in a .framework bundle, or even a Versions folder anywhere within the created directories. The output is extremely verbose, but it certainly appears to have exited successfully; it made some folders and an archive, and closed with exit code 0.

When I first ran it and couldn't find a .framework, I had assumed that I have to make the bundle myself and copy the built files into it, but there are a couple of projects on GitHub that make no such reference to that being a necessary step, despite claiming to use this project to build their actual .framework bundles.

Is there something I'm missing here? How do I actually get a .framework out of this thing, or is that not how this is supposed to work and I've misunderstood what you mean by 'Apple Framework format'? If not, is there something about the output I do get that would help work out what might be going on?

Numpy-iOS has Non-public API

My project use the python 3.6 with numpy , it's run prefect
but when i submit project to AppStore,the App Store Connect feedback that some API is non-public
in libnumpy.a
non-public API about this : ccopy, dcopy, scopy, xerbla, zcopy
how can i fix it

Building frameworks should respect case sensitivity.

When building a project on a case sensitive filesystem, the Xcode linker was unable to find XZ.framework and BZip2.framework on my machine. As it turns out, the Makefile creates fat binaries and symlinks named "xz" and "bzip2", which are usually equal, since Macs per default ship with a case insensitive filesystem. However, choosing a case sensitive filesystem (doesn't matter if HFS+ or APFS) is possible, and the fix is very simple: Create the fat binaries embedded in the framework as well as the symlinks with respect to case sensitivity.

Regarding the pre built packages, it is sufficient to rename the binaries and recreate the symlinks, I was able to successfully link the frameworks after a simple rename.

I will create a pull request demonstrating the fix for the 3.6 branch.

numpy-iOS, python 3.7

Hi,

I'm still investigating, but the target numpy-{iOS/macOS} fails on the 3.7 branch at the following point

[...]
error: Command "xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk -DNDEBUG -g -fwrapv -O3 -Wall -mios-version-min=7.0 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -Inumpy/core/include -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/dalcacer/repositories/privat/github_python_apple_support/build/macOS/python/include/python3.7m -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/private -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/npymath -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/private -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/npymath -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/private -Ibuild/src.iphonesimulator.x86_64-3.7/numpy/core/src/npymath -c numpy/random/mtrand/mtrand.c -o build/temp.iphonesimulator.x86_64-3.7/numpy/random/mtrand/mtrand.o -MMD -MF build/temp.iphonesimulator.x86_64-3.7/numpy/random/mtrand/mtrand.o.d" failed with exit status 1
make: *** [build/iOS/packages/numpy/build/temp.iphonesimulator.x86_64-3.7/libpymath.a] Error 1

Handle Exception that causes crash

Hi and thank you for your great work
when an exception occurs in python that causes IOS app to crashes how can we handle that?
Thank you again.

python: Can't reopen .pyc file

I was used this framework in iOS,and can run python file with ".py",but I compile to ".pyc",it show a error:"python: Can't reopen .pyc file".I show the compile python version and python.framework are the same 3.5.4.

How can I solute this probrem?
I run the file like thisPyRun_AnyFile(path, "hello.pyc");

thank you !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.