[Distutils] Re: distutils?- Borland Extensions

Rene Liebscher R.Liebscher@gmx.de
Mon Feb 19 07:27:59 2001


Terry@trewitt.org wrote:
> 
> (A plea for help from a Zope newbie...)
> 
> I am attempting to build the elusive "_mysqldb" module required by
> ZMySQLDA, from
> <http://www.zope.org/Members/adustman/News/MySQL_Support_20000115>, under
> Win98 with Borland BCC 5.5.
> 
> In the post
> <http://mail.python.org/pipermail/distutils-sig/2000-October/001694.html>,
> Rene Liebscher wrote:
> 
> > First convert all MSVC++ libraries you need from COFF to OMF.
> > coff2omf python20.lib python20_bcpp.lib
> 
> I performed this step successfully
> 
> > When you want to link against a library (python20), distutils checks
> > if there is a library with _bcpp suffix and uses it, otherwise
> > it tries the normal name for the library (python20.lib).
> 
> This failed for me, so I replaced the entry in config.h for "python20.lib"
> with "python20_bcpp.lib":
>         #pragma comment(lib,"python20_bcpp.lib")
This makes no sense because it is enclosed in an #ifdef _MSC_VER
(python20_bcpp.lib was found!!! see your command line
"D:\PROGRAM FILES\LSS-ZOPE\BIN\PYTHON20\libs\python20_bcpp.lib" )

> > The second point is, you have to specify that you want to use the
> Borland compiler.
> > python setup.py install build_ext --compiler=bcpp
> 
> (many Thanks for this obscure tip)
> The error file resulting from this step is posted below
> 
> Can anyone provide any enlightenment as to what I could be missing, or
> where I should be looking for 'LIBS.OBJ'?  Are the warnings shown below
> usual for this module?  I am neither a C or Python programmer, although I
> was in a former life, many years ago.  I found and loaded BCC just for
> this project.
(The warnings are not a problem I think, because Borland C++ brings
more warnings than most other compilers.)

I think the problem (LIBS.OBJ) is the following part of the command line

C:\BORLAND\BCC55\BIN\ilink32.exe /Tpd /Gn /q /x 
/Ld:\nusphere\mysql\lib\opt 
==> "/LD:\PROGRAM FILES\LSS-ZOPE\BIN\PYTHON20\libs" <==
/L. c0d32 
build\temp.win32-2.0\Release\_mysqlmodule.obj 
d:\nusphere\mysql\lib\opt\mysqlclient.lib ,
build\lib.win32-2.0\_mysql.pyd 
,, d:\nusphere\mysql\lib\opt\mysqlclient.lib 
d:\nusphere\mysql\lib\opt\zlib.lib msvcrt libcmt wsock32 advapi32 
"D:\PROGRAM FILES\LSS-ZOPE\BIN\PYTHON20\libs\python20_bcpp.lib" import32 
cw32mt , build\temp.win32-2.0\Release\_mysql.def ,

Because of the quoting ilink might take this as an object filename.
(If it is not this, it might be the similar path name in the ilink32.cfg
file.)

It might be help to patch distutils/bcppcompiler.py as follows
-----------------------------------------------------------------------
--- bcppcompiler.py Mon Feb 12 10:46:21
2001                                    
+++ bcppcompiler_new.py Mon Feb 19 13:18:51
2001                                
@@ -257,7 +257,7
@@                                                             
                                                                                
                                                                                
             for l in
library_dirs:                                             
-                ld_args.append("/L%s" %
os.path.normpath(l))                   
+                ld_args.extend(["/L","%s" %
os.path.normpath(l)])              
             ld_args.append("/L.") # we sometimes use relative
paths            
                                                                                
             # list of object
files                                             
------------------------------------------------------------------------
I don't know if it helps, because I currently have no (Windows,Borland
C++)
computer available to test it. If it works send me a note, so we can
make it
an offical patch for distutils.

Kind regards
Rene Liebscher

> ...
> 
> ----------------------------------------------------------------------
> The creation of these 2 vital files was suggested by Gordon Williams
> <http://www.cyberus.ca/~g_will/pyExtenDL.shtml> (Many Thanks!)
> ------------------------------------------------
> C:\Borland\bcc32\bin\bcc32.cfg:
> ------------------------------------------------
> -w
> -I"c:\BORLAND\BCC55\INCLUDE;.\;D:\PROGRAM
> FILES\LSS-ZOPE\bin\PYTHON20\INCLUDE;d:\nusphere\mysql\include"
> -L"c:\BORLAND\BCC55\LIB;c:\Borland\Bcc55\lib\psdk;D:\PROGRAM
> FILES\LSS-ZOPE\bin\PYTHON20\LIBS;d:\nusphere\mysql\lib\opt"
> 
> ------------------------------------------------
> C:\Borland\bcc32\bin\ilink32.cfg:
> ------------------------------------------------
> -x
> -L"C:\BORLAND\BCC55\LIB;C:\Borland\bcc55\lib\psdk;D:\PROGRAM
> FILES\LSS-ZOPE\bin\PYTHON20\LIBS"
> 
> ------------------------------------------------
> python setup.py install build_ext --compiler=bcpp > build.log
> ------------------------------------------------
> _mysqlmodule.c:
> Warning W8060 _mysqlmodule.c 81: Possibly incorrect assignment in function
> _mysql_Exception
> ...
> Warning W8060 _mysqlmodule.c 1732: Possibly incorrect assignment in
> function init_mysql
> Fatal: Unable to open file 'LIBS.OBJ'
> running install
> running build
> running build_py
> copying MySQLdb.py -> build\lib.win32-2.0
> copying CompatMysqldb.py -> build\lib.win32-2.0
> running build_ext
> building '_mysql' extension
> C:\BORLAND\BCC55\BIN\bcc32.exe -c /tWM /O2 /q /g0
> -Id:\nusphere\mysql\include "-ID:\PROGRAM
> FILES\LSS-ZOPE\BIN\PYTHON20\Include"
> -obuild\temp.win32-2.0\Release\_mysqlmodule.obj _mysqlmodule.c
> writing build\temp.win32-2.0\Release\_mysql.def
> C:\BORLAND\BCC55\BIN\ilink32.exe /Tpd /Gn /q /x
> /Ld:\nusphere\mysql\lib\opt "/LD:\PROGRAM
> FILES\LSS-ZOPE\BIN\PYTHON20\libs" /L. c0d32
> build\temp.win32-2.0\Release\_mysqlmodule.obj
> d:\nusphere\mysql\lib\opt\mysqlclient.lib , build\lib.win32-2.0\_mysql.pyd
> ,, d:\nusphere\mysql\lib\opt\mysqlclient.lib
> d:\nusphere\mysql\lib\opt\zlib.lib msvcrt libcmt wsock32 advapi32
> "D:\PROGRAM FILES\LSS-ZOPE\BIN\PYTHON20\libs\python20_bcpp.lib" import32
> cw32mt , build\temp.win32-2.0\Release\_mysql.def ,