Skip to content
This repository was archived by the owner on Aug 15, 2017. It is now read-only.

Commit d92740c

Browse files
committed
Initial commit of working support libraries.
0 parents  commit d92740c

File tree

5 files changed

+280
-0
lines changed

5 files changed

+280
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.swo
2+
*.swp
3+
src/*
4+
archive/*
5+
build/*
6+
downloads/*
7+
diff/*
8+
dist/*

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2014 Russell Keith-Magee.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
PROJECTDIR=$(shell pwd)
2+
3+
BUILD_NUMBER=1
4+
5+
# Version of packages that will be compiled by this meta-package
6+
PYTHON_VERSION=3.4.2
7+
8+
OPENSSL_VERSION_NUMBER=1.0.2
9+
OPENSSL_REVISION=d
10+
OPENSSL_VERSION=$(OPENSSL_VERSION_NUMBER)$(OPENSSL_REVISION)
11+
12+
# OS/X build commands and flags
13+
OSX_SDK_ROOT=$(shell xcrun --show-sdk-path)
14+
OSX_CC=$(shell xcrun -find clang) --sysroot=$(OSX_SDK_ROOT)
15+
16+
17+
all: Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz
18+
19+
# Clean all builds
20+
clean:
21+
rm -rf build dist Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz
22+
23+
# Full clean - includes all downloaded products
24+
distclean: clean
25+
rm -rf downloads
26+
27+
Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz: dist/python/bin/python$(basename $(PYTHON_VERSION))m
28+
cd dist && tar zcvf ../Python-$(PYTHON_VERSION)-OSX-support.b$(BUILD_NUMBER).tar.gz python
29+
30+
###########################################################################
31+
# Working directories
32+
###########################################################################
33+
34+
downloads:
35+
mkdir -p downloads
36+
37+
build:
38+
mkdir -p build
39+
40+
dist:
41+
mkdir -p dist
42+
43+
# Clean the OpenSSL project
44+
clean-OpenSSL:
45+
rm -rf build/openssl-$(OPENSSL_VERSION)
46+
rm -rf build/OpenSSL
47+
rm -rf dist/OpenSSL.framework
48+
49+
# Download original OpenSSL source code archive.
50+
downloads/openssl-$(OPENSSL_VERSION).tgz: downloads
51+
-if [ ! -e downloads/openssl-$(OPENSSL_VERSION).tgz ]; then curl --fail -L http://openssl.org/source/openssl-$(OPENSSL_VERSION).tar.gz -o downloads/openssl-$(OPENSSL_VERSION).tgz; fi
52+
if [ ! -e downloads/openssl-$(OPENSSL_VERSION).tgz ]; then curl --fail -L http://openssl.org/source/old/$(OPENSSL_VERSION_NUMBER)/openssl-$(OPENSSL_VERSION).tar.gz -o downloads/openssl-$(OPENSSL_VERSION).tgz; fi
53+
54+
build/OpenSSL/lib/libssl.a: build downloads/openssl-$(OPENSSL_VERSION).tgz
55+
# Unpack sources
56+
cd build && tar zxf ../downloads/openssl-$(OPENSSL_VERSION).tgz
57+
mkdir -p build/OpenSSL
58+
# Configure the build
59+
cd build/openssl-$(OPENSSL_VERSION) && \
60+
CC="$(OSX_CC)" ./Configure darwin64-x86_64-cc --openssldir=$(PROJECTDIR)/build/OpenSSL
61+
# Make the build
62+
cd build/openssl-$(OPENSSL_VERSION) && CC="$(OSX_CC)" make all
63+
# Install the build
64+
cd build/openssl-$(OPENSSL_VERSION) && make install
65+
66+
###########################################################################
67+
# Python
68+
###########################################################################
69+
70+
# Clean the Python project
71+
clean-Python:
72+
rm -rf build/Python-$(PYTHON_VERSION)
73+
rm -rf build/python
74+
rm -rf dist/Python.framework
75+
76+
# Download original Python source code archive.
77+
downloads/Python-$(PYTHON_VERSION).tgz: downloads
78+
curl -L https://www.python.org/ftp/python/$(PYTHON_VERSION)/Python-$(PYTHON_VERSION).tgz > downloads/Python-$(PYTHON_VERSION).tgz
79+
80+
# build/Python-$(PYTHON_VERSION)/Python.framework: build dist/OpenSSL.framework downloads/Python-$(PYTHON_VERSION).tgz
81+
dist/python/bin/python$(basename $(PYTHON_VERSION))m: build downloads/Python-$(PYTHON_VERSION).tgz build/OpenSSL/lib/libssl.a
82+
# Unpack sources
83+
cd build && tar zxf ../downloads/Python-$(PYTHON_VERSION).tgz
84+
mkdir -p build/python
85+
# Apply patches
86+
cd build/Python-$(PYTHON_VERSION) && cp ../../patch/Python/Setup.embedded Modules/Setup.embedded
87+
# Configure the build
88+
cd build/Python-$(PYTHON_VERSION) && ./configure --prefix=$(PROJECTDIR)/dist/python --without-ensurepip
89+
# Make the build
90+
cd build/Python-$(PYTHON_VERSION) && make
91+
# Install the build
92+
cd build/Python-$(PYTHON_VERSION) && make install
93+
# Prune out things that aren't needed
94+
cd dist/python && rm -rf share include
95+
cd dist/python/bin && rm -rf 2to3* idle* pydoc* python*-config pyvenv* python*m
96+
cd dist/python/lib && rm -rf libpython$(basename $(PYTHON_VERSION)).a pkgconfig
97+
cd dist/python/lib/python$(basename $(PYTHON_VERSION)); \
98+
rm -rf *test* bsddb curses ensurepip hotshot idlelib tkinter turtledemo wsgiref \
99+
config-$(basename $(PYTHON_VERSION))m ctypes/test distutils/tests site-packages sqlite3/test
100+
# Make sure python always works as an executable name
101+
cd dist/python/bin && ln -si python$(basename $(PYTHON_VERSION)) python

README.rst

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Python iOS Support
2+
==================
3+
4+
This is a meta-package for building a version of Python that can be embedded
5+
into an iOS project.
6+
7+
It works by downloading, patching, and building a fat binary OpenSSL and
8+
Python, and packaging them both in iOS Framework format.
9+
10+
The binaries support the ``$(ARCHS_STANDARD)`` set - that is, armv7 and
11+
arm64. This should enable the code to run on:
12+
13+
* iPhone
14+
- iPhone 4s
15+
- iPhone 5
16+
- iPhone 5s
17+
- iPhone 6
18+
- iPhone 6 Plus
19+
* iPad
20+
- iPad 2
21+
- iPad (3rd gen)
22+
- iPad (4th gen)
23+
- iPad Air
24+
- iPad retina
25+
* iPad Mini
26+
- iPad Mini (1st gen)
27+
- iPad Mini (2nd gen)
28+
* iPod Touch
29+
- iPod Touch (4th gen)
30+
- iPod Touch (5th gen)
31+
32+
This repository branch builds a packaged version of **Python 3.4.2**.
33+
Other Python versions are available by cloning other branches of the main
34+
repository.
35+
36+
Quickstart
37+
----------
38+
39+
Pre-built versions of the frameworks can be downloaded_, and added to
40+
your iOS project.
41+
42+
Alternatively, to build the frameworks on your own, download/clone this
43+
repository, and then in the root directory, and run:
44+
45+
$ make
46+
47+
This should:
48+
49+
1. Download the original source packages
50+
2. Patch them as required for iOS compatibility
51+
3. Build the packages as iOS frameworks.
52+
53+
The build products will be in the `build` directory.
54+
55+
.. _downloaded: https://github.com/pybee/Python-iOS-support/releases/download/3.4.2-b2/Python-3.4.2-iOS-support.b2.tar.gz
56+
57+
Acknowledgements
58+
----------------
59+
60+
The approach to framework packaging is drawn from `Jeff Verkoeyen`_, and
61+
`Ernesto García's`_ tutorials.
62+
63+
.. _Jeff Verkoeyen: https://github.com/jverkoey/iOS-Framework
64+
.. _Ernesto García's: http://www.raywenderlich.com/41377/creating-a-static-library-in-ios-tutorial

patch/Python/Setup.embedded

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#####################################################################
2+
# Static compilation instructions for all binary modules.
3+
#####################################################################
4+
5+
_bisect _bisectmodule.c
6+
_codecs_cn cjkcodecs/_codecs_cn.c
7+
_codecs_hk cjkcodecs/_codecs_hk.c
8+
_codecs_iso2022 cjkcodecs/_codecs_iso2022.c
9+
_codecs_jp cjkcodecs/_codecs_jp.c
10+
_codecs_kr cjkcodecs/_codecs_kr.c
11+
_codecs_tw cjkcodecs/_codecs_tw.c
12+
_crypt _cryptmodule.c
13+
_csv _csv.c
14+
_datetime _datetimemodule.c
15+
_elementtree _elementtree.c \
16+
-I$(srcdir)/Modules/expat
17+
-DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
18+
_heapq _heapqmodule.c
19+
_json _json.c
20+
_lsprof _lsprof.o rotatingtree.c
21+
_md5 md5module.c
22+
_multibytecodec cjkcodecs/multibytecodec.c
23+
_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/semaphore.c
24+
_opcode _opcode.c
25+
_pickle _pickle.c
26+
_posixsubprocess _posixsubprocess.c
27+
_random _randommodule.c
28+
_sha1 sha1module.c
29+
_sha256 sha256module.c
30+
_sha512 sha512module.c
31+
_socket socketmodule.c
32+
_sqlite3 -I$(srcdir)/Modules/_sqlite -DMODULE_NAME='\"sqlite3\"' -DSQLITE_OMIT_LOAD_EXTENSION -lsqlite3 \
33+
_sqlite/cache.c \
34+
_sqlite/connection.c \
35+
_sqlite/cursor.c \
36+
_sqlite/microprotocols.c \
37+
_sqlite/module.c \
38+
_sqlite/prepare_protocol.c \
39+
_sqlite/row.c \
40+
_sqlite/statement.c \
41+
_sqlite/util.c
42+
_ssl _ssl.c -I$(srcdir)/../OpenSSL/include -lssl -lcrypto -L$(srcdir)/../OpenSSL/lib -DUSE_SSL
43+
_struct _struct.c
44+
array arraymodule.c
45+
audioop audioop.c
46+
binascii binascii.c
47+
cmath cmathmodule.c _math.c
48+
fcntl fcntlmodule.c
49+
grp grpmodule.c
50+
math mathmodule.c
51+
mmap mmapmodule.c
52+
parser parsermodule.c
53+
pyexpat expat/xmlparse.c \
54+
expat/xmlrole.c \
55+
expat/xmltok.c \
56+
pyexpat.c \
57+
-I$(srcdir)/Modules/expat \
58+
-DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
59+
resource resource.c
60+
select selectmodule.c
61+
syslog syslogmodule.c
62+
termios termios.c
63+
time timemodule.c
64+
unicodedata unicodedata.c
65+
zlib zlibmodule.c -I$(prefix)/include -lz
66+
67+
#####################################################################
68+
# Testing modules
69+
#####################################################################
70+
_ctypes_test _ctypes/_ctypes_test.c
71+
_testbuffer _testbuffer.c
72+
_testcapi _testcapimodule.c
73+
_testimportmultiple _testimportmultiple.c
74+
75+
#####################################################################
76+
# Modules that require additional frameworks
77+
#####################################################################
78+
#_bz2 bz2module.c -lbz2
79+
#_curses _cursesmodule.c -lcurses -ltermcap
80+
#_curses_panel _curses_panel.c -lpanel -lncurses
81+
#_dbm _dbmmodule.c
82+
#_gdbm _gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm
83+
#_lzma
84+
#_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT -I... -L...
85+
#nis nismodule.c -lnsl
86+
#ossaudiodev
87+
#readline readline.c -lreadline -ltermcap
88+
#spwd spwdmodule.c

0 commit comments

Comments
 (0)