[Pythonmac-SIG] Building a 32 bit framework build in a 64 bit system
Ned Deily
nad at acm.org
Wed Oct 17 07:48:13 CEST 2012
In article
<CALGmxE+tAoZmL2FTP8B6aO9GRLyFGkAOZGC4ODV8cEEXDd8dGw at mail.gmail.com>,
Chris Barker <chris.barker at noaa.gov> wrote:
> I'm finding it a pain to force the Universal Python to 32 bit -- for
> building extensions, as well as running, etc. So I though maybe it
> would be nice to have a just plain 32 bit Intel build -- then I can
> use that to run and test all mystuff (I'm depending on 32 bit only C++
> code extensions), and also have something to re-distribute that
> doesn't carry around worthless (for my needs) 64 bit baggage.
With reasonably current python.org Pythons, you can use the ARCHFLAGS
environment variable to limit which archs are used by Distutils (and
tools which use Distutils like easy_install or pip) to build C extension
modules. For example, to limit to just 32-bit Intel, you could use
something like:
ARCHFLAGS='-arch i386' easy_install psutil
or
export ARCHFLAGS='-arch i386'
python2.7-32 setup.py install
> Poking through the READMEs, I'm having trouble figuring out how to
> build a 32bit-only python framework on a 64 bit system.
> --with-universal-archs values all have multiple builds (hence
> universal...).
The Mac/README was revised and updated for the recent 3.3.0 release; at
the moment, it has the most recent information. While it was written
for that release, most of the information applies to 2.7.x as well.
http://hg.python.org/cpython/file/default/Mac/README
> or is it as simple as passing arch=i386 in to configure?
Pretty much. Here's a very simple configure for use with Xcode 4 and
OS X 10.8 for a non-framework 32-bit-only build. Adjust the deployment
target as needed and for Xcode 3 I'd recommend using CC=gcc-4.2.
./configure CFLAGS="-arch i386" LDFLAGS="-arch i386" \
CC=clang MACOSX_DEPLOYMENT_TARGET=10.8
> (I'll want to build a dmg installer too, but cross that bridge when I
> come to it...)
Look at the readme for the installer build script (again, this is the
more recent 3.3+ version):
http://hg.python.org/cpython/file/default/Mac/BuildScript/README.txt
> NOTE: I'm running 10.7, and would like to use the latest XCode (4.2?),
> and am OK with the result only working on 10.7+ systems, though 10.6
> and above would be nice.
Set the deployment target env variable to 10.6 or whatever version you
need. By the way, at the moment, the latest version of Xcode for 10.7
and 10.8 is Xcode 4.5.1 available for free through App Store.app.
There are some gotchas with the most recent versions of Xcode 4. Among
them are the elimination of the use of the /Developer directory; now
things like SDKs are contained within Xcode.app itself. You can find
them using xcodebuild:
xcodebuild -version -sdk macosx10.7 Path
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Deve
loper/SDKs/MacOSX10.7.sdk
And, after installing/updating Xcode.app, you also need to install the
"Command Line Tools" component of Xcode from Xcode -> Preferences. That
installs things like clang, make, ld, and system include files into
their conventional places within /usr.
Good luck!
--
Ned Deily,
nad at acm.org
More information about the Pythonmac-SIG
mailing list