Gentoo Archives: gentoo-alt

From: Fabian Groffen <grobian@g.o>
To: gentoo-alt@l.g.o
Subject: [gentoo-alt] On Python and OSX
Date: Mon, 14 Sep 2009 12:53:17
Message-Id: 20090914125259.GG1088@gentoo.org
1 This message is mainly for Mac OS X users, if you're not one of them,
2 you can probably just skim or even ignore this message.
3
4 Over the last few weeks I've been messing/fighting with Python for the
5 "aqua" USE-flag that I added to it. Enabling this flag causes a
6 framework build of Python to be made. This actually results in a
7 Mach/Next-style installation hierarchy, referred to as a Framework. On
8 OSX these are used and typically found in /Library/Frameworks.
9 Basically, with Gentoo Prefix you *never* want such thing to be
10 installed in your prefix, for it's useless within the UNIX-style
11 environment that we built. So basically, one would wonder why we would
12 like to build Python like this. The answer is that if you want to do
13 graphical stuff with Python, e.g. applications using wxPython, then you
14 need a Python that is bound to the Mac OS X window system using
15 CoreGraphics and all the Aqua-related Apple candy. The crux is here,
16 some stuff only works right if the binary itself from a framework. So,
17 that's the main reason we want a framework build of Python. For this to
18 get it right, I've got some inspiration from our friends at MacPorts.
19
20 Over the past few weeks a few mess-ups, have been made, causing the
21 interrevision bumps of python. Sorry for all the rebuilding.
22
23 The changes I've made are as follows. First, because we need the
24 framework and since we don't want many more frameworks, I decided to
25 install the framework in a non-standard location, which better suits our
26 UNIX-layout: $EPREFIX/usr/lib/Python.framework. This in contrast to
27 $EPREFIX/Library/Frameworks/Python.framework. Using the former part, we
28 hide the framework thing a bit, by partially swiping it under the carpet.
29 Next, I've heavily crippled the framework build of Python to make it
30 more like a UNIX build. This is necessary to make sure for instance
31 that applications can still find python includes, python modules, etc.
32 where they expect them to be. Also for the upgrade path the directory
33 locations should remain the same, e.g. not suddenly be inside the
34 framework. To achieve this, multiple patches and iterations were
35 necessary, as Python has the bad habit to try to be smart at the
36 occasions where it should better not.
37
38 By default, a framework build of python supplies usr/bin/python and
39 /usr/bin/pythonw which are in fact small executables which call the
40 pythonw executable from the framework to achieve the desired effect of
41 being in the framework and thus having access to the graphical
42 environment. I didn't like this, expecially not because this means you
43 always run the framework python, and due to Python's own "cleverness"
44 that means you get e.g. a pythonpath that is using that framework
45 location instead of your usr/lib/pythonxx/site-packages.
46
47 What I therefore did is make the "python" executable in usr/bin really
48 be the python interpreter that cannot do graphical stuff, like it used
49 to be before, and bind pythonw to the framework python. pythonw is not
50 our invention, it's the way by upstream to get access to the python with
51 graphical capabilities on a Mac and Windows. So, are we happy? Yeah,
52 because pythonw does quite a good job to run wxPython stuff on OSX with
53 Prefix now, it seems.
54
55 At the same time as this was taking place, we also did fixes for 64-bits
56 framework build Python on Leopard, and 32 or 64-bits build Python on
57 Snow Leopard. That said, it should compile fine on Snow Leopard now.
58 And by the way while we were fixing things, we also fixed readline
59 support on the console, which was disabled for as long as I recall
60 because of some stupid "typically Python" decision.
61
62 So, I guess everyone is up-to-date again now.
63
64
65 --
66 Fabian Groffen
67 Gentoo on a different level

Replies

Subject Author
Re: [gentoo-alt] On Python and OSX Qiangning Hong <hongqn@×××××.com>
Re: [gentoo-alt] On Python and OSX Pavel Volkovitskiy <olfway@×××××.com>