From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/util/, /
Date: Wed, 2 Aug 2023 06:31:24 +0000 (UTC) [thread overview]
Message-ID: <1690957880.19c27a2471c78d5e17b14325477fee60ead791e5.sam@gentoo> (raw)
commit: 19c27a2471c78d5e17b14325477fee60ead791e5
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 30 13:19:10 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Aug 2 06:31:20 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=19c27a24
Use the correct library path when launching scripts directly from a venv
It's not clear what bin_entry_point.sh was trying to do before. The
regular expression didn't appear to match any likely shebang. The
wrapper already runs under the desired Python, so we only need to use
sys.executable, which points to the venv's python symlink.
We don't need to worry about handling non-Python scripts any more either
as the new Meson-based build system just installs these directly to bin
rather than creating an entrypoint for them. Any Python-based Portage
scripts they execute are now tried from the same directory first and
will therefore use the correct environment, as above.
Signed-off-by: James Le Cuirot <chewi <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>
NEWS | 3 +++
lib/portage/util/bin_entry_point.py | 18 +++++-------------
2 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/NEWS b/NEWS
index 0e3541af4..53db165e8 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,9 @@ Bug fixes:
* Ensure non-Python (s)bin scripts launch other Python-based Portage scripts
using the same environment.
+* Use the correct Python library path when launching scripts directly from a
+ virtual environment.
+
portage-3.0.49 (2023-06-21)
--------------
diff --git a/lib/portage/util/bin_entry_point.py b/lib/portage/util/bin_entry_point.py
index bb012b6b7..efa8b17b7 100644
--- a/lib/portage/util/bin_entry_point.py
+++ b/lib/portage/util/bin_entry_point.py
@@ -1,9 +1,8 @@
-# Copyright 2021 Gentoo Authors
+# Copyright 2021-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
__all__ = ["bin_entry_point"]
-import re
import sys
from portage.const import PORTAGE_BIN_PATH
@@ -18,17 +17,10 @@ def bin_entry_point():
"""
script_path = os.path.join(PORTAGE_BIN_PATH, os.path.basename(sys.argv[0]))
if os.access(script_path, os.X_OK):
- with open(script_path) as f:
- shebang = f.readline()
- python_match = re.search(r"/python[\d\.]*\s+([^/]*)\s+$", shebang)
- if python_match:
- sys.argv = [
- os.path.join(os.path.dirname(sys.argv[0]), "python"),
- python_match.group(1),
- script_path,
- ] + sys.argv[1:]
- os.execvp(sys.argv[0], sys.argv)
- sys.argv[0] = script_path
+ sys.argv = [
+ sys.executable,
+ script_path,
+ ] + sys.argv[1:]
os.execvp(sys.argv[0], sys.argv)
else:
print("File not found:", script_path, file=sys.stderr)
next reply other threads:[~2023-08-02 6:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 6:31 Sam James [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-10-02 21:40 [gentoo-commits] proj/portage:master commit in: lib/portage/util/, / James Le Cuirot
2023-07-26 7:58 Sam James
2022-11-30 22:29 Sam James
2021-02-28 10:10 Zac Medico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1690957880.19c27a2471c78d5e17b14325477fee60ead791e5.sam@gentoo \
--to=sam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox