This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Missing documentation on how to link with libpython
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, eric.araujo, ned.deily, pitrou, python-dev, raorn, rpq
Priority: normal Keywords: patch

Created on 2004-10-05 06:51 by raorn, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
docembed.patch pitrou, 2011-11-29 18:16 review
docembed-edits.patch eric.araujo, 2012-01-06 16:43 review
Messages (21)
msg60573 - (view) Author: Sir Raorn (raorn) Date: 2004-10-05 06:51
Missing documentation part about linking program with
libpython (embedding python). Questions are:

How one can get needed CFLAGS (-I... -D...)

How one can get needed LDFLAGS (-L... -l...)

For now, applications assumes that headers located in
PREFIX/include/pythonX.Y, libraries located in
EXEC_PREFIX/lib/pythonX.Y/config
msg109742 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-09 14:15
The number of google hits tells me this is still an issue.
msg148568 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-11-29 14:05
I did not found all these Google hist.  Most of the links on the first page for “link libpython” are bug reports which are rejected by maintainers.  Related: http://mail.python.org/pipermail/python-dev/2006-February/060549.html

So, what do people link with libpython for?
msg148573 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-11-29 14:44
Éric, this is for embedding a Python interpreter in a C/C++ application. I tend to agree that the official doc page (http://docs.python.org/extending/embedding.html) on this topic is somewhat lacking in the area of the configuration/compilation procedure. There's some info scattered around the web in tutorials, though.

So I'd say it's a valid issue.
msg148587 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-29 17:37
There is (outdated, incomplete and clumsy) documentation about using distutils.sysconfig from the command-line. I'll try to work on a small patch. It will probably be Unix-only, though.
msg148589 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-29 18:04
Attached patch rewrites the offending paragraphs.
msg148590 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-29 18:16
Updated markup.
msg148591 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2011-11-29 18:29
Antoine, this is a big improvement - LGTM.
msg148684 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-11-30 20:25
New changeset 2c05b8a6cdd1 by Antoine Pitrou in branch '3.2':
Issue #1040439: better document how to compile and link an embedded Python interpreter.
http://hg.python.org/cpython/rev/2c05b8a6cdd1

New changeset 528abe272856 by Antoine Pitrou in branch 'default':
Issue #1040439: better document how to compile and link an embedded Python interpreter.
http://hg.python.org/cpython/rev/528abe272856
msg148685 - (view) Author: Ray (rpq) Date: 2011-11-30 20:38
I think mentioning that you can export CFLAGS and LDFLAGS would be particularly useful.  I was able to compile some of the missing packages that were deemed 'missing' at the end of 'make' by updating setup.py and having CFLAGS and LDFLAGS point to the desired packages' directories...  Unfortunately for linux, the ability to specify *multiple* lib/ and include/ paths using this method is currently not available unless you modify setup.py.  I opened a ticket in relation to this: Issue13511 if anyone cares.
msg148686 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-11-30 20:48
> I think mentioning that you can export CFLAGS and LDFLAGS would be
> particularly useful.  I was able to compile some of the missing
> packages that were deemed 'missing' at the end of 'make' by updating
> setup.py and having CFLAGS and LDFLAGS point to the desired packages'
> directories...

Unless I'm missing something, this is slightly off-topic for this issue,
which is about using Python as an embedded interpreter, not compiling
it. Embedding Python assumes it has already been built.
msg148725 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-12-01 14:14
I did a review on Rietveld.
msg150740 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-01-06 16:43
Attached patch adds the useful bits from the review I did; I hope you won’t think it’s pointless nitpicking.
msg150746 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-01-06 16:55
> Attached patch adds the useful bits from the review I did; I hope you
> won’t think it’s pointless nitpicking.

Looks good to me.
msg152687 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-02-05 12:50
New changeset 79e8de78abd0 by Éric Araujo in branch '3.2':
Markup improvements for the embedding CPython doc patch from #1040439
http://hg.python.org/cpython/rev/79e8de78abd0

New changeset 1cb9b8126534 by Éric Araujo in branch 'default':
Merge edits from 3.2 (#13716, #1040439, #2945, #13770, #6715)
http://hg.python.org/cpython/rev/1cb9b8126534
msg152741 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-06 15:51
Is there still work to do on this issue?
msg152742 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-02-06 16:20
> Is there still work to do on this issue?

Not for Unix, no. I don't if it's applicable to Windows.
msg152928 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012-02-09 04:32
ISTM that part of the doc specifically deals with Unix, so this issue can be closed as completed.

Windows is a different issue. Perhaps the documentation should have a new section on embedding on Windows, similarly to the "Building C and C++ Extensions on Windows" section in the "extending" documentation. Anyway, if there's interest in that, it should be a separate issue.
msg154300 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-26 02:49
Is there any reason not to backport to 2.7?  (Yes, I’m volunteering.)
msg154905 - (view) Author: Eli Bendersky (eli.bendersky) * (Python committer) Date: 2012-03-04 19:09
Éric, go ahead :)
msg191812 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2013-06-24 21:35
I've now backported the 3.x update to the 2.7 docs in Issue18164 (I hadn't noticed that this issue was still open).  As Eli noted, if any updates are needed to cover Windows, a separate issue should be opened. I'm closing this one.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 40984
2013-06-24 21:35:58ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg191812

resolution: fixed
stage: patch review -> resolved
2012-06-08 12:38:10eli.benderskysetnosy: - eli.bendersky
2012-03-04 19:09:06eli.benderskysetmessages: + msg154905
2012-02-26 02:49:55eric.araujosetmessages: + msg154300
2012-02-09 04:32:56eli.benderskysetmessages: + msg152928
2012-02-06 16:20:58pitrousetmessages: + msg152742
2012-02-06 15:51:32eric.araujosetmessages: + msg152741
2012-02-05 12:50:14python-devsetmessages: + msg152687
2012-01-06 16:55:01pitrousetmessages: + msg150746
2012-01-06 16:43:11eric.araujosetfiles: + docembed-edits.patch

messages: + msg150740
2011-12-01 14:14:31eric.araujosetmessages: + msg148725
2011-11-30 20:48:00pitrousetmessages: + msg148686
2011-11-30 20:38:58rpqsetnosy: + rpq
messages: + msg148685
2011-11-30 20:25:11python-devsetnosy: + python-dev
messages: + msg148684
2011-11-29 18:29:43eli.benderskysetmessages: + msg148591
2011-11-29 18:16:31pitrousetfiles: - docembed.patch
2011-11-29 18:16:20pitrousetfiles: + docembed.patch

messages: + msg148590
2011-11-29 18:04:13pitrousetfiles: + docembed.patch
keywords: + patch
messages: + msg148589

stage: needs patch -> patch review
2011-11-29 17:37:48pitrousetnosy: + pitrou
messages: + msg148587
2011-11-29 14:44:29eli.benderskysetmessages: + msg148573
2011-11-29 14:05:05eric.araujosetnosy: + eric.araujo

messages: + msg148568
title: Missing documentation on How To Link With libpython -> Missing documentation on how to link with libpython
2011-11-29 07:30:32eli.benderskysetnosy: + eli.bendersky
2011-11-29 06:32:39ezio.melottisetnosy: - BreamoreBoy
stage: needs patch

versions: + Python 2.7, Python 3.3
2010-07-09 14:15:05BreamoreBoysetversions: + Python 3.2, - Python 2.6
nosy: + docs@python, BreamoreBoy

messages: + msg109742

assignee: docs@python
2009-02-14 18:21:41ajaksu2setversions: + Python 2.6
2004-10-05 06:51:11raorncreate