[PATCH 0 of 5] using ctypes on Windows

Adrian Buehlmann adrian at cadifra.com
Tue Feb 8 17:20:39 CST 2011


On 2011-02-08 21:59, Dirkjan Ochtman wrote:
> On Tue, Feb 8, 2011 at 20:12, Adrian Buehlmann <adrian at cadifra.com> wrote:
>> We only need to go to the "bare Windows metal" in a few rather obscure
>> occasions -- but there we really need it and we need to care about every
>> ugly hairy angle of it (see the epic hardlink odyssey).
>>
>> Whereas pywin32 tries to give very broad access to the Windows API, but
>> it still obscures it and it's not clear to me how pywin32 will be
>> carried on in the future. Especially since there is now the more
>> versatile and powerful access to the full Windows API using ctypes.
>>
>> From what I've seen on the net, ctypes seems to be quickly gaining
>> popularity. Nearly every question I stumbled upon while doing this
>> series had already been discussed somewhere on the net (often on
>> stackoverflow).
> 
> Sure sounds good.
> 
> Do we care about having an extra dependency on ctypes for 2.4 on
> Windows? That would seem like a very small piece of the Mercurial pie.

I think most people on Windows are lucky enough to get Mercurial running
correctly on Windows at all.

> Nonetheless, and I should know better than to bring this up, is it
> time yet to contemplate dropping 2.4 from the lineup entirely?

I have no opinion on that, but not caring about Python 2.4 compatibility
in the Mercurial codebase is not the same not caring about running
Mercurial with Python 2.4 *on Windows*.

So, as a Windows Mercurial developer (BTW, where is my T-Shirt?), I'm
fine with respecting the general rule that the Mercurial code base must
be written such that it is compatible with Python 2.4. Even I as a
Windows moron understand that there are other people who want to run
Mercurial on non-Windows platforms together with Python 2.4. Which is
not such a hopeless combination as it is on Windows.

As such the question of whether it is a problem that ctypes is missing
in Python 2.4 is of no practical relevance, since only code parts of
Mercurial running on Windows exclusively will use ctypes and no one on
Windows which uses Mercurial really cares about using Python 2.4 on
Windows any more. If they do, they are probably left alone.

I think based on that, allowing to use ctypes in the Windows specific
parts of Mercurial as an exception to the rule should be fine. And in
theory, ctypes is available as a separately installable package for
Windows for CPython 2.4.

Currently, we have to install the separate pywin32 package for all
Python versions to get Mercurial running on Windows in a reasonable way.
So I could argue that for Python 2.4 on Windows you do have to install
an additional package anyway. It's either pywin32, or -- possibly -- ctypes.

But if we change mercurial/win32.py to use ctypes (my patch), no
additional package must be installed on Windows for Python >= 2.5.



More information about the Mercurial-devel mailing list