Merge pull request #11 from draftcode/build-pydebug

Add an option to build a debug version of Python
This commit is contained in:
Yamashita, Yuu 2013-03-28 00:53:08 -07:00
commit 6e58c43d8a
2 changed files with 19 additions and 4 deletions

View File

@ -2,12 +2,13 @@
# #
# Summary: Install a Python version using the python-build plugin # Summary: Install a Python version using the python-build plugin
# #
# Usage: pyenv install [-f|--force] [-k|--keep] [-v|--verbose] <version> # Usage: pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <version>
# pyenv install [-f|--force] [-k|--keep] [-v|--verbose] <definition-file> # pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <definition-file>
# pyenv install -l|--list # pyenv install -l|--list
# #
# -l/--list List all available versions # -l/--list List all available versions
# -f/--force Install even if the version appears to be installed already # -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 # -k/--keep Keep source tree in $PYENV_BUILD_ROOT after installation
# (defaults to $PYENV_ROOT/sources) # (defaults to $PYENV_ROOT/sources)
# -v/--verbose Verbose mode: print compilation status to stdout # -v/--verbose Verbose mode: print compilation status to stdout
@ -40,6 +41,7 @@ usage() {
unset FORCE unset FORCE
unset KEEP unset KEEP
unset VERBOSE unset VERBOSE
unset DEBUG
parse_options "$@" parse_options "$@"
for option in "${OPTIONS[@]}"; do for option in "${OPTIONS[@]}"; do
@ -61,6 +63,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" ) "v" | "verbose" )
VERBOSE="-v" VERBOSE="-v"
;; ;;
"g" | "debug" )
DEBUG="-g"
;;
"version" ) "version" )
exec python-build --version exec python-build --version
;; ;;
@ -105,6 +110,7 @@ done
# Set VERSION_NAME from $DEFINITION, if it is not already set. Then # Set VERSION_NAME from $DEFINITION, if it is not already set. Then
# compute the installation prefix. # compute the installation prefix.
[ -n "$VERSION_NAME" ] || VERSION_NAME="${DEFINITION##*/}" [ -n "$VERSION_NAME" ] || VERSION_NAME="${DEFINITION##*/}"
[ -n "$DEBUG" ] && VERSION_NAME="${VERSION_NAME}-debug"
PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}" PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
# If the installation prefix exists, prompt for confirmation unless # 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 # Invoke `python-build` and record the exit status in $STATUS. Run
# `pyenv rehash` after a successful installation. # `pyenv rehash` after a successful installation.
STATUS=0 STATUS=0
python-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?" python-build $KEEP $VERBOSE $DEBUG "$DEFINITION" "$PREFIX" || STATUS="$?"
# Execute `after_install` hooks. # Execute `after_install` hooks.
for hook in "${after_hooks[@]}"; do eval "$hook"; done for hook in "${after_hooks[@]}"; do eval "$hook"; done

View File

@ -557,7 +557,7 @@ version() {
usage() { usage() {
{ version { 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" echo " python-build --definitions"
} >&2 } >&2
@ -577,6 +577,7 @@ list_definitions() {
unset VERBOSE unset VERBOSE
unset KEEP_BUILD_PATH unset KEEP_BUILD_PATH
unset DEBUG
PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.." PYTHON_BUILD_ROOT="$(abs_dirname "$0")/.."
parse_options "$@" parse_options "$@"
@ -586,6 +587,7 @@ for option in "${OPTIONS[@]}"; do
"h" | "help" ) "h" | "help" )
usage without_exiting usage without_exiting
{ echo { echo
echo " -g/--debug Build a debug version"
echo " -k/--keep Do not remove source tree after installation" echo " -k/--keep Do not remove source tree after installation"
echo " -v/--verbose Verbose mode: print compilation status to stdout" echo " -v/--verbose Verbose mode: print compilation status to stdout"
echo " --definitions List all built-in definitions" echo " --definitions List all built-in definitions"
@ -603,6 +605,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" ) "v" | "verbose" )
VERBOSE=true VERBOSE=true
;; ;;
"g" | "debug" )
DEBUG=true
;;
"version" ) "version" )
version version
exit 0 exit 0
@ -661,6 +666,10 @@ else
unset PYTHON_BUILD_MIRROR_URL unset PYTHON_BUILD_MIRROR_URL
fi fi
if [ -n "$DEBUG" ]; then
CONFIGURE_OPTS+=" --with-pydebug"
fi
SEED="$(date "+%Y%m%d%H%M%S").$$" SEED="$(date "+%Y%m%d%H%M%S").$$"
LOG_PATH="${TMP}/python-build.${SEED}.log" LOG_PATH="${TMP}/python-build.${SEED}.log"
PYTHON_BIN="${PREFIX_PATH}/bin/python" PYTHON_BIN="${PREFIX_PATH}/bin/python"