From d6cbc9cc388c44b58d69db6e731dda30d66f80a5 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 3 May 2023 17:41:28 -0400 Subject: [PATCH] python3: mark as EXTERNALLY-MANAGED this prevents users from breaking xbps-installed python3 packages by using pip outside of a virtual environment. Error message adapted from gentoo's, debian's, and the example from PEP 668 see https://peps.python.org/pep-0668/ for more details closes #43703 --- srcpkgs/python3/files/EXTERNALLY-MANAGED | 21 +++++++++++++++++++++ srcpkgs/python3/template | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/python3/files/EXTERNALLY-MANAGED diff --git a/srcpkgs/python3/files/EXTERNALLY-MANAGED b/srcpkgs/python3/files/EXTERNALLY-MANAGED new file mode 100644 index 000000000000..507c9e917628 --- /dev/null +++ b/srcpkgs/python3/files/EXTERNALLY-MANAGED @@ -0,0 +1,21 @@ +[externally-managed] +Error= + The system-wide Python installation in Void should be maintained + using the system package manager, xbps. + + If the package in question is not packaged for Void, please + consider installing it inside a virtual environment, e.g.: + + python3 -m venv /path/to/venv + . /path/to/venv/bin/activate + pip install mypackage + + To exit the virtual environment, run: + + deactivate + + The virtual environment is not deleted, and can be re-entered by + re-sourcing the activate file. + + To automatically manage virtual environments, pipx (from python3-pipx) + can be used. diff --git a/srcpkgs/python3/template b/srcpkgs/python3/template index aebf41852764..45852a17bcc6 100644 --- a/srcpkgs/python3/template +++ b/srcpkgs/python3/template @@ -4,7 +4,7 @@ # pkgname=python3 version=3.11.3 -revision=1 +revision=2 build_style="gnu-configure" configure_args="--enable-shared --enable-ipv6 --enable-loadable-sqlite-extensions --with-computed-gotos @@ -135,6 +135,9 @@ do_install() { ${DESTDIR}/usr/bin/python${version%.*}-config \ ${DESTDIR}/usr/lib/python${version%.*}/_sysconfigdata_*_*.py \ ${DESTDIR}/usr/lib/python${version%.*}/config-${version%.*}*/Makefile + + # https://peps.python.org/pep-0668/ + vinstall ${FILESDIR}/EXTERNALLY-MANAGED 644 usr/lib/python${version%.*} } python3-devel_package() {