Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Simplified installation #1

Closed
wants to merge 4 commits into from

1 participant

@dpo

I much simplified setup.py because it shouldn't be setup.py's job to download cppad and install it. For OSX users, installing cppad is now a one liner on the terminal and cppad gets installed by default to /usr/local. Installing pycppad is then straightforward. It should be similar on Linux provided the package manager gives access to cppad.

@dpo dpo closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 14, 2012
  1. @dpo

    Much simplified setup.py.

    dpo authored
  2. @dpo

    Update import style.

    dpo authored
  3. @dpo

    Remove trailing blanks.

    dpo authored
  4. @dpo

    Move test script to own directory.

    dpo authored
    Otherwise, the script causes import errors.
This page is out of date. Refresh to see the latest.
Showing with 54 additions and 150 deletions.
  1. +16 −15 pycppad/__init__.py
  2. +38 −135 setup.py
  3. 0  { → test}/test_more.py
View
31 pycppad/__init__.py
@@ -14,20 +14,20 @@
#
# $head Purpose$$
# Creates an AD object $icode a_x$$ that records floating point operations.
-# An $cref/adfun/$$ object can later use this recording to evaluate
+# An $cref/adfun/$$ object can later use this recording to evaluate
# function values and derivatives. These later evaluations are done
-# using the same type as $icode x$$
+# using the same type as $icode x$$
# (except when $icode x$$ is an instance of $code int$$,
# the later evaluations are done using $code float$$ operations).
#
-# $head x$$
+# $head x$$
# The argument $icode x$$ can be an instance of an $code int$$ (AD level 0),
# or an instance of $code float$$ (AD level 0),
# or an $code a_float$$ (AD level 1).
# The argument $icode x$$ may also be a $code numpy.array$$ with one of the
# element types listed in the previous sentence.
#
-# $head a_x$$
+# $head a_x$$
# $index a_float, create$$
# $index create, a_float$$
# $index a2float, create$$
@@ -37,9 +37,9 @@
# If $icode x$$ is an $code a_float$$,
# $icode a_x$$ is an $code a2float$$ (AD level 2).
# If $icode x$$ is an $code numpy.array$$,
-# $icode a_x$$ is also an $code numpy.array$$ with the
+# $icode a_x$$ is also an $code numpy.array$$ with the
# same shape as $icode x$$.
-#
+#
# $children%
# example/ad.py
# %$$
@@ -65,21 +65,21 @@
# $head Purpose$$
# Returns an object with one lower level of AD recording.
#
-# $head a_x$$
+# $head a_x$$
# The argument $icode a_x$$ must be an $code a_float$$ (AD level 1),
# or an $code a2float$$ (AD level 2).
# The argument $icode a_x$$ may also be a $code numpy.array$$ with one of the
# element types listed in the previous sentence.
#
-# $head x$$
+# $head x$$
# If $icode a_x$$ is an $code a_float$$,
# $icode x$$ is a $code float$$ (AD level 0).
# If $icode a_x$$ is an $code a2float$$,
# $icode x$$ is an $code a_float$$ (AD level 1).
# If $icode a_x$$ is an $code numpy.array$$,
-# $icode x$$ is also an $code numpy.array$$ with the
+# $icode x$$ is also an $code numpy.array$$ with the
# same shape as $icode a_x$$.
-#
+#
# $children%
# example/value.py
# %$$
@@ -94,7 +94,8 @@
"""
import numpy
-import pycppad.cppad_
+from pycppad import cppad_
+#import pycppad.cppad_
from cppad_ import a_float
from cppad_ import a2float
from cppad_ import abort_recording
@@ -107,8 +108,8 @@
def ad(x) :
"""
ad(x): returns an object with one higher level of automatic differentiation.
- If x is an int, or float (AD level 0), ad(x) is an a_float
- (AD level 1). If x is an a_float (AD level 1), ad(x) is an a2float
+ If x is an int, or float (AD level 0), ad(x) is an a_float
+ (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) :
@@ -131,8 +132,8 @@ def ad(x) :
def value(a_x) :
"""
value(a_x): returns object with one lower level of automatic differentation.
- If a_x is an a_float, value(a_x) is a float (AD level 0).
- If a_x is an a2float, value(a_x) is an a_float (AD level 1).
+ If a_x is an a_float, value(a_x) is a float (AD level 0).
+ If a_x is an a2float, value(a_x) is an a_float (AD level 1).
"""
if isinstance(a_x, a_float) :
return cppad_.float_(a_x);
View
173 setup.py
@@ -1,146 +1,49 @@
#!/usr/bin/env python
import os
-# ---------------------------------------------------------------------
-# The code below is included verbatim in omh/install.omh
-# BEGIN USER SETTINGS
-# Directory where Boost Python library and include files are located
-boost_python_lib_dir = '/usr/lib'
-boost_python_include_dir= '/usr/include'
-# Name of the Boost Python library in boost_python_lib_dir.
-# Must begin with 'lib' and end with '.so' (under unix) or '.a' (under cygwin).
-boost_python_lib_name_cygwin = 'libboost_python-mt.a'
-boost_python_lib_name_darwin = 'libboost_python.dylib'
-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-*
-cppad_parent_dir = 'external'
-#
-# END USER SETTINGS
-# ---------------------------------------------------------------------
-# See http://docs.python.org/distutils/setupscript.html
-# for documentation on how to write the script setup.py
-#
-# See http://docs.python.org/install/index.html
-# for documentation on how to use the script setup.py
-# ---------------------------------------------------------------------
-# Values in setup.py that are replaced by build.sh
-package_version = '20111018'
-cppad_tarball = 'cppad-20110101.5.gpl.tgz'
-cppad_download_dir = 'http://www.coin-or.org/download/source/CppAD'
-# ---------------------------------------------------------------------
-import re
-import sys
-import platform
from distutils.core import setup, Extension
from numpy.distutils.misc_util import get_numpy_include_dirs
-# ---------------------------------------------------------------------
-# determine if this is a cygwin system
-uname = (( platform.uname() )[0] )[0:6]
-is_cygwin = (uname == 'CYGWIN')
-is_darwin = (uname == 'Darwin')
-# ---------------------------------------------------------------------
-# determine the install directory and the include directory
-match=re.search('([^-]*-[0-9]*[.][0-9]*)[.].*', cppad_tarball)
-cppad_dir = match.group(1)
-cppad_include_dir = cppad_parent_dir + '/' + cppad_dir
-# ---------------------------------------------------------------------
-# check for the specified boost-python library
-if is_cygwin :
- boost_python_lib_name = boost_python_lib_name_cygwin
- m = re.search('lib([a-zA-Z0-9_-]+)[.]a', boost_python_lib_name)
- if m == None :
- print "boost_python_lib_name_cygwin must begin with 'lib' & end with '.a'"
-elif is_darwin :
- boost_python_lib_name = boost_python_lib_name_darwin
- m = re.search('lib([a-zA-Z0-9_-]+)[.]dylib', boost_python_lib_name)
- if m == None :
- print "boost_python_lib_name_darwin must begin with 'lib' & end with '.dylib'"
-else :
- boost_python_lib_name = boost_python_lib_name_unix
- m = re.search('lib([a-zA-Z0-9_-]+)[.]so', boost_python_lib_name)
- if m == None :
- print "boost_python_lib_name_unix must begin with 'lib' & 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: ' + boost_python_lib_path
- print 'Use the web page http://www.boost.org/ for information about'
- print 'boost::python. Make sure that boost_python_lib_dir and'
- print 'boost_python_lib_name are set correctly at the beginning of the file'
- print 'setup.py.'
- exit(1)
-# ---------------------------------------------------------------------
-# make sure we have a copy of the soruce for the specified cppad version
-build_source_dist = False
-if len( sys.argv ) == 2 :
- if sys.argv[1] == 'sdist' :
- build_source_dist = True
-if not build_source_dist :
- if not os.access( cppad_parent_dir , os.R_OK ) :
- cmd = 'mkdir ' + cppad_parent_dir
- os.system( cmd )
- if not os.access( cppad_include_dir , os.R_OK ) :
- print 'os.getcwd() = ' + os.getcwd()
- print 'Please wait while the proper version of CppAD is downloaded'
- cmd = '( cd ' + cppad_parent_dir + ';'
- cmd = cmd + ' curl -O ' + cppad_download_dir + '/' + cppad_tarball + ')'
- print cmd
- os.system( cmd )
- cmd = '( cd ' + cppad_parent_dir + ';'
- cmd = cmd + ' tar -xzf ' + cppad_tarball + ')'
- print cmd
- os.system( cmd )
- if not os.access( cppad_include_dir , os.R_OK ) :
- print 'Did not successfully retrieve the proper verison of CppAD'
- exit(1)
-# ---------------------------------------------------------------------
-try:
- doc_files = os.listdir('doc')
- for i in range( len(doc_files) ):
- doc_files[i] = 'doc/' + doc_files[i]
-
-except:
- doc_files = []
-#
-brad_email = 'bradbell @ seanet dot com'
-sebastian_email = 'sebastian dot walter @ gmail dot com'
-package_author = 'Bradley M. Bell and Sebastian F. Walter'
-package_author_email = sebastian_email + ' , ' + brad_email
-package_url = 'http://github.com/b45ch1/pycppad/tree/master'
-package_description = 'Python Algorihtmic Differentiation Using CppAD'
-package_data_files = [ ('share/doc/pycppad', doc_files ) ]
-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_include_dirs.append( boost_python_include_dir )
-cppad_extension_library_dirs = [ boost_python_lib_dir ]
-cppad_extension_libraries = [ boost_python_lib ]
-cppad_extension_sources = [
- 'pycppad' + '/adfun.cpp' ,
- 'pycppad' + '/pycppad.cpp' ,
- 'pycppad' + '/vec2array.cpp' ,
- 'pycppad' + '/vector.cpp'
-]
-extension_modules = [ Extension(
- cppad_extension_name ,
+
+# Begin config.
+cppad_include_dir = []
+cppad_lib_dir = []
+boost_python_include_dir = ['/usr/local/include']
+boost_python_lib_dir = ['/usr/local/lib']
+libbost_python_name = 'boost_python-mt'
+# End config.
+
+cppad_extension_name = os.path.join('pycppad', 'cppad_')
+cppad_extension_include_dirs = get_numpy_include_dirs()
+cppad_extension_include_dirs += cppad_include_dir
+cppad_extension_include_dirs += boost_python_include_dir
+cppad_extension_library_dirs = cppad_lib_dir
+cppad_extension_library_dirs += boost_python_lib_dir
+cppad_extension_libraries = [libbost_python_name]
+
+cppad_source_files = ['adfun.cpp', 'pycppad.cpp', 'vec2array.cpp', 'vector.cpp']
+cppad_extension_sources = map(lambda p: os.path.join('pycppad', p),
+ cppad_source_files)
+
+extension_modules = [ Extension(
+ cppad_extension_name ,
cppad_extension_sources ,
include_dirs = cppad_extension_include_dirs ,
library_dirs = cppad_extension_library_dirs ,
libraries = cppad_extension_libraries ,
) ]
-#
+
+brad_email = 'bradbell @ seanet dot com'
+sebastian_email = 'sebastian dot walter @ gmail dot com'
+package_author_email = sebastian_email + ' , ' + brad_email
+
setup(
- name = 'pycppad' ,
- version = package_version ,
- license = package_license ,
- description = package_description ,
- author = package_author ,
- author_email = package_author_email ,
- url = package_url ,
- ext_modules = extension_modules ,
- packages = [ 'pycppad' , 'pycppad' ] ,
- package_dir = { 'pycppad' : 'pycppad' } ,
- data_files = package_data_files
+ name = 'pycppad',
+ version = '20111018',
+ license = 'BSD',
+ description = 'Python Algorihtmic Differentiation Using CppAD',
+ author = 'Bradley M. Bell and Sebastian F. Walter',
+ author_email = package_author_email,
+ url = 'http://github.com/b45ch1/pycppad/tree/master',
+ ext_modules = extension_modules,
+ packages = [ 'pycppad' , 'pycppad' ],
+ package_dir = { 'pycppad' : 'pycppad' },
)
View
0  test_more.py → test/test_more.py
File renamed without changes
Something went wrong with that request. Please try again.