mangelajo/python-cmake-buildsystem
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
This is a replacement buildsystem for Python. The existing (autotools based)
buildsystem for Python is overcomplicated and makes cross-compiling very
difficult.
This cmake-based buildsystem is better because:
* It's much faster to compile: 7 seconds instead of 58 seconds in my
unscientific test.
* No compiled program for the target architecture is used in the build
itself. This makes cross-compiling possible.
* Same project files for all platforms - there's no need to maintain the
unix build separately from four different MSVC builds.
How to use this buildsystem:
* Download and extract the Python 2.7.1 source.
* Copy all the files in this repository into the Python source directory.
* mkdir bin
* cd bin
* cmake ..
* make -j10
* sudo make install
CMake options:
You can pass options to CMake to control the way Python is built. You only
need to give each option once - they get saved in CMakeCache.txt. Pass
options on the commandline with -DOPTION=VALUE, or use the "ccmake" gui.
CMAKE_BUILD_TYPE=Debug|Release
Build with debugging symbols or with optimisations.
CMAKE_INSTALL_PREFIX=<path> (defaults to /usr/local)
Path in which to install Python.
ENABLE_SHARED=ON|OFF (defaults to OFF)
ENABLE_STATIC=ON|OFF (defaults to ON)
Build libpython as a shared library (.so or .dll) or a static library
(.a). At least one of these options must be set to ON - if they are both
set to ON then the Python executable will be linked against the shared
version of libpython.
Note that Python extensions are always built as shared libraries. On
Windows it is not possible to build shared .dll extensions against a
static libpython, so you must build any extensions you want into libpython
itself (see the BUILTIN flags below).
ENABLE_<extension>=ON|OFF (defaults to ON)
BUILTIN_<extension>=ON|OFF (defaults to OFF except for POSIX, PWD and
NT extensions which are builtin by default)
These two options control how individual python extensions are built.
<extension> is the name of the extension in upper case, and without any
leading underscore (_). Known extensions for 2.7.1 include:
ARRAY AUDIOOP BINASCII BISECT BSDDB BZ2 CMATH CODECS_CN CODECS_HK
CODECS_ISO2022 CODECS_JP CODECS_KR CODECS_TW COLLECTIONS CPICKLE CRYPT
CSTRINGIO CSV CTYPES CTYPES_TEST CURSES CURSES_PANEL DATETIME DBM
ELEMENTTREE FCNTL FUNCTOOLS FUTURE_BUILTINS GDBM GRP HASHLIB HEAPQ
HOTSHOT IO ITERTOOLS JSON LINUXAUDIODEV LOCALE LSPROF MATH MMAP
MULTIBYTECODEC MULTIPROCESSING NIS NT OPERATOR OSSAUDIODEV PARSER POSIX
PWD PYEXPAT RANDOM READLINE RESOURCE SELECT SOCKET SPWD SQLITE3 SSL
STROP STRUCT SYSLOG TERMIOS TESTCAPI TIME TKINTER UNICODEDATA ZLIB
All extensions are enabled by default, but some might depend on system
libraries and will get disabled if they're not available (a list of
extensions that didn't have all their prerequisites available will be
printed when you run cmake).
By default extensions are compiled as separate shared libraries (.so or
.dll files) and installed in lib/python2.7/lib-dynload. If you set
BUILTIN_<extension> to ON then the extension is compiled into libpython
instead.
USE_LIB64=ON|OFF (defaults to OFF)
If this is set to ON then cmake will look for dependencies in lib64 as
well as lib directories. Compiled python extensions will also be
installed into lib64/python2.7/lib-dynload instead of
lib/python2.7/lib-dynload.
EXTRA_PYTHONPATH=dir1:dir2 (defaults to "")
Colon (:) separated list of extra directories to add to the compiled-in
PYTHONPATH.
Cross-compiling for Windows from Linux:
There are some patches in the cmake/patches-win32 directory that make it
possible to compile Python using the mingw32 compiler. You have to apply
these before running make:
* patch -p0 < cmake/patches-win32/01-dynload_win.patch
* patch -p0 < cmake/patches-win32/02-signalmodule.patch
* patch -p0 < cmake/patches-win32/03-mingw32.patch
Note: This branch is for Python version 2.7.1. Since this buildsystem is
maintained separately from Python itself it needs to be manually updated
whenever there is a new release of Python.