Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The heart is not a logical organ. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4


devel / comp.lang.python / Re: [Help Request] Embedding Python in a CPP Application Responsibly & Functionally

SubjectAuthor
o Re: [Help Request] Embedding Python in a CPP Application Responsibly &Dieter Maurer

1
Re: [Help Request] Embedding Python in a CPP Application Responsibly & Functionally

<mailman.1631.1674720588.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25755&group=comp.lang.python#25755

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: dieter@handshake.de (Dieter Maurer)
Newsgroups: comp.lang.python
Subject: Re: [Help Request] Embedding Python in a CPP Application Responsibly &
Functionally
Date: Thu, 26 Jan 2023 08:50:51 +0100
Lines: 53
Message-ID: <mailman.1631.1674720588.20444.python-list@python.org>
References: <943ae183-6b26-4430-50d4-71fcbdb5c13a@gmail.com>
<25554.12507.902369.225551@ixdm.fritz.box>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de hOVReiRHsZW8DpV4pVKFrgY7beFO8+hRpaNGb1azCSLg==
Return-Path: <dieter@handshake.de>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.016
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'exit': 0.07; 'avoided':
0.09; 'cc:addr:python-list': 0.09; 'environment,': 0.09;
'libraries:': 0.09; 'skip:` 10': 0.09; 'subject:Python': 0.12;
'cc:no real name:2**0': 0.14; 'import': 0.15; 'c++': 0.16;
'compiled': 0.16; 'directly,': 0.16; 'interpreter': 0.16; 'skip:.
20': 0.16; 'skip:> 10': 0.16; 'skip:> 20': 0.16;
'subject:Application': 0.16; 'python': 0.16; 'subject:Help': 0.17;
'libraries': 0.19; 'cc:addr:python.org': 0.20; 'option': 0.20;
'subject:: [': 0.21; 'subject:] ': 0.21; 'application.': 0.22;
'command': 0.23; 'run': 0.23; 'received:de': 0.23; 'python,':
0.25; 'cannot': 0.25; 'cc:2**0': 0.25; 'binary': 0.26; 'library':
0.26; 'creating': 0.27; '>>>': 0.28; 'error': 0.29; 'seem': 0.31;
'program': 0.31; 'think': 0.32; "doesn't": 0.32; 'objects': 0.32;
'but': 0.32; "i'm": 0.33; 'there': 0.33; 'path': 0.33; 'same':
0.34; 'header:In-Reply-To:1': 0.34; 'running': 0.34; 'trying':
0.35; 'final': 0.35; 'errors': 0.36; "skip:' 10": 0.37; 'file':
0.38; 'way': 0.38; 'could': 0.38; 'put': 0.38; 'error,': 0.38;
'read': 0.38; 'mentioned': 0.39; 'subject:Request': 0.39;
'shared': 0.39; 'wrote': 0.39; 'file:': 0.40; 'place.': 0.40;
'want': 0.40; 'try': 0.40; 'should': 0.40; 'tell': 0.60;
'provide': 0.60; 'above': 0.62; 'generation': 0.62; 'involved':
0.63; 'your': 0.64; 'independent': 0.65; 'header:Received:6':
0.67; 'manually': 0.69; 'virtual': 0.71; 'linking': 0.76;
'returned': 0.81; 'again:': 0.84; 'received:88': 0.84;
'dependent': 0.93; 'seemingly': 0.93
In-Reply-To: <943ae183-6b26-4430-50d4-71fcbdb5c13a@gmail.com>
X-Mailer: VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid
(x86_64-linux-gnu)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <25554.12507.902369.225551@ixdm.fritz.box>
X-Mailman-Original-References: <943ae183-6b26-4430-50d4-71fcbdb5c13a@gmail.com>
 by: Dieter Maurer - Thu, 26 Jan 2023 07:50 UTC

John McCardle wrote at 2023-1-25 22:31 -0500:
> ...
>1) To get the compiled Python to run independently, I have to hack
>LD_LIBRARY_PATH to get it to execute. `LD_LIBRARY_PATH=./Python-3.11.1
>./Python-3.11.1/python` .

The need to set `LD_LIBRARY_PATH` usually can be avoided via
a link time option: it tells the linker to add library path
information into the created shared object.

Read the docs to find out which option this is (I think it
was `-r` but I am not sure).

>Even when trying to execute from the same
>directory as the binary & executable, I get an error, `/python: error
>while loading shared libraries: libpython3.11.so.1.0: cannot open shared
>object file: No such file or directory`.

It might be necessary, to provide the option mentioned above
for all shared libraries involved in your final application.

Alternatively, you could try to put the shared objects
into a stadard place (searched by default).

>2) When running the C++ program that embeds Python, I see these messages
>after initializing:
>`Could not find platform independent libraries <prefix>
>Could not find platform dependent libraries <exec_prefix>`

Again: either put your installation in a standard place
or tell the Python generation process about your non-standard place.

>This is seemingly connected to some issues regarding libraries: When I
>run the Python interpreter directly, I can get some of the way through
>the process of creating a virtual environment, but it doesn't seem to
>leave me with a working pip:
>
>`$ LD_LIBRARY_PATH=./Python-3.11.1 ./Python-3.11.1/python
> >>> import venv
> >>> venv.create("./venv", with_pip=True)
>subprocess.CalledProcessError: Command
>'['/home/john/Development/7DRL/cpp_embedded_python/venv/bin/python',
>'-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit
>status 127.`

Run the command manually and see what errors this gives.

> ...

>3) I'm not sure I even need to be statically linking the interpreter.

There should be no need (if all you want in the embedding).


devel / comp.lang.python / Re: [Help Request] Embedding Python in a CPP Application Responsibly & Functionally

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor