How to make an extension of Python

Mitsuo Igarashi mitsu5@ruby.famille.ne.jp
Thu Nov 9 23:37:00 GMT 2000


Jason

|> May I have questions?
|>
|> Question 1).
|>   Why does the usual build up of python end in a failure in making an
|> extension?
|
|Because the usual Cygwin Python build does not produce the import
|library needed by extensions and even if it did python.exe does not
|export those symbols anyway.
|
|> What is your patch doing to correct the failure?
|
|The key to my patch is that it builds the Python core as a DLL just
|like the Win32 version does.  Once Python is built as a "shared library"
|(i.e., DLL), developers can build extensions just like on any other UNIX
|platform that supports shared libraries.
|
|Actually building Python as a DLL was much easier than I thought --
|mainly because the same code already compiles as a DLL on Win32.  The hard
|part was integrating into the idiosyncrasies of Python's autoconf, make,
|and makesetup build infrastructure.
|
|I believe that one could have alternatively modified the build procedure
|to produce the import library and export those symbols directly from
|python.exe without building a DLL.  This is similar to what PostgreSQL
|does for postgres.exe and pgpsql.dll.  I decided against this approach
|for three reasons:
|
|    1. I feel that consistency between the Win32 and Cygwin versions is
|       important.
|    2. The DLL approach is better for embedded Python too.
|    3. I already had the DLL approach working and didn't want to start
|       all over again.
|
|Obviously, reason #3 above is the most compelling. :,)


Thanks lots for your kind explanation.

|> >dllwrap --def cx_Oracle.def --output-lib libcx_Oracle.a --dllname
|> cx_Oracle.dll \
|> >        cx_Oracle.o -L/Tools/Library/Win32 -loci -lpython20
|>
|> I tried the following written procedure that ended up in the error
message:
|>
|> dllwrap -o myEnviron.pyd -def myEnviron.def myEnviron.o -lpython2.0
|> "Importerror: dynamic modules does not define init
|> function ( initmyEnviron)".
|
|My guess is for some reason initmyEnviron is not being exported from
|myEnviron.pyd.  What is the contents of your myEnviron.def file?


EXPORTS
 initenviron

|> I could create the extension of "environ.c" according to the following
|> instruction by Mingw32.
|>
|> http://starship.python.net/crew/kernr/mingw32/Notes.html
|> Instructions for Python Extensions with GCC/mingw32 by Robert Kern.
|>
|> >dllwrap --dllname foo.pyd --driver-name gcc --def foo.def -o foo.pyd \
|> >foomodule.o -s --entry _DllMain@12 --target=i386-mingw32 -L<py-lib-dir>
\
|> >-lpython15
|> However, the same "environ.c" could not be a successful dll binary in
|> Cygwin.
|
|Were you importing the above module into the Win32 or Cygwin Python?


cygwin python

This failure is probably the bad -lpython2.0.
"libpython2.0.a" is not shared?

Your explanation is a bit difficult to me.
Thanks again.
----------=========---------
Mitsuo Igarashi
mitsu5@ruby.famille.ne.jp


--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list