This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Cygwin 2.1 and Python modules


Dave,

On Thu, Jul 05, 2001 at 10:58:56AM -0400, David Abrahams wrote:
> > The above is usually done to build straight Win32 extension modules with
> > Mingw or Cygwin -mno-cygwin -- not to build Cygwin extension modules.
> 
> Oh! So if I built my extension modules with -mno-cygwin and used pexports to
> generate the import library, you think I might be able to link with the
> regular Windows Python release?

Yes, see the following:

    http://starship.python.net/crew/kernr/mingw32/Notes.html

If you are willing to use a non-standard way of building extension
modules (neither Misc/Makefile.pre.in or Distutils), then see attached.
This makefile builds the readline extension module for the Win32 Python.
It takes advantage of somewhat recent Cygwin gcc enhancements:

    1. binding to msvcrt.dll instead of crtdll.dll
    2. ability to link directly to a DLL (instead of requiring an import
       library)

You can use this as an example and modify it to suit your needs.  Note
that it obviates the need for pexports.

Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
# Directory definitions
PythonDistDir = /mnt/d/Program\ Files/Python21
PythonDllDir = /mnt/c/WINNT/system32
PythonSourceDir = /home/jt/src/Python-2.1
MingwDir = /apps/mingw

# Constant definitions
CC = gcc -mno-cygwin
CPPFLAGS = -D__READLINE_IMPORT__ -I $(PythonDistDir)/Include \
    -I $(MingwDir)/include
LDFLAGS = -s -shared -Wl,--enable-auto-image-base
LDLIBS = $(PythonDllDir)/python21.dll $(MingwDir)/bin/libreadline.dll
INSTALL = install
INSTALLFLAGS = -s

# VPATH definitions
vpath %.c $(PythonSourceDir)/Modules

# all target
all: readline.pyd

# install target
install: all
	$(INSTALL) $(INSTALLFLAGS) readline.pyd $(PythonDistDir)/DLLs
	$(INSTALL) $(INSTALLFLAGS) $(MingwDir)/bin/libreadline.dll $(PythonDistDir)/DLLs

# clean target
clean:
	$(RM) $(RMFLAGS) readline.*
	
# readline.def target
readline.def:
	echo LIBRARY readline.pyd >$@
	echo EXPORTS >>$@
	echo initreadline >>$@

# Win32 Python readline module target
readline.pyd: readline.o readline.def

# .pyd rule
%.pyd: %.o
	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]