With pyMinGW

B

bearophileHUGS

To use Pyrex, SWIG and the like on a Win2K I have followed this way:

http://jove.prohosting.com/iwave/ipython/pyMinGW.html

I already had MinGW 3.4.2, so I have decompressed the Python 2.4.2
sources, I have merged in the pyMinGW patch, and I have run the global
compilation with:

make -f python24.mak all

It has compiled most things, but not zlibmodule.c
It has stopped the compilation with:

c:\......\bin\dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want
make[1]: Leaving directory `/.../PyminGW/Python-2.4.2/MinGW'
make -f zlib.mak
make[1]: Entering directory `/.../PyminGW/Python-2.4.2/MinGW'
gcc.exe -c ../Modules/zlibmodule.c -o ../Modules/zlibmodule.o
-I"../Include" -I"../Pc" -I"../../../d
ist/zlib-1.2.3" -Wall -s -DNDEBUG -D_USRDLL -O2
.../Modules/zlibmodule.c:8:18: zlib.h: No such file or directory
.../Modules/zlibmodule.c:66: error: syntax error before "z_stream"

.... etc etc.

Anyway, probably 98% was compiled and this Python works, I have tried
the standard tests and most of them pass.
Then I have downloaded the pyMinGW Extensions V. 0.0.6.6, so zip and
other things now work.

The link to the Tcl-Tkinter extension doesn't work (the free site
hosting the file doesn't accept this file format anymore), so I cannot
use Tkinter.

I have decompressed SWIG and put it in a temporary Path.

I have then tried a basic SWIG example, (called example) coming from
this obsolete but probably still interesting page:
http://sebsauvage.net/python/mingw.html

But I have had problems durign the module creation:

C:\...\PyminGW\Python-2.4.2\MinGW>python setup.py build -cmingw32
running build
running build_ext
building 'example' extension
swigging example.i to example_wrap.c
C:\...\PyminGW\swigwin-1.3.28\swig.exe -python -o example_wrap.c
example.i
creating build
creating build\temp.win32-2.4
creating build\temp.win32-2.4\Release
C:\......\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\python24\include
-Ic:\pytho
n24\PC -c example_wrap.c -o build\temp.win32-2.4\Release\example_wrap.o
example_wrap.c: In function `My_variable_set':
example_wrap.c:2550: error: `My_variable' undeclared (first use in this
function)

.... ecc.


So I have had 3 problems, maybe some of you can suggest me how to solve
some of them.

(Can the standard Python site accept to distribuite an installer with
MinGW-compiled Python + minGW + SWIG for people using Windows that want
such system prebuilt? Maybe me or another person can assemble it).

Thank you,
bearophile
 
A

A.B., Khalid

To use Pyrex, SWIG and the like on a Win2K I have followed this way:

http://jove.prohosting.com/iwave/ipython/pyMinGW.html

I already had MinGW 3.4.2, so I have decompressed the Python 2.4.2
sources, I have merged in the pyMinGW patch, and I have run the global
compilation with:

make -f python24.mak all

It has compiled most things, but not zlibmodule.c
It has stopped the compilation with:

c:\......\bin\dllwrap.exe: no export definition file provided.
Creating one, but that may not be what you want
make[1]: Leaving directory `/.../PyminGW/Python-2.4.2/MinGW'
make -f zlib.mak
make[1]: Entering directory `/.../PyminGW/Python-2.4.2/MinGW'
gcc.exe -c ../Modules/zlibmodule.c -o ../Modules/zlibmodule.o
-I"../Include" -I"../Pc" -I"../../../d
ist/zlib-1.2.3" -Wall -s -DNDEBUG -D_USRDLL -O2
../Modules/zlibmodule.c:8:18: zlib.h: No such file or directory
../Modules/zlibmodule.c:66: error: syntax error before "z_stream"

... etc etc.

Anyway, probably 98% was compiled and this Python works, I have tried
the standard tests and most of them pass.
Then I have downloaded the pyMinGW Extensions V. 0.0.6.6, so zip and
other things now work.

The link to the Tcl-Tkinter extension doesn't work (the free site
hosting the file doesn't accept this file format anymore), so I cannot
use Tkinter.

I have decompressed SWIG and put it in a temporary Path.

I have then tried a basic SWIG example, (called example) coming from
this obsolete but probably still interesting page:
http://sebsauvage.net/python/mingw.html

