[Patches] [ python-Patches-400938 ] [Draft] libpython as shared library (.so) on Linux

noreply@sourceforge.net noreply@sourceforge.net
Thu, 09 Aug 2001 09:51:33 -0700


Patches item #400938, was opened at 2000-07-19 13:55
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=400938&group_id=5470

Category: None
Group: None
Status: Closed
Resolution: Out of Date
Priority: 5
Submitted By: Gregor Hoffleit (flight)
Assigned to: Guido van Rossum (gvanrossum)
Summary: [Draft] libpython as shared library (.so) on Linux

Initial Comment:
 

----------------------------------------------------------------------

Comment By: Frederic Giacometti (giacometti)
Date: 2001-08-09 09:51

Message:
Logged In: YES 
user_id=93657


If that helps, here is how I rebuild python and its library as shared entities, after the standard static build.

This works fine on Linux. The next problem on linux is that all native extensions also have to be explicitely 
relinked with the Python shared library.
A few months ago, I search the 12,000 python lines for the distutil for the line to modify to have this done 
properly, but I failed to find it...

Since then, I've started sketching a Python implementation of a Make-like tool (rule-based), so as not to 
use the distutils that are beyond my grasp; but it's a low priority task :((

It's only one line to modify in the distutil, and you'll get the dynamic version entirely build on Linux and likes, 
using what's below...

Regards,

Frederic Giacometti

 ----------------------------------

WHICH=which
PYTHONEXE=$(shell $(WHICH) python)
PYTHON_BUILDDIR=$(HOME)/local/src/Python-2.1
PYTHON_O=$(PYTHON_BUILDDIR)/Modules/python.o
PYTHONSTATICLIB=$(PYTHON_BUILDDIR)/lib$(PYTHONLIBNAME).a
SOBUILDDIR=$(JPEDIR)/pysolib

$(PYTHONSOLIB): $(PYTHONSTATICLIB) $(PYTHON_O)
	$(RM) -rf $(SOBUILDDIR)
	mkdir $(SOBUILDDIR)
	cd $(SOBUILDDIR) && ar x $<
	cd $(SOBUILDDIR) && ld -shared -export-dynamic -o $@ *.o\
 -lpthread -ldl -lutil -lm -lc
	mv $(PYTHONEXE) $(PYTHONEXE)~
	ld -export-dynamic -o $(PYTHONEXE) $(PYTHON_O)\
 -L$(PYTHONSOLIBDIR) -l$(PYTHONLIBNAME)\
 || (echo "failed to build $(PYTHONEXE)" && mv $(PYTHONEXE)~ $(PYTHONEXE)\
     && exit 23)


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-08-09 08:41

Message:
Logged In: YES 
user_id=6380

I'm moving this to PEP-24, small feature requests.

We're still waiting for someone to contribute a patch that
works.  I think it's best to have to request this explicitly
with a configure option.


----------------------------------------------------------------------

Comment By: Gregor Hoffleit (flight)
Date: 2001-06-12 15:19

Message:
Logged In: YES 
user_id=5293

> Now we're just waiting for someone to produce a working
patch.
> Or is there one already?

I'm currently distributing experimental packages of Python
2.1 for Debian. The packages include a hack to build
libpython2.1 as .so for Linux.

The shared library patch currently is buried in a big diff
file. You can get it as
http://people.debian.org/~flight/python2/python2_2.1-0.diff.gz

This is only a starting point for a real patch!

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-06-12 09:54

Message:
Logged In: YES 
user_id=6380

Reopening -- this keeps being requested.  Now we're just
waiting for someone to produce a working patch.

Or is there one already?

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-06-12 09:51

Message:
Logged In: YES 
user_id=6380

Reopening -- this keeps being requested.  Now we're just
waiting for someone to produce a working patch.

Or is there one already?

----------------------------------------------------------------------

Comment By: Neil Schemenauer (nascheme)
Date: 2001-03-21 15:59

Message:
Logged In: YES 
user_id=35752

We're going to have to create a new patch to do this.  This
one is
way too out of date.  Maybe for 2.2.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-01-19 14:46

Message:
I'm reassigning this to Neil.

Neil, can you see if you can integrate this into your flat Makefile?

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-01-17 15:09

Message:
Andrew, I'm tentatively reassigning this to you, since you're taking charge of the build process at the moment (setup.py).

I suspect that the patch no longer works as is -- would it make sense to mark it postponed and get the author to submit a new version before we release 2.1a1?


----------------------------------------------------------------------

Comment By: Nobody/Anonymous (nobody)
Date: 2001-01-17 14:46

Message:
Getting this patch into the next version of Python would be "A Good Thing"(tm) in my opinion.  We use libpython as a .so at ILM and end up having to make changes like this by hand every time we get a new version...

----------------------------------------------------------------------

Comment By: Moshe Zadka (moshez)
Date: 2000-11-01 03:32

Message:
I've had a look at the patch, and it seems it has
two orthogonal parts. One is adding the infrastructure
for compiling another version for the Python library, which can be more or less integrated as-is, and one is hard-coding the particular way, in Linux, of building shared objects. Since we discover how to build shared objects in the configure script anyway (otherwise we could not have built modules as shared objects), we should embed that information there, not the Linux flags.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2000-10-26 14:13

Message:
Let's give this to Jeremy instead, because he seems to know more about build issues. Jeremy, it would be good to look into getting this to work with your RPM suite. Flight's argument (has been used without complaints in Debian Python 1.5.2 since 1999) is good.

----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2000-08-23 09:26

Message:
In the absence of anyone arguing for inclusion of this patch and a one-week idle period, it is postponed.

----------------------------------------------------------------------

Comment By: Moshe Zadka (moshez)
Date: 2000-08-16 00:40

Message:
I suggest we postpone it. It isn't really complete (only works on real distributions <wink>), and the complete solution should work on all unices. If Tcl/Perl can do it, there is no reason Python can't -- and a half hearted solution isn't that good. flight, you should use this
for the Python in woody in the mean time -- I doubt woody
will be stable before Python 2.1 comes out, so 2.1 sounds
like a good timeframe to do it.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2000-08-15 10:52

Message:
Assigned to Barry because he's a Linux weenie.  Barry, if you think there's something here that should go into 2.0, please pursue it now, else change the status to Postponed.

----------------------------------------------------------------------

Comment By: Gregor Hoffleit (flight)
Date: 2000-07-19 14:10

Message:
This is what it used in product to build libpython as shared library(.so) for Debian.

Note: This patch is not ready for inclusion in the upstream Python distribution. Anyway, I think this might be a start. The Python 1.5 executable in Debian GNU/Linux is built against a shared libpython1.5.so since April 1999, and I haven't yet heard about any problems.

Using a shared library should have an advantage if you're running multiple instances of Python (be it standalone interpreter or embedded applications).


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=400938&group_id=5470