Object oriented databae for Python
Konstantin Knizhnik
knizhnik at garret.ru
Fri Mar 21 13:31:32 EST 2003
Hello achrist,
This is problem with definition DL_EXPORT macro in Python 2.2.2
With 2.3 it works ok, but not with 2.2.2.
May be I just do not define some environment variable. But neither
USE_DL_EXPORT, USE_DL_IMPORT properly works:
In pyconfig.h we have:
#ifdef USE_DL_IMPORT
#define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE
#endif
#ifdef USE_DL_EXPORT
#define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE
#define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
#endif
And in python.h:
#ifndef DL_IMPORT /* declarations for DLL import/export */
#define DL_IMPORT(RTYPE) RTYPE
#endif
#ifndef DL_EXPORT /* declarations for DLL import/export */
#define DL_EXPORT(RTYPE) RTYPE
#endif
So looks like USE_DL_EXPORT should be used for building Python core,
and USE_DL_IMPORT is not enough for building proper client extension
- it doesn't define DL_EXPORT, so module init function is not
imported.
That is why in original version I did it it such way:
#ifdef _WIN32
__declspec(dllexport)
#endif
void
initpythonapi(void)
{
Py_InitModule("pythonapi", dybase_methods);
}
But Gerhard send me patch where this my hack was removed (by using
DL_EXPORT macro).
At this moment I already forgot the reason of such hack, so I check
that this code works (with Python 2.3) and apply the fix.
I forgot about the problem with Python 2.2.
So no I am going to return back to my original code which should work
with both versions of Python. Or may be there is some better solution?
Friday, March 21, 2003, 8:18:05 PM, you wrote:
aec> achrist at easystreet.com wrote:
>>
>>
>> I expect I'll be trying to re-build this with MSVC++ v6 with
>> debugging off in a couple of hours.
>>
aec> Here's what I did:
aec> 1. Changed makefile.mvc to what shown below
aec> 2. Changed Make.Bat to what shown below
aec> 3. Changed Compile.Bat in the Python Dir of Dybase to what shown below
aec> I ran Make.Bat and Compile.Bat, and they each appear to work.
aec> I set up and ran a batch file to run the examples (below)
aec> Example Guess.Py gives an error:
aec> Traceback (most recent call last):
aec> File "I:\Python\Lib\site-packages\dybase\python\guess.py", line
aec> 6, in ?
aec> import dybase
aec> File "I:\Python\Lib\site-packages\dybase\python\dybase.py",
aec> line 6, in ?
aec> import pythonapi
aec> ImportError: dynamic module does not define init function
aec> (initpythonapi)
aec> Al
aec> ----------------New MakeFile.Mvc Follows-----------------------
aec> # -*- makefile -*-
aec> # Makefile for Microsoft Windows with Microsoft Visual C++ 5.0 and
aec> higher compiler
aec> OBJS = btree.obj database.obj dybase.obj file.obj pagepool.obj
aec> INCS = database.h btree.h buffer.h file.h hashtab.h pagepool.h stdtp.h
aec> sync.h ..\inc\dybase.h
aec> DYBASE_LIB = ..\lib\dybase.lib
aec> DYBASE_DLL = ..\lib\dybasedll.dll
aec> CC = cl
aec> COMMON_FLAGS = -I. -GX -I..\inc -c -nologo
aec> CFLAGS = $(COMMON_FLAGS) -W3 -MD
aec> DLLFLAGS = -LD -nologo
aec> LD = $(CC)
aec> LDFLAGS = -MD -nologo
aec> AR = lib
aec> ARFLAGS =
aec> all: $(DYBASE_LIB) $(DYBASE_DLL)
aec> btree.obj: btree.cpp $(INCS)
aec> $(CC) $(CFLAGS) btree.cpp
aec> database.obj: database.cpp $(INCS)
aec> $(CC) $(CFLAGS) database.cpp
aec> file.obj: file.cpp $(INCS)
aec> $(CC) $(CFLAGS) file.cpp
aec> pagepool.obj: pagepool.cpp $(INCS)
aec> $(CC) $(CFLAGS) pagepool.cpp
aec> dybase.obj: dybase.cpp $(INCS)
aec> $(CC) $(CFLAGS) -DDYBASE_DLL dybase.cpp
aec> $(DYBASE_LIB): $(OBJS)
aec> $(AR) $(ARFLAGS) /OUT:$(DYBASE_LIB) $(OBJS)
aec> $(DYBASE_DLL): $(OBJS)
aec> $(CC) $(DLLFLAGS) /Fe$(DYBASE_DLL) $(OBJS)
aec> cleanobj:
aec> -del *.exp,*.obj,*.pch,*.pdb,*.ilk,*.dsp,*.dsw,*.ncb,*.opt
aec> clean: cleanobj
aec> -del $(DYBASE_LIB),$(DYBASE_DLL)
aec> zip: clean
aec> cd ..\..
aec> -del dybase.zip
aec> zip -r dybase.zip dybase
aec> --------------------------------------------------------
aec> ---------------------New Make.Bat-----------------------
aec> set path=D:\Msvc\Bin;%PATH%
aec> set include=D:\Msvc\Include;%path;
aec> nmake -f makefile.mvc %1 %2 %3 %4 %5 %6 %7 %8 %9
aec> -----------------------------------------------------------
aec> ----New Compile.Bat (There are just 2 lines, ignore wrap --
aec> set PYTHON_HOME=I:\Python
aec> cl -MD -GX -LD -I%PYTHON_HOME%\Include -I..\inc -Fepythonapi.dll
aec> pythonapi.c ..\lib\dybasedll.lib %PYTHON_HOME%\libs\python22.lib
aec> -------------------------------------------------------
aec> ----------------RunExamples.Bat -----------------------
aec> Set Path=I:\Python\Lib\Site-Packages\Dybase\Lib;%Path%
aec> Guess.Py
aec> Pause
aec> TestIndex.Py
aec> Pause
aec> TestLink.Py
aec> Pause
--
Best regards,
Konstantin mailto:knizhnik at garret.ru
More information about the Python-list
mailing list