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
#
# Usage: pyenv install [-f|--force] [-k|--keep] [-v|--verbose] <version>
# pyenv install [-f|--force] [-k|--keep] [-v|--verbose] <definition-file>
# Usage: pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <version>
# pyenv install [-f|--force] [-g|--debug] [-k|--keep] [-v|--verbose] <definition-file>
# 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

View file

@ -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 "$@"
@ -586,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"
@ -603,6 +605,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" )
VERBOSE=true
;;
"g" | "debug" )
DEBUG=true
;;
"version" )
version
exit 0
@ -661,6 +666,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"