[Python.NET] UCS2/UCS4 detection

Christian Heimes lists at cheimes.de
Thu Oct 18 13:26:48 CEST 2007

Sanghyeon Seo wrote:
> UCS2/UCS4 detection in Makefile doesn't seem to work here.
> tinuviel at debian:~/svn/pythonnet$ python -c 'import sys; print sys.maxunicode'
> 1114111
> tinuviel at debian:~/svn/pythonnet$ make Python.Runtime.dll
> cd "/home/tinuviel/svn/pythonnet/src/runtime"; \
>         gmcs /define:PYTHON24,UCS2 /nologo  /unsafe /target:library \
>              /out:../../Python.Runtime.dll /recurse:*.cs
> Makefile uses distutils.sysconfig, but why not just check sys.maxunicode?

What's your full Python version, OS, distribution and the output of

$ python -c "from distutils.sysconfig import get_config_var; print

? It looks like Python 2.4.x and a Debian GNU/Linux distribution.

I'm using get_config_var() because it's the obvious choice. It's using
the information from pyconfig.h. It's also easier to understand and less
error prone than "(sys.maxunicode > 2<<15) and 4 or 2". I usually tend
to use the public API instead of reinventing the wheel.


More information about the PythonDotNet mailing list