diff --git a/brad/doc.omh b/brad/doc.omh index 41067e0..4c499c9 100644 --- a/brad/doc.omh +++ b/brad/doc.omh @@ -28,7 +28,7 @@ $hiliteseq% %.%reverse%(% reverse %$$ -$section pycppad-20090213: A Python Algorithm Derivative Package$$ +$section pycppad-20090512: A Python Algorithm Derivative Package$$ $index AD, python$$ $index python, AD$$ diff --git a/brad/omh/install.omh b/brad/omh/install.omh index f0429ca..ef642f6 100644 --- a/brad/omh/install.omh +++ b/brad/omh/install.omh @@ -1,6 +1,7 @@ $begin install$$ $dollar @$$ $spell + numpy usr inplace undef @@ -27,13 +28,18 @@ $section Installing pycppad$$ $index install, pycppad$$ $index pycppad, install$$ +$head Requires$$ +This package requires the following other packages to be installed: +Boost Python (development version), +numpy. + $head Downloading$$ $index download, pycppad$$ $index pycppad, download$$ Download the file $href% - http://www.seanet.com/~bradbell/pycppad-20090213.tar.gz% - pycppad-20090213.tar.gz + http://www.seanet.com/~bradbell/pycppad-20090512.tar.gz% + pycppad-20090512.tar.gz %$$ and store it on your machine. @@ -44,14 +50,14 @@ $index extract, pycppad$$ $index pycppad, extract$$ On unix, you could use the command $codep - tar -xvzf pycppad-20090213.tar.gz + tar -xvzf pycppad-20090512.tar.gz $$ -which would create the directory $code pycppad-20090213$$. +which would create the directory $code pycppad-20090512$$. $head Required Setup Information$$ The value of the following setup variables, in the file $codep - pycppad-20090213/setup.py + pycppad-20090512/setup.py $$ must be set to agree with your system: $code @@ -64,7 +70,7 @@ properly set this information $head Building$$ $index build, pycppad$$ $index pycppad, build$$ -Change into the directory $code pycppad-20090213$$ and execute the command +Change into the directory $code pycppad-20090512$$ and execute the command $codep ./setup.py build_ext --inplace --debug --undef NDEBUG $$ @@ -98,7 +104,7 @@ $index test, pycppad$$ $index pycppad, test$$ You can test of all the $cref/examples/example/$$ in the $code pycppad$$ documentation. -Change into the directory $code pycppad-20090213$$ and execute the command +Change into the directory $code pycppad-20090512$$ and execute the command $codep python test_example.py $$ @@ -115,7 +121,7 @@ You may or may not preform this step: $pre $$ -Change into the directory $code pycppad-20090213$$ and execute the command +Change into the directory $code pycppad-20090512$$ and execute the command $codei% python setup.py install --prefix=%prefix% %$$ @@ -134,7 +140,7 @@ an uninstall command. You can uninstall the $code pycppad$$ package by removing the entries $codei% %prefix%/lib/python%major%.%minor%/site-packages/pycppad - %prefix%/lib/python%major%.%minor%/site-packages/pycppad-20090213.egg-info + %prefix%/lib/python%major%.%minor%/site-packages/pycppad-20090512.egg-info %prefix%/share/doc/pycppad %$$ where $icode major$$ and $icode minor$$ @@ -152,7 +158,7 @@ $codei% %$$ unless the distribution directory $codep - pycppad-20090213 + pycppad-20090512 $$ or (provided you installed $code pycppad$$) the installation directory $codei% @@ -174,7 +180,7 @@ $codei% $head pycppad Documentation$$ The documentation for $code pycppad$$ starts out in the directory $codep - pycppad-20090213/doc + pycppad-20090512/doc $$ During the installation process, it is copied to the directory $codei% diff --git a/brad/pycppad/__init__.py b/brad/pycppad/__init__.py index a91db13..030e14a 100644 --- a/brad/pycppad/__init__.py +++ b/brad/pycppad/__init__.py @@ -181,7 +181,9 @@ def ad(x) : (AD level 1). If x is an a_float (AD level 1), ad(x) is an a2float (AD level 2). Higher AD levels for the argument x are not yet supported. """ - if isinstance(x, int) or isinstance(x, float) : + if isinstance(x, int) : + return a_float( float(x) ) + elif isinstance(x, float) : return a_float(x) elif isinstance(x, a_float) : return a2float(x) diff --git a/brad/setup.template b/brad/setup.template index 77781be..9728836 100644 --- a/brad/setup.template +++ b/brad/setup.template @@ -1,8 +1,12 @@ #!/usr/bin/env python # --------------------------------------------------------------------- +# The code below is included verbatim in omh/install.omh # BEGIN USER SETTINGS -boost_lib_dir = '/usr/lib' # Directory where boost::python library is located -boost_python_lib = 'boost_python' # name of the library in that directory +# Directory where Boost Python library is located +boost_python_lib_dir = '/usr/lib' +# The name of the Boost Python library in that directory which must +# begin with 'lib' and end with '.so'. +boost_python_lib_name = 'libboost_python-py26.so' # END USER SETTINGS # --------------------------------------------------------------------- # See http://docs.python.org/distutils/setupscript.html @@ -28,20 +32,23 @@ else : exit(1) cppad_include_dir = cppad_parent_dir + '/' + cppad_dir # --------------------------------------------------------------------- - +import re import os import sys from distutils.core import setup, Extension from numpy.distutils.misc_util import get_numpy_include_dirs # --------------------------------------------------------------------- -boost_python_lib_path = boost_lib_dir + '/lib' + boost_python_lib + '.so' +m = re.search('lib([a-zA-Z0-9_-]+)[.]so', boost_python_lib_name) +if m == None : + print 'boost_python_lib_name must begin with \'lib\' and end with \'.so\'' +boost_python_lib = m.group(1) +boost_python_lib_path = boost_python_lib_dir + boost_python_lib_name if not os.access ( boost_python_lib_path , os.R_OK ) : - print 'Cannot find the boost::python library' - print boost_python_lib_path + print 'Cannot find the Boost Python library.' print 'Use the following web page for information about boost::python' print 'http://www.boost.org/doc/libs/1_37_0/libs/python/doc/index.html' - print 'Make sure that boost_lib_dir and boost_python_lib are set correctly' - print 'at the beginnin of the file setup.py' + print 'Make sure that boost_python_lib_dir and boost_python_lib_name' + print 'are set correctly at the beginnin of the file setup.py' # --------------------------------------------------------------------- # set cppad_include_dir build_source_dist = False @@ -81,7 +88,7 @@ package_license = 'BSD' cppad_extension_name = 'pycppad' + '/cppad_' cppad_extension_include_dirs = get_numpy_include_dirs() cppad_extension_include_dirs.append( cppad_include_dir ) -cppad_extension_library_dirs = [ boost_lib_dir ] +cppad_extension_library_dirs = [ boost_python_lib_dir ] cppad_extension_libraries = [ boost_python_lib ] cppad_extension_sources = [ 'pycppad' + '/adfun.cpp' ,