Skip to content

Commit

Permalink
Make setup.py and build.sh use a local copy of cppad; i.e.,
Browse files Browse the repository at this point in the history
under current working directory.

build.sh: use test_setup.py for fast testing, directly edit setup.py.
install.omh: use setup.py instead of setup.template.
setup.py: change default cppad_parrent_dir to current working directory.
setup.template: remove this file and use test_setup.py instead.
  • Loading branch information
bradbell committed Mar 19, 2011
1 parent eb1cffe commit 0873ce4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
57 changes: 30 additions & 27 deletions build.sh
@@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/bash -e
#
# exit on any error
set -e
Expand All @@ -18,29 +18,32 @@ fi
option="$1"
# ---------------------------------------------------------------------
yyyymmdd=`date +%F | sed -e 's|-||g'` # todays year, month, and day
cppad_tarball='cppad-20110101.2.gpl.tgz' # name in download directory
cppad_parent_dir="$HOME/install" # parrent of download directory
cppad_tarball='cppad-20110101.2.gpl.tgz' # local_cppad_directory.gpl.tgz
cppad_parent_dir=`pwd` # parrent of local_cppad_directory
log_dir=`pwd` # write build.sh logs in here
cppad_download_dir='http://www.coin-or.org/download/source/CppAD/'
log_dir=`pwd`
# ---------------------------------------------------------------------
# directory for cppad tarball (see setup.template)
cppad_dir=`echo $cppad_tarball | sed -e 's|\([^-]*-[0-9]\{8\}\.[0-9]*\).*|\1|'`
if [ "$option" == "final" ] && [ -e "$cppad_parent_dir/$cppad_dir" ]
# ----------------------------------------------------------------------------
# Update setup.py so it corresponds to current build.sh options above.
# only edit line corresponding to assignment statement, check not a == case
echo "sed -i setup.py"
sed -i setup.py \
-e "s|^\(package_version *=\)[^=].*|\1 '$yyyymmdd'|" \
-e "s|^\(cppad_tarball *=\)[^=].*|\1 '$cppad_tarball'|" \
-e "s|^\(cppad_download_dir *=\)[^=].*|\1 '$cppad_download_dir'|"
#
# Create test_setup.py
if [ "$option" == "final" ]
then
echo "rm -r $cppad_parent_dir/$cppad_dir"
rm -r $cppad_parent_dir/$cppad_dir
echo "cp setup.py test_setup.py"
cp setup.py test_setup.py
else
echo "sed < setup.py > test_setup.py"
sed < setup.py > test_setup.py \
-e "s|^\(cppad_parent_dir *=\)[^=].*|\1 '$cppad_parent_dir'|"
echo "chmod +x test_setup.py"
chmod +x test_setup.py
fi
# ----------------------------------------------------------------------------
# Create setup.py from setup.template with certain replacements
# only edit line corresponding to assignment statement not check for ==
echo "sed < ./setup.template > setup.py -e ..."
sed < ./setup.template > setup.py \
-e "s|\(package_version *=\)[^=].*|\1 '$yyyymmdd'|" \
-e "s|\(cppad_tarball *=\)[^=].*|\1 '$cppad_tarball'|" \
-e "s|\(cppad_download_dir *=\)[^=].*|\1 '$cppad_download_dir'|"
#
echo "chmod +x setup.py"
chmod +x setup.py
# ----------------------------------------------------------------------------
omhelp_location=`which omhelp`
if [ "$omhelp_location" = "" ]
Expand Down Expand Up @@ -150,8 +153,8 @@ include README
include test_more.py
include test_example.py
EOF
echo "./setup.py sdist > setup.log"
./setup.py sdist > $log_dir/setup.log
echo "./test_setup.py sdist > setup.log"
./test_setup.py sdist > $log_dir/setup.log
if [ "$option" == "sdist" ]
then
exit 0
Expand All @@ -166,8 +169,8 @@ tar -xzf pycppad-$yyyymmdd.tar.gz
echo "cd pycppad-$yyyymmdd"
cd pycppad-$yyyymmdd
#
echo "./setup.py build_ext --inplace --debug --undef NDEBUG >> setup.log"
./setup.py build_ext --inplace --debug --undef NDEBUG >> $log_dir/setup.log
echo "./test_setup.py build_ext --inplace --debug --undef NDEBUG >> setup.log"
./test_setup.py build_ext --inplace --debug --undef NDEBUG >> $log_dir/setup.log
# Kludge: setup.py is mistakenly putting -Wstrict-prototypes on compile line
echo "sed -i $log_dir/setup.log \\"
echo " -e '/warning: command line option \"-Wstrict-prototypes\"/d'"
Expand All @@ -177,7 +180,7 @@ sed -i $log_dir/setup.log \
if [ ! -e pycppad/cppad_.so ] && [ ! -e pycppad/cppad_.dll ]
then
dir=`pwd`
echo "build.sh: setup.py failed to create $dir/pycppad/cppad_.so"
echo "build.sh: test_setup.py failed to create $dir/pycppad/cppad_.so"
exit 1
fi
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -207,8 +210,8 @@ fi
echo "rm -rf $HOME/prefix/pycppad"
rm -rf $HOME/prefix/pycppad
#
echo "./setup.py install --prefix=$HOME/prefix/pycppad >> setup.log"
./setup.py install --prefix=$HOME/prefix/pycppad >> $log_dir/setup.log
echo "./test_setup.py install --prefix=$HOME/prefix/pycppad >> setup.log"
./test_setup.py install --prefix=$HOME/prefix/pycppad >> $log_dir/setup.log
# ----------------------------------------------------------------------------
echo "OK: build.sh $1"
exit 0
2 changes: 1 addition & 1 deletion omh/install.omh
Expand Up @@ -76,7 +76,7 @@ $codep
$$
must be set to agree with your system:
$code
$verbatim%setup.template%5%# BEGIN USER SETTINGS%# END USER SETTINGS%$$
$verbatim%setup.py%5%# BEGIN USER SETTINGS%# END USER SETTINGS%$$
$$
Note that Boost Python must be installed before you can
properly set this information
Expand Down
10 changes: 5 additions & 5 deletions setup.template → setup.py 100644 → 100755
Expand Up @@ -10,8 +10,8 @@
boost_python_lib_name_cygwin = 'libboost_python-mt.a'
boost_python_lib_name_unix = 'libboost_python.so'
# The CppAD tarball will be downloaded into this directory
# and it will be extraced to a subdirectory called cppad-* or CppAD-*
cppad_parent_dir = os.environ.get('HOME') + '/install'
# and it will be extraced to a subdirectory called cppad-*
cppad_parent_dir = '.'
#
# END USER SETTINGS
# ---------------------------------------------------------------------
Expand All @@ -22,9 +22,9 @@
# for documentation on how to use the script setup.py
# ---------------------------------------------------------------------
# Values in setup.py that are replaced by build.sh
package_version = # date in yyyymmdd format corresonding to this distribution
cppad_tarball = # name of the tarball in CppAD download directory
cppad_download_dir = # web address where the tarball is downloaded from
package_version = '20110319'
cppad_tarball = 'cppad-20110101.2.gpl.tgz'
cppad_download_dir = 'http://www.coin-or.org/download/source/CppAD/'
# ---------------------------------------------------------------------
import re
import sys
Expand Down

0 comments on commit 0873ce4

Please sign in to comment.