RFC: Alternative for exemaker

Adrian Buehlmann adrian at cadifra.com
Fri Jun 22 16:55:58 CDT 2012


As I've started hacking a bit on the exemaker source, I thought why
don't we build a proper hg.exe from a hg.c that #includes Python.h and
uses the Windows import library, e.g. python27.lib?

python27.lib is installed in C:\Python\libs by the Windows msi
installer, which also installs Python.h in C:\Python\include.

The hg.exe project would then link with python27.lib, which corresponds
to python27.dll at runtime.

The hg.c would basically embed Python, as described at:

  http://docs.python.org/extending/embedding.html

and then call Py_Main

  http://docs.python.org/c-api/veryhigh.html#Py_Main

like exemaker already does today, handing the arguments of the hg.exe
command line over to the Python interpreter.

The difference to exemaker would be that we use standard Python.h and
pythonXX.lib to link against, so we can use functions Py_Main directly
in hg.c.

This would also make all Python C-API functions directly available via
Python.h, which leaves room for possibly defining a few things that
could be used from the Python side (we can, we don't have to). Perhaps
we want to define some extra module that can be imported from the python
side to see whether we are called from the hg.exe or not (which seems to
require some magic with args - see the problems with util.spawndetached
I found).

This would be much more comfortable than the hackery exemaker does with
trying to find the correct pythonXX.dll and load it. A hackery that
doesn't really work correctly anway.

The only drawback I see is that a hg.exe that was built in this way
would link against a fixed major version of Python, like for example
python27.

But I don't think that's much of a hindrance. For example, if I'd
provide a hackable zip for download, which contains Python, then I know
anway what major python version it contains. The download would be named
like hackable-hg-python-27.zip or something like that.

Of course the license for that hg.exe mini-project would be the same as
for mercurial, as it links with mercurial (exemaker might have a bit of
a problem here, if we start expanding it mercurial-specifics).

Perhaps I'll start doing that. From scratch. Of course heavily inspired
by exemaker.



More information about the Mercurial-devel mailing list