[From nobody Wed Mar 25 13:43:10 2020
Date: Mon, 06 May 2002 12:59:22 -0400
From: Jason Tishler &lt;jason@tishler.net&gt;
Subject: Re: Creating C modules for Python under Cygwin
In-reply-to: &lt;pNwB8.9120$zW3.232547@news1.tin.it&gt;
To: Alex Martelli &lt;aleax@aleax.it&gt;
Cc: python-list@python.org,
 Martin =?iso-8859-1?Q?v=2E_L=F6wis?= &lt;loewis@informatik.hu-berlin.de&gt;
Mail-followup-to: Alex Martelli &lt;aleax@aleax.it&gt;, python-list@python.org,
 Martin =?iso-8859-1?Q?v=2E_L=F6wis?= &lt;loewis@informatik.hu-berlin.de&gt;
Message-id: &lt;20020506165922.GN1668@tishler.net&gt;
MIME-version: 1.0
Content-type: multipart/mixed; boundary=&quot;Boundary_(ID_bKmLZlV7ivR7cd9WCEclyg)&quot;
Content-transfer-encoding: 8BIT
User-Agent: Mutt/1.3.24i
References: &lt;3CD41CC4.5752F30C@wag.caltech.edu&gt;
 &lt;j43cx6ilpq.fsf@informatik.hu-berlin.de&gt; &lt;20020506131744.GD1668@tishler.net&gt;
 &lt;mailman.1020694211.2354.python-list@python.org&gt;
 &lt;pNwB8.9120$zW3.232547@news1.tin.it&gt;


--Boundary_(ID_bKmLZlV7ivR7cd9WCEclyg)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 8BIT
Content-disposition: inline
Content-length: 1588

On Mon, May 06, 2002 at 02:53:09PM +0000, Alex Martelli wrote:
&gt; Martin v. Löwis wrote:
&gt; &gt; I think this is what Alex had in mind.
&gt; 
&gt; Alex doesn't understand the details of Cygwin, and dlltool in particular, 
&gt; well enough to be certain, but it sure looks something like what I was
&gt; saying should be doable, yes.
&gt; [snip]

OK, I got it to work.  My previous procedure was incorrect because it did
not get python.exe to export any symbols.  The new (still quick and dirty)
procedure is as follows:

    $ configure --disable-shared
    $ make python.exe # [1]
    $ mkexp.sh        # [2]
    $ make            # [3]

Notes:

    [1] make will stop after python.exe is built but before the shared
        extensions are.
    [2] Rebuild python.exe to export all appropriate symbols.  The
        attached shell script, mkexp.sh, just blindly follows the
        procedure used by Cygwin PostgreSQL to export symbols from an
        executable.  I admit to not fully grokking this procedure (yet).
        Additionally, there may be better, more modern ways (i.e., gcc
        -shared) of accomplishing the same results.  I will investigate
        further.
    [3] Continue make to build the shared extensions.

A Cygwin Python with a static Python library built with the above
procedure successfully loads shared extensions and passes all regression
tests.

I intend to submit a patch to Python CVS with a clean version of the
above.  However my motivation would be greater, if I actually knew of
someone who is really interested in this functionality.  Is there anyone?

Thanks,
Jason

--Boundary_(ID_bKmLZlV7ivR7cd9WCEclyg)
Content-type: application/x-sh; NAME=mkexp.sh
Content-transfer-encoding: quoted-printable
Content-disposition: attachment; filename=mkexp.sh
Content-length: 2577

#!/bin/sh=0A=
=0A=
# Echo commands as executed=0A=
set -x=20=0A=
=0A=
# Create the def file=0A=
dlltool --export-all --output-def python2.3.def Modules/getbuildinfoo Parse=
r/acceler.o Parser/grammar1.o Parser/listnode.o Parser/node.o Parser/parser=
.o Parser/parsetok.o Parser/tokenizer.o Parser/bitset.o Parser/metagrammar.=
o Parser/myreadline.o Objects/abstract.o Objects/boolobject.o Objects/buffe=
robject.o Objects/cellobject.o Objects/classobject.o Objects/cobject.o Obje=
cts/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/file=
object.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o O=
bjects/intobject.o Objects/iterobject.o Objects/listobject.o Objects/longob=
ject.o Objects/dictobject.o Objects/methodobject.o Objects/moduleobject.o O=
bjects/object.o Objects/obmalloc.o Objects/rangeobject.o Objects/sliceobjec=
t.o Objects/stringobject.o Objects/structseq.o Objects/tupleobject.o Object=
s/typeobject.o Objects/weakrefobject.o Objects/unicodeobject.o Objects/unic=
odectype.o Python/bltinmodule.o Python/exceptions.o Python/ceval.o Python/c=
ompile.o Python/codecs.o Python/errors.o Python/frozen.o Python/frozenmain.=
o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright=
.o Python/getmtime.o Python/getplatform.o Python/getversion.o Python/gramin=
it.o Python/import.o Python/importdl.o Python/marshal.o Python/modsupport.o=
 Python/mystrtoul.o Python/mysnprintf.o Python/pyfpe.o Python/pystate.o Pyt=
hon/pythonrun.o Python/structmember.o Python/symtable.o Python/sysmodule.o =
Python/traceback.o Python/getopt.o Python/dynload_shlib.o Python/thread.o M=
odules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules=
/threadmodule.o Modules/signalmodule.o Modules/posixmodule.o Modules/_sre.o=
 Modules/newmodule.o Modules/symtablemodule.o Modules/xxsubtype.o=0A=
=0A=
# Create the import library=0A=
dlltool --dllname python.exe --def python2.3.def --output-lib libpython2.3.=
dll.a=0A=
=0A=
# Create the export file=0A=
dlltool --dllname python.exe --output-exp python2.3.exp --def python2.3.def=
=0A=
=0A=
# Create the base file=0A=
gcc -o python.exe -Wl,--base-file,python2.3.base python2.3.exp Modules/pyth=
on.o libpython2.3.a -lutil -lm=0A=
=0A=
# Create the export file (again) but incorporate the base file=0A=
dlltool --dllname python.exe --base-file python2.3.base --output-exp python=
2.3.exp --def python2.3.def=0A=
=0A=
# Create python.exe that exports the appropriate symbols=0A=
gcc -o python.exe python2.3.exp Modules/python.o libpython2.3.a -lutil -lm=
=0A=
=0A=

--Boundary_(ID_bKmLZlV7ivR7cd9WCEclyg)--

]