From ded98e11dedab027b5e82105c3fd3f53731fe53a Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 18 Oct 2014 22:58:45 +0900 Subject: [PATCH 1/5] Allow users to change the name of `install` target (#255) --- plugins/python-build/bin/python-build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index e388f4e2..c7c1d20e 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -599,6 +599,7 @@ build_package_standard() { local PACKAGE_MAKE_OPTS_ARRAY="${package_var_name}_MAKE_OPTS_ARRAY[@]" local PACKAGE_MAKE_INSTALL_OPTS="${package_var_name}_MAKE_INSTALL_OPTS" local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]" + local PACKAGE_MAKE_INSTALL_TARGET="${package_var_name}_MAKE_INSTALL_TARGET" local PACKAGE_CFLAGS="${package_var_name}_CFLAGS" [ "$package_var_name" = "PYTHON" ] && use_homebrew_readline || true @@ -612,7 +613,7 @@ build_package_standard() { ) >&4 2>&1 { "$MAKE" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} "${!PACKAGE_MAKE_OPTS_ARRAY}" - "$MAKE" install $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}" + "$MAKE" "${!PACKAGE_MAKE_INSTALL_TARGET:-install}" $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}" } >&4 2>&1 } From 45b45bcf255adc6bbbc64ec9487e4b477d1359ad Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sat, 18 Oct 2014 23:56:51 +0900 Subject: [PATCH 2/5] Pass `--altinstall` to `ensurepip` (#255) --- plugins/python-build/bin/python-build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index c7c1d20e..c9cc5080 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1443,7 +1443,11 @@ build_package_get_pip() { } build_package_ensurepip() { - "$PYTHON_BIN" -m ensurepip 1>/dev/null 2>&1 || { + local ensurepip_opts + if [[ "$PYTHON_MAKE_INSTALL_TARGET" != *"altinstall"* ]]; then + ensurepip_opts="--altinstall" + fi + "$PYTHON_BIN" -m ensurepip $ensurepip_opts 1>/dev/null 2>&1 || { build_package_ez_setup "$@" && build_package_get_pip "$@" } || return 1 From eef8ac2701497947e3031d81e8a3033f607e8593 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sun, 19 Oct 2014 00:13:49 +0900 Subject: [PATCH 3/5] Use version suffixed executable (e.g. `python3.4`) for internal use of python (#255) --- plugins/python-build/bin/python-build | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index c9cc5080..8f45f894 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1687,9 +1687,25 @@ if [[ "Darwin" == "$(uname -s)" ]]; then fi fi +python_bin_suffix() { + local version_name version_info + case "$1" in + 2.* | 3.* ) + version_name="$1" + version_info=(${version_name//./ }) + echo "${version_info[0]}.${version_info[1]}" + ;; + stackless-2.* | stackless-3.* ) + version_name="${1#stackless-}" + version_info=(${version_name//./ }) + echo "${version_info[0]}.${version_info[1]}" + ;; + esac +} + SEED="$(date "+%Y%m%d%H%M%S").$$" LOG_PATH="${TMP}/python-build.${SEED}.log" -PYTHON_BIN="${PREFIX_PATH}/bin/python" +PYTHON_BIN="${PREFIX_PATH}/bin/python$(python_bin_suffix "${DEFINITION_PATH##*/}")" CWD="$(pwd)" if [ -z "$PYTHON_BUILD_BUILD_PATH" ]; then From d9e772eb6ed4afa99563e82756f02a40f6c112c9 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sun, 19 Oct 2014 00:34:20 +0900 Subject: [PATCH 4/5] Stop creating symlinks w/ version suffix if `altinstall` has specified (#182, #255) --- plugins/python-build/bin/python-build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 8f45f894..dd918c2f 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1282,7 +1282,9 @@ verify_python() { ln -fs "${PREFIX_PATH}/Python.framework/Versions/Current/bin" "${PREFIX_PATH}/bin" fi - create_symlinks "$1" + if [[ "$PYTHON_MAKE_INSTALL_TARGET" != *"altinstall"* ]]; then + create_symlinks "$1" + fi if [ ! -x "${PYTHON_BIN}" ]; then { colorize 1 "ERROR" From b2ac5df98d5199534ddf6fc005481463db184430 Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Sun, 19 Oct 2014 10:44:38 +0900 Subject: [PATCH 5/5] Calling `create_symlinks` after `ensurepip` is unnecessary (#182, #255) Install script of setuptools-6.1/pip-1.5.6 will create those links if needed --- plugins/python-build/bin/python-build | 38 +++++++++++---------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index dd918c2f..78816b2a 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -1255,26 +1255,6 @@ apply_python_patch() { esac } -create_symlinks() { - local suffix="$1" - - local file link - shopt -s nullglob - for file in "${PREFIX_PATH}/bin"/*; do - if [[ "${file##*/}" == *"${suffix}" ]]; then - if [[ "${file}" == *"-${suffix}" ]]; then - link="${file%%-${suffix}}" - else - link="${file%%${suffix}}" - fi - if [ ! -e "${link}" ]; then - ( cd "${file%/*}" && ln -fs "${file##*/}" "${link##*/}" ) - fi - fi - done - shopt -u nullglob -} - verify_python() { if [[ "$PYTHON_CONFIGURE_OPTS" == *"--enable-framework"* ]]; then # Only symlinks are installed in ${PREFIX_PATH}/bin @@ -1282,8 +1262,22 @@ verify_python() { ln -fs "${PREFIX_PATH}/Python.framework/Versions/Current/bin" "${PREFIX_PATH}/bin" fi + # Not create symlinks on `altinstall` (#255) if [[ "$PYTHON_MAKE_INSTALL_TARGET" != *"altinstall"* ]]; then - create_symlinks "$1" + local suffix="${1#python}" + local file + shopt -s nullglob + for file in "${PREFIX_PATH}/bin"/*; do + local link + case "${file}" in + *"-${suffix}" ) link="${file%%-${suffix}}" ;; + *"${suffix}" ) link="${file%%${suffix}}" ;; + esac + if [ -n "$link" ] && [ ! -e "$link" ]; then + ( cd "${file%/*}" && ln -fs "${file##*/}" "${link##*/}" ) + fi + done + shopt -u nullglob fi if [ ! -x "${PYTHON_BIN}" ]; then @@ -1452,8 +1446,6 @@ build_package_ensurepip() { "$PYTHON_BIN" -m ensurepip $ensurepip_opts 1>/dev/null 2>&1 || { build_package_ez_setup "$@" && build_package_get_pip "$@" } || return 1 - - create_symlinks "$("$PYTHON_BIN" -c 'import sys;v=sys.version_info;sys.stdout.write("python%d.%d"%(v[0],v[1]))')" } version() {