distutils, C extensions, Borland compiler, wxPython

Michael Hudson mwh at python.net
Tue Feb 5 09:26:26 EST 2002


"Anders J. Munch" <andersjm at dancontrol.dk> writes:

> I have built Python from source on Win2K using cygwin except with a
> Borland compiler (BCB4) instead of gcc.  It took a fair amount of
> hacks to get the configure script and makefiles to work (s/.o/.obj/ is
> just the beginning) but it was worth it.

Which version of Python?  I thought there was at least *some* support
for this in recent versions of python.

Have you looked at google to see if people have tried this before?

> It's all statically linked.  I kinda like monolithic executables, so
> rather than get .dlls to work I have just disabled that part of the
> makefile.
> 
> It works great.  I've been extending and embedding like crazy for a
> while, using Setup.local.
> 
> There's just one hitch: distutils.  I'd like to use wxPython, but
> wxPython uses distutils with C extensions.
> 
> "python setup.py install" fails, unsurprisingly, because it doesn't
> know how to build and import the C++ code.

Try using 

$ python setup.py build --compiler=bcpp install

> I wonder if the configure/make process is supposed to store this
> information somewhere, but even if it did, it probably wouldn't
> work.  I presume distutils relies on the use of .dll/.so's which I'd
> rather not have to mess with,

Hopefully the author of ../distutils/bccpcompiler.py has done the
messing already...

> and also my python.exe is not a cygwin app. and hence doesn't
> understand the cygwin paths from the make process.

Don't really follow you here, but as I've never used the borland
compiler and try to avoid understanding windows issues...

> Now what I'd like to have is for distutils to just tell me which
> .c/.c++ files need to be compiled into python and with which options,
> so that I could add these files to Setup.local manually and rebuild
> python.exe.

This *shouldn't* be that hard; the setup.py file should contain a list
of source files that need compiling, like

setup(...
      extensions = [Extension("wx", ["wxfile1.c", "wxfile2.c"]),
        ...]
      ...)

this translates to lines in Setup.local along the lines of

wx wxfile1.c wxfile2.c 

> The distutils docs I have seen so far don't seem to get beyond
> "press the big green button and everything works automatically".  

That's the hope.

> Are there any docs on how to tell distutils which compiler to use
> and how?

There's

http://python.sourceforge.net/devel-docs/inst/inst.html

but I don't know how thorough this is -- I generally read the source
when I need to understand what distutils is up to...

> TIA for any advice.

HTH.

> the-docs-state-that-"Windows-Python-is-built-in-Microsoft-Visual-C++"-
> which-is-of-course-perfectly-true-(except-when-it-isn't)-ly y'rs, 
>  Anders
> 
> 
> PS: The wxPython setup.py error message that I get:
> ! Traceback (most recent call last):
> !   File "setup.py", line 10, in ?
> !     from my_distutils import run_swig, contrib_copy_tree
> ! File "my_distutils.py", line 125, in ?
> !  ccompiler.default_compiler['nt'] = 'my_msvc'
> ! AttributeError: 'module' object has no attribute 'default_compiler'

Oh, it looks like wxPython plays silly buggers in it's
setup.py... this may make things more complicated.  Or not.

Cheers,
M.

-- 
112. Computer Science is embarrassed by the computer.
  -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html



More information about the Python-list mailing list