Gentoo Archives: gentoo-python

From: "Michał Górny" <mgorny@g.o>
To: gentoo-python@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-python] [PATCH 3/4] Stop creating symlinks to interpreters and the wrapper
Date: Sun, 15 Nov 2015 09:39:31
Message-Id: 1447580355-16777-4-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-python] [eselect-python] Patches to switch to full python-exec wrapping by "Michał Górny"
1 ---
2 python.eselect.in | 60 ++++++++++---------------------------------------------
3 1 file changed, 11 insertions(+), 49 deletions(-)
4
5 diff --git a/python.eselect.in b/python.eselect.in
6 index 32d9cbf..3d9b4bc 100644
7 --- a/python.eselect.in
8 +++ b/python.eselect.in
9 @@ -2,7 +2,7 @@
10 # Distributed under the terms of the GNU General Public License v2
11 # $Id: $
12
13 -DESCRIPTION="Manage Python symlinks"
14 +DESCRIPTION="Manage active Python interpreter"
15 MAINTAINER="python@g.o"
16 SVN_DATE='$Date$'
17 VERSION=$(svn_date_to_version "${SVN_DATE}" )
18 @@ -41,44 +41,18 @@ set_python_subver() {
19 }
20
21 set_python() {
22 - local symlink="${INTERPRETER_PATH}python" target="${1}"
23 - ln -s python-wrapper "${symlink}"
24 + local target="${1}"
25 mkdir -p "${ENV_D_PATH}/python"
26 echo "${target}" > "${ENV_D_PATH}/python/config"
27 }
28
29 -set_python_config() {
30 - local script="${INTERPRETER_PATH}python-config" target="${1}"
31 - cat << EOF > "${script}"
32 -#!/usr/bin/env bash
33 -# Gentoo python-config wrapper script
34 -
35 -[[ "\${EPYTHON}" =~ (/|^python\$) ]] && EPYTHON="${target/-config-/}"
36 -python_config="\${EPYTHON/python/python-config-}"
37 -"\${0%/*}/\${python_config:-${target}}" "\$@"
38 -EOF
39 - chmod a+rx "${script}"
40 -}
41 -
42 # Try to remove python and python.1 symlinks
43 remove_symlinks() {
44 local symlink symlink_target symlink_target_found
45 if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
46 - rm -f "${INTERPRETER_PATH}"{idle,pydoc,python,python-config,pythonw} &> /dev/null || return 1
47 rm -f "${MAN_PATH}"python.1{,.gz,.bz2,.lzma,.xz,.lz} &> /dev/null || return 1
48 fi
49
50 - for symlink in "${INTERPRETER_PATH}python"?; do
51 - [[ ! -L "${symlink}" ]] && continue
52 - symlink_target_found=0
53 - for symlink_target in "${symlink}".?; do
54 - [[ -f "${symlink_target}" ]] && symlink_target_found=1
55 - done
56 - if [[ "${symlink_target_found}" -eq 0 ]]; then
57 - rm -f "${symlink}"
58 - fi
59 - done
60 -
61 # Files of Mac OS X framework
62 rm -f "${INTERPRETER_PATH%/bin/}/lib/Python.framework}"/{Headers,Python,Resources}
63 }
64 @@ -125,25 +99,9 @@ set_scripts_and_symlinks() {
65
66 pushd "${INTERPRETER_PATH}" 1> /dev/null
67
68 - ln -nfs "${target}" "${target%.*}"
69 set_python_subver "${target}"
70 if [[ "${SET_MAIN_ACTIVE_PYTHON_INTERPRETER}" == "1" ]]; then
71 set_python "${target}"
72 - set_python_config "${target/python/python-config-}"
73 - ln -nfs "${target/python/pydoc}" pydoc
74 - # idle is optionally installed
75 - if [[ -f "${target/python/idle}" ]]; then
76 - ln -nfs "${target/python/idle}" idle
77 - fi
78 - # 2to3 for >=2.6
79 - if [[ -f "${target/python/2to3-}" ]]; then
80 - ln -nfs "${target/python/2to3-}" 2to3
81 - fi
82 -
83 - # Wrapper for graphical applications on Mac OS X
84 - if [[ -f "${target/python/pythonw}" ]] ; then
85 - ln -nfs "${target/python/pythonw}" pythonw
86 - fi
87
88 # Files of Mac OS X framework
89 local framework_dir="${INTERPRETER_PATH%/bin/}/lib/Python.framework"
90 @@ -213,9 +171,13 @@ do_show() {
91 fi
92
93 if [[ "${python2}" == "1" ]]; then
94 - interpreter="$(<"${ENV_D_PATH}/python/python2")"
95 + if [[ -f ${ENV_D_PATH}/python/python2 ]]; then
96 + interpreter="$(<"${ENV_D_PATH}/python/python2")"
97 + fi
98 elif [[ "${python3}" == "1" ]]; then
99 - interpreter="$(<"${ENV_D_PATH}/python/python3")"
100 + if [[ -f ${ENV_D_PATH}/python/python3 ]]; then
101 + interpreter="$(<"${ENV_D_PATH}/python/python3")"
102 + fi
103 elif [[ -f "${ENV_D_PATH}/python/config" ]]; then
104 interpreter="$(<"${ENV_D_PATH}/python/config")"
105 fi
106 @@ -385,10 +347,10 @@ do_update() {
107 die -q "'--python2' and '--python3' options cannot be specified simultaneously"
108 fi
109
110 - if [[ "${if_unset}" == "1" && -f "${INTERPRETER_PATH}python" && -f "${ENV_D_PATH}/python/config" ]]; then
111 - if [[ "${python2}" == "1" && -f "${INTERPRETER_PATH}python2" ]]; then
112 + if [[ "${if_unset}" == "1" && -f "${ENV_D_PATH}/python/config" ]]; then
113 + if [[ "${python2}" == "1" && -f "${ENV_D_PATH}/python/python2" ]]; then
114 return
115 - elif [[ "${python3}" == "1" && -f "${INTERPRETER_PATH}python3" ]]; then
116 + elif [[ "${python3}" == "1" && -f "${ENV_D_PATH}/python/python3" ]]; then
117 return
118 elif [[ "${python2}" == "0" && "${python3}" == "0" ]]; then
119 return
120 --
121 2.6.3