Project

General

Profile

Bundle-python » History » Version 3

Saúl Ibarra Corretgé, 05/27/2013 02:20 PM

1 1 Saúl Ibarra Corretgé
h1. Building a Python Framework to bundle inside Blink
2
3
In order to avoid using the system Python a custom Framework build is needed. Using a bundled Python version will make the package bigger in size, but all package versions are controlled and not up to the environment. Also, we can use the latest Python version, with latest bugfixes and features, since Apple only updates the system Python version on every major OS release.
4
5
h2. Building the Python Framework itself
6
7
* Download the desired Python version, at the time of this writing, 2.7.5
8
9
<pre>
10
wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2
11
</pre>
12
13
* Uncompress and get ready to compile
14
15
<pre>
16
tar jxvf Python-2.7.5.tar.bz2
17
cd Python-2.7.5
18
</pre>
19
20
* Create a temporary directory for the build result
21
22
<pre>
23
mkdir -p /tmp/py
24
</pre>
25
26
* Compile Python (Framework build) in 32 bits mode and with compatibility for OSX >= 10.6
27
28
<pre>
29
./configure --prefix=/tmp/py --enable-framework=/tmp/py MACOSX_DEPLOYMENT_TARGET=10.6 ARCHFLAGS="-arch i386" CFLAGS="-arch i386" CXXFLAGS="-arch i386" LDFLAGS="-arch i386"
30
make
31
make install
32
</pre>
33
34
The resulting framework will be located in /tmp/py
35
36
* Change the dynamic link target in the main binary file of the Python Framework
37
38
<pre>
39
cd /tmp/py/Python.framework/Versions/2.7
40
chmod +w Python
41
install_name_tool -id @executable_path/../Frameworks/Python.framework/Versions/2.7/Python Python
42
chmod -w Python
43
</pre>
44
45 3 Saúl Ibarra Corretgé
The framework is almos ready for inclusion on the project.
46 1 Saúl Ibarra Corretgé
47 2 Saúl Ibarra Corretgé
*NOTE*: Be careful when copying the framework around, it contains symlinks and if @cp -r@ is used the size will we doubled, use @cp -RH@ instead.
48
49 1 Saúl Ibarra Corretgé
50
* Reduce the size of the Python Framework:
51
52 3 Saúl Ibarra Corretgé
There are a number of things that can be removed from the framework directory to make it smaller in size:
53
54
<pre>
55
*.pyc
56
*.pyo
57
Versions/Current/Mac
58
Versions/Current/bin
59
Versions/Current/share
60
Versions/Current/Resources/English*
61
Versions/Current/Resources/*.app
62
Versions/Current/lib/python2.7/test
63
Versions/Current/lib/python2.7/plat-*
64
Versions/Current/lib/python2.7/idlelib
65
Versions/Current/lib/python2.7/curses
66
Versions/Current/lib/python2.7/lib2to3
67
Versions/Current/lib/python2.7/lib-tk
68
Versions/Current/lib/python2.7/bsddb
69
</pre>