[Distutils] Help: request for assistance with PyOpenGL distribution using distutils on NT

Rene Liebscher R.Liebscher@gmx.de
Mon Sep 18 07:23:01 2000

Thomas Heller wrote:
> >
> > D:\bin\lang\studio\VC98\BIN\cl.exe /c /nologo /Ox /MD /W3 /GX -Isrc
> > -ID:\bin\lang\Python\Include /Tcsrc/_glumodule.c
> > /Fobuild\temp.win32\Release\src/_glumodule.obj
> >
> > Doesn't work.  The GUI under the old BUILD.py uses:
> >
> > /nologo /MD /W3 /GX /O2 /Ob2 /I "D:\bin\lang\Python\include" /D "WIN32" /D
> > "_WINDOWS" /D "NDEBUG" /Fp"tmp\./_glu.pch" /YX /Fo"tmp\./" /Fd"tmp\./" /FD
> > /c
> >
> > and works fine.
> This is not related to C/C++ problems.
> The problem is that WIN32 and _WINDOWS is not defined in the first run.
> Insert the define_macros parameter:
>            Extension("_glu",
>                 ["src/_glumodule.c"],
>                 libraries=glu_libs,
>                 library_dirs=glu_lib_dirs,
>                 define_macros=[("WIN32", None), ("_WINDOWS", None)],
>                ),
> in your setup-script and it should work.
> (This may also be necessary for other extensions).

'define_macros' only works with the latest version of distutils.

May be you should use the same include order as in the other
(This file fails to compile.)
* _glumodule.c *******************
#ifdef WIN32
#include <windows.h>
#define MCALLBACK (void (__stdcall *)(void))

#include <GL/gl.h>
#include <GL/glu.h>
#include "Python.h"

(This one compiles without problems.)
* _openglmodule.c ****************
#include "Python.h"
#ifdef MS_WIN32
#include <windows.h>
#include <GL/gl.h>
#include <math.h>

If you include "Python.h" first and use then 
MS_WIN32 instead of WIN32, you don't need to
define WIN32 and don't get problems with 
older versions of distutils, which doesn't
handle 'define_macros'.

(There are some other occurences of WIN32 in
your file, either you replace them or you 
define WIN32 in your c-file if MS_WIN32
is defined.)

kind regards

Rene Liebscher