From 8bf0938e604d1581b02cf1378353e1792d7183a5 Mon Sep 17 00:00:00 2001 From: draftcode Date: Thu, 28 Mar 2013 12:04:58 +0900 Subject: [PATCH 1/3] Add an option to build a debug version of Python --- plugins/python-build/bin/pyenv-install | 12 +++++++++--- plugins/python-build/bin/python-build | 10 +++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/python-build/bin/pyenv-install b/plugins/python-build/bin/pyenv-install index bbf719f3..21b8f6cd 100755 --- a/plugins/python-build/bin/pyenv-install +++ b/plugins/python-build/bin/pyenv-install @@ -2,12 +2,13 @@ # # Summary: Install a Python version using the python-build plugin # -# Usage: pyenv install [-f|--force] [-k|--keep] [-v|--verbose] -# pyenv install [-f|--force] [-k|--keep] [-v|--verbose] +# Usage: pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] +# pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] # pyenv install -l|--list # # -l/--list List all available versions # -f/--force Install even if the version appears to be installed already +# -g/--debug Build a debug version # -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation # (defaults to $PYENV_ROOT/sources) # -v/--verbose Verbose mode: print compilation status to stdout @@ -40,6 +41,7 @@ usage() { unset FORCE unset KEEP unset VERBOSE +unset DEBUG parse_options "$@" for option in "${OPTIONS[@]}"; do @@ -61,6 +63,9 @@ for option in "${OPTIONS[@]}"; do "v" | "verbose" ) VERBOSE="-v" ;; + "g" | "debug" ) + DEBUG="-g" + ;; "version" ) exec python-build --version ;; @@ -105,6 +110,7 @@ done # Set VERSION_NAME from $DEFINITION, if it is not already set. Then # compute the installation prefix. [ -n "$VERSION_NAME" ] || VERSION_NAME="${DEFINITION##*/}" +[ -n "$DEBUG" ] && VERSION_NAME="${VERSION_NAME}-debug" PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}" # If the installation prefix exists, prompt for confirmation unless @@ -138,7 +144,7 @@ for hook in "${before_hooks[@]}"; do eval "$hook"; done # Invoke `python-build` and record the exit status in $STATUS. Run # `pyenv rehash` after a successful installation. STATUS=0 -python-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?" +python-build $KEEP $VERBOSE $DEBUG "$DEFINITION" "$PREFIX" || STATUS="$?" # Execute `after_install` hooks. for hook in "${after_hooks[@]}"; do eval "$hook"; done diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index cad61cea..b638e696 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -557,7 +557,7 @@ version() { usage() { { version - echo "usage: python-build [-k|--keep] [-v|--verbose] definition prefix" + echo "usage: python-build [-g|--debug] [-k|--keep] [-v|--verbose] definition prefix" echo " python-build --definitions" } >&2 @@ -577,6 +577,7 @@ list_definitions() { unset VERBOSE unset KEEP_BUILD_PATH +unset DEBUG PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.." parse_options "$@" @@ -603,6 +604,9 @@ for option in "${OPTIONS[@]}"; do "v" | "verbose" ) VERBOSE=true ;; + "g" | "debug" ) + DEBUG=true + ;; "version" ) version exit 0 @@ -661,6 +665,10 @@ else unset PYTHON_BUILD_MIRROR_URL fi +if [ -n "$DEBUG" ]; then + CONFIGURE_OPTS="--with-pydebug" +fi + SEED="$(date "+%Y%m%d%H%M%S").$$" LOG_PATH="${TMP}/python-build.${SEED}.log" PYTHON_BIN="${PREFIX_PATH}/bin/python" From c170255580561f1f68cc9f4502595f8547829ee4 Mon Sep 17 00:00:00 2001 From: draftcode Date: Thu, 28 Mar 2013 16:35:26 +0900 Subject: [PATCH 2/3] Preserve CONFIGURE_OPTS --- plugins/python-build/bin/python-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index b638e696..9b01dc25 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -666,7 +666,7 @@ else fi if [ -n "$DEBUG" ]; then - CONFIGURE_OPTS="--with-pydebug" + CONFIGURE_OPTS+=" --with-pydebug" fi SEED="$(date "+%Y%m%d%H%M%S").$$" From dce4eb636a20a5e28f8936f58ca7c0e69a0b0bb8 Mon Sep 17 00:00:00 2001 From: draftcode Date: Thu, 28 Mar 2013 16:41:07 +0900 Subject: [PATCH 3/3] Add a help string to describe the debug option --- plugins/python-build/bin/python-build | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/python-build/bin/python-build b/plugins/python-build/bin/python-build index 9b01dc25..d1cb22f1 100755 --- a/plugins/python-build/bin/python-build +++ b/plugins/python-build/bin/python-build @@ -587,6 +587,7 @@ for option in "${OPTIONS[@]}"; do "h" | "help" ) usage without_exiting { echo + echo " -g/--debug Build a debug version" echo " -k/--keep Do not remove source tree after installation" echo " -v/--verbose Verbose mode: print compilation status to stdout" echo " --definitions List all built-in definitions"