Python Un*x build with a Python shared library

Frederic Giacometti frederic.giacometti at arakne.com
Wed May 16 08:08:44 EDT 2001


The problem I am getting is that all Python extension modules need to be
relinked.
Here the kind of error I'm getting:

$ java -verbose:jni,class,gc
-Djava.library.path=/home-import/fgiacometti/local/src/jpe
-Djava.class.path=/home-import/fgiacometti/local/src/jpe python.PyRun
test.py
Traceback (most recent call last):
  File "test.py", line 35, in ?
    import unittest
  File
"/home-import/fgiacometti/local/src/Python-2.1/build/lib/python2.1/unittest.py",
line 51, in ?
    import time
ImportError:
/home-import/fgiacometti/local/src/Python-2.1/build/lib/python2.1/lib-dynload/time.so:
undefined symbol: PyExc_IOError
gmake: *** [test] Error 1

time.so must be linked to libpython2.1.so !!!, just like every other
Python extension (a la Windows).

Thus the incentive to directly patching this into distutils, since this
is now the module used for building the extensions.

Unfortunately, the distutil code is obscure and over-engineered
to me (my QA background also tells me:  if you see statements like 'from
... import *' in module files, prepare yourself for some hard time...
and this rule never miss, sadly enough).
The 1047 lines of the disutils/ccompiler.py file are beyond my grasp...

I'm still looking for the right line to patch. Any help?

FG

[PS:
FYI, the distutil package has a total of 12,976 lines in 41 py files...
Ouch!

And yet, I haven't been able to find in distutils what I need for
writing a portable Makefile (running with VC6's nmake on Windows and
Unix V standard make).]


Oleg Broytmann wrote:

> On Tue, 15 May 2001, Frederic Giacometti wrote:
> > Changes requested on the current Python 2.1 source distribution:
> > ==========================================
> > Changes should be required in only two location:
> >     - main Python Makefile
> >     - the distutil code that links the dynamic extensions.
>
>    Nice to see someone returned to the issue. The following shell script
> works for me perfectly (Linux, of course):
>
> -----
> #! /bin/sh
>
> # For Linux systems, the simplest method of producing libpython.so seems to be
> # (originally from the Minotaur project web page, http://mini.net/pub/ts2/minotaur.html)
>
> make distclean
> OPT="-fpic -O2" CPPFLAGS=-I/usr/local/include/ncurses mconfig $*
> make || exit 1
>
> mkdir .extract
> (cd .extract; ar xv ../libpython2.1.a)
> gcc -shared -o libpython2.1.so .extract/*.o
> rm -rf .extract
> -----
>
>    But of course it'd be nice to allow Distutils recognize a platform and
> do appropriate build.
>
> Oleg.
> ----
>      Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list