[Python-Dev] Compiling Python with Python

Jussi Pakkanen jpakkane at gmail.com
Wed Jun 5 21:21:53 CEST 2013


Hello all

I'd like to start this email by saying this is not a proposal to change
Python's build system. This is just the results of some experimentation you
might be interested it.

I have been working on a cross-platform build system called Meson, which is
implemented in Python 3. For symmetry I wanted to see if it could be used
to build Python itself. After about an evening worth of work, I got the
basic C parts (that is, the build targets in the main Makefile such as core
Python, pgen etc) built.

Main highlights:

- pyconfig.h generation in a fully cross-platform way without Autoconf (not
tested with Visual Studio but should work as Meson has unit tests for this,
tests for functions in header files and some others not done)

- builds in a separate build directory, can have arbitrarily many build
dirs with different configurations (for gcc/clang/static
analysis/debug/release/etc)

- configure time 5s, build time 8s on an i5 Macbook running Ubuntu
(Autotool-configure takes 37 s but it's not directly comparable because it
does a lot more)

- the file describing the build is 433 lines, most of which look like this:

if cc.has_header('io.h')
  pyconf.set('HAVE_IO_H', 1)
endif

- implementation of Meson is 100% Python 3, it does not have a dependency
on the shell and in fact already works on Windows

If you want to try it yourself, here are the steps (only 64 bit Linux
tested thus far):

- install python3-ply and Ninja (Ubuntu package ninja-build)
- get Meson git head: https://sourceforge.net/p/meson/code/
- get Python3 trunk
- download and extract the build files into trunk:
https://dl.dropboxusercontent.com/u/37517477/python-meson.tar.gz
- cd into Python trunk and do the following commands:

mkdir build
cd build
path/to/meson.py ..
ninja

And there you have it. You can't do much with it, though (except run pgen
to ensure that it actually did something ;) ).

If you have any questions that are not directly related to Python, feel
free to email me or the Meson mailing list.

Enjoy,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20130605/97866294/attachment.html>


More information about the Python-Dev mailing list