But I have had problems durign the module creation:

C:\...\PyminGW\Python-2.4.2\MinGW>python setup.py build -cmingw32
running build
running build_ext
building 'example' extension
swigging example.i to example_wrap.c
C:\...\PyminGW\swigwin-1.3.28\swig.exe -python -o example_wrap.c
example.i
creating build
creating build\temp.win32-2.4
creating build\temp.win32-2.4\Release
C:\......\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\python24\include
-Ic:\pytho
n24\PC -c example_wrap.c -o build\temp.win32-2.4\Release\example_wrap.o
example_wrap.c: In function `My_variable_set':
example_wrap.c:2550: error: `My_variable' undeclared (first use in this
function)

... ecc.


So I have had 3 problems, maybe some of you can suggest me how to solve
some of them.

(Can the standard Python site accept to distribuite an installer with
MinGW-compiled Python + minGW + SWIG for people using Windows that want
such system prebuilt? Maybe me or another person can assemble it).

Thank you,
bearophile


It seems you may be using an old version of pyMinGW, because in the one
I have the directory issue of zlib was fixed and the relevant part
dealing with include directories in zlib.mak should read now as
follows:

LIBS = -L. -lpython24 -L"../../../dist/zlib-1.2.3" -lz
--image-base,0x1e1B0000
INCS = -I"../Include" -I"../Pc" -I"../../../dist/zlib-1.2.3"
CXXINCS = -I"../Include" -I"../Pc" -I"../../../dist/zlib-1.2.3"

The idea is to make INCS point at the location of your zlib sources.

As to the Tkinter-Tcl point, then please remember that this was a
binary build extension distribution that had nothing to do with the
core Python that pyMinGW is supposed to address. And if you download
the extension sources then you can certainly build the libraries
yourself, and then the python extensions, especially since you have
make files ready to use for the later in the pyMinGW sources. The
binary distribution was meant to make things a bit easier for people,
but since the site stopped the hosting of zip files and since many
people do not download that particular file anyway when it was hosted
elsewhere, letting the file expire (inactive files are removed after
one week from last download), then I hope you'd agree it would be much
work for me to keep track of expired and unexpired files and so keep on
uploading the files.

As to your SWIG problem, then I suggest you look into the pyMinGW's
extensions' directory. There you will find two examples of building C
and CPP extensions using SWIG and MinGW.

Regards,
Khalid



pyMinGW:
http://jove.prohosting.com/iwave/ipython/pyMinGW.html
 
B

bearophileHUGS

Thank you for your answers, Khalid.
It seems you may be using an old version of pyMinGW,

I have downloaded it yesterday from your site.

the relevant part dealing with include directories in zlib.mak
should read now as follows:

I have checked, and that relevant part is the same in my zlib.mak.

but since the site stopped the hosting of zip files and since many
people do not download that particular file anyway when it was hosted
elsewhere, letting the file expire (inactive files are removed after
one week from last download), then I hope you'd agree it would be much
work for me to keep track of expired and unexpired files and so keep on
uploading the files.

You can probably remove the dead link from your page.
(Maybe I can build a complete package (with Tkinter, minGW and Swig
too), and put it in some official Python site.)

As to your SWIG problem, then I suggest you look into the pyMinGW's
extensions' directory. There you will find two examples of building C
and CPP extensions using SWIG and MinGW.

I don't want to use/waste too much of your time, I have succed with the
C++ example, but the C example has given me some problems:

C:\...\PyminGW\Python-2.4.2\MinGW\Extensions\pyExt_C_exmaple>python24
setupMingW.py build --compile
r=mingw32
running build
running build_ext
building '_example' extension
swigging example.i to example_wrap.c
C:\...\PyminGW\swigwin-1.3.28\swig.exe -python -o example_wrap.c
example.i
C:\......\bin\gcc.exe -mno-cygwin -mdll -O2 -Wall -s
-IC:\...\PyminGW\Python-2.4
..2\include -IC:\...\PyminGW\Python-2.4.2\PC -c example_wrap.c -o
build\temp.win32-2.4\Release\examp
le_wrap.o
example_wrap.c: In function `PySwigClientData_New':
example_wrap.c:1205: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c: In function `PySwigObject_own':
example_wrap.c:1456: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c:1456: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c: In function `My_variable_set':
example_wrap.c:2515: error: `My_variable' undeclared (first use in this
function)

Bye,
bearophile
 
A

A.B., Khalid

Thank you for your answers, Khalid.


I have downloaded it yesterday from your site.



I have checked, and that relevant part is the same in my zlib.mak.



You can probably remove the dead link from your page.
(Maybe I can build a complete package (with Tkinter, minGW and Swig
too), and put it in some official Python site.)



I don't want to use/waste too much of your time, I have succed with the
C++ example, but the C example has given me some problems:

C:\...\PyminGW\Python-2.4.2\MinGW\Extensions\pyExt_C_exmaple>python24
setupMingW.py build --compile
r=mingw32
running build
running build_ext
building '_example' extension
swigging example.i to example_wrap.c
C:\...\PyminGW\swigwin-1.3.28\swig.exe -python -o example_wrap.c
example.i
C:\......\bin\gcc.exe -mno-cygwin -mdll -O2 -Wall -s
-IC:\...\PyminGW\Python-2.4
.2\include -IC:\...\PyminGW\Python-2.4.2\PC -c example_wrap.c -o
build\temp.win32-2.4\Release\examp
le_wrap.o
example_wrap.c: In function `PySwigClientData_New':
example_wrap.c:1205: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c: In function `PySwigObject_own':
example_wrap.c:1456: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c:1456: warning: dereferencing type-punned pointer will
break strict-aliasing rules
example_wrap.c: In function `My_variable_set':
example_wrap.c:2515: error: `My_variable' undeclared (first use in this
function)

Bye,
bearophile


You are using the C example extension found in pyMinGW, right? It
builds fine here, of course using the "python setup.py build" command.

$ python setupMinGW.py build
running build
running build_ext
building '_example' extension
swigging example.i to example_wrap.c
d:\MISC\PROGRAMS\SWIG-1.3.21\swig.exe -python -o example_wrap.c
example.i
creating build
creating build\temp.win32-2.4
creating build\temp.win32-2.4\Release
e:\UTILIT~1\PROGRA~1\MINGW\BIN\gcc.exe -mno-cygwin -mdll -O2 -Wall -s
-IG:\PROJS\PY24\PYTHON\DIST\SRC\include
-IG:\PROJS\PY24\PYTHON\DIST\SRC\PC -c example_wrap.c -o
build\temp.win32-2.4\Release\example_wrap.o
example_wrap.c:187: warning: 'SWIG_Python_TypeDynamicCast' defined but
not used
example_wrap.c:199: warning: 'SWIG_Python_TypeName' defined but not
used
example_wrap.c:205: warning: 'SWIG_Python_TypeQuery' defined but not
used
example_wrap.c:551: warning: 'SWIG_Python_MustGetPtr' defined but not
used
example_wrap.c:559: warning: 'SWIG_Python_ConvertPacked' defined but
not used
e:\UTILIT~1\PROGRA~1\MINGW\BIN\gcc.exe -mno-cygwin -mdll -O2 -Wall -s
-IG:\PROJS\PY24\PYTHON\DIST\SRC\include
-IG:\PROJS\PY24\PYTHON\DIST\SRC\PC -c example.c -o
build\temp.win32-2.4\Release\example.o
writing build\temp.win32-2.4\Release\_example.def
creating build\lib.win32-2.4
e:\UTILIT~1\PROGRA~1\MINGW\BIN\gcc.exe -mno-cygwin -shared -s
build\temp.win32-2.4\Release\example_wrap.o
build\temp.win32-2.4\Release\example.o
build\temp.win32-2.4\Release\_example.def
-LG:\PROJS\PY24\PYTHON\DIST\SRC\libs
-LG:\PROJS\PY24\PYTHON\DIST\SRC\PCBuild -lpython24 -o
build\lib.win32-2.4\_example.pyd

And copying that _example.pyd from the build directory just created to
our current directory so that python can see it, we can load that
extension fine as well:

$ python -i
Python 2.4.2 (#67, Nov 8 2005, 10:12:11)
[GCC 3.4.2 (mingw-special)] on win32
Type "help", "copyright", "credits" or "license" for more information.['__builtins__', '__doc__', '__file__', '__name__', '_example',
'_newclass', '_object', '_swig_getattr', '_swig_setattr', 'cvar',
'fact', 'fib', 'get_time', 'hello', 'my_mod']

Regards,
Khalid
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top