Source

benchmarks / make_perf3.sh

Full commit
#! /usr/bin/env bash
#
# NOTE: most benchmarks are natively Python 3-compatible and don't need
# to be translated.  Simply run perf.py with `-b 2n3` to run them.
#
# Usage:
#   hg clone http://hg.python.org/benchmarks/ py2benchmarks
#   mkdir py3benchmarks;
#   cd py3benchmarks
#   ../py2benchmarks/make_perf3.sh ../py2benchmarks
#   python3.1 perf.py -b py3k old_py3k new_py3k

set -e

srcdir=$(cd "$1" && pwd -P)

if [ "x$srcdir" = x ]; then
    echo "Specify the source directory as the first argument."
    exit 1
fi
if [ "$srcdir" = $(pwd -P) ]; then
    echo "Can't generate python 3 into the same directory as python 2 version."
    exit 1
fi

py2_6=${PYTHON:-python2.6}

# Update the files in place.
CONVERT="${py2_6} ${srcdir}/lib/2to3/2to3 --write --nobackups --no-diffs"

rm -rf perf.py* lib performance

cp "${srcdir}/perf.py" perf.py
${CONVERT} perf.py

# Libraries that are Python 3 compatible as-is.
SAFE_LIBS_AS_IS="Chameleon-2.9.2 pathlib"
# Libraries that work with Python 3 after passing through 2to3.
SAFE_LIBS_TO_TRANSLATE="2to3 mako-0.3.6 Mako-0.7.3"
# Libraries whose source is Python 3 only.
SAFE_LIBS_PORTED=""

mkdir lib
for safe_lib in ${SAFE_LIBS_AS_IS}; do
  cp -a "${srcdir}/lib/${safe_lib}" lib/${safe_lib}
done

for safe_lib in ${SAFE_LIBS_TO_TRANSLATE}; do
  cp -a "${srcdir}/lib/${safe_lib}" lib/${safe_lib}
  ${CONVERT} lib/${safe_lib}
done

for safe_lib in ${SAFE_LIBS_PORTED}; do
  cp -a "${srcdir}/lib3/${safe_lib}" lib/${safe_lib}
done

# Touch-ups
cp ${srcdir}/lib3/pkg_resources.py lib/Chameleon-2.9.2/src

cp -a "${srcdir}/performance" performance

# The 2to3 benchmark looks for sample data to run over behind the
# 2to3_data symlink.  That needs to point to python-2 source, even
# though we're running 2to3 inside python-3.
( cd lib; ln -sf "${srcdir}/lib/2to3" 2to3_data )