Prev Next

@(@\newcommand{\B}[1]{ {\bf #1} } \newcommand{\R}[1]{ {\rm #1} }@)@
Configure and Build the cppad_py Python Module

Syntax
python setup.py build_ext --inplace [--debug] [--undef NDEBUG]
where python is the Python executable you will be using with cppad_py.

External Requirements
  1. c++ .
  2. cmake .
  3. git .
  4. swig : There seems to be a problem with swig-3.0.8; see issue 3 .
  5. python : version 2 or 3.
  6. numpy .


Download
Use the following command to download the current version of cppad_py:
     git clone https://github.com/bradbell/cppad_py.git 
top_srcdir

Top Source Directory
The directory you choose for top_srcdir is referred to as your top source directory.

Configure
Before running setup.py or get_cppad.sh , you should check and possibly change the following settings (which are near the top of top_srcdir/setup.py ):
verbose_makefile = "false"
build_type       = "debug"
cppad_prefix     = "build/prefix"
test_cppad       = "fasle"
extra_cxx_flags  = "-Wall -pedantic-errors -Wno-unused-result -std=c++11"
Each of these settings is described below:

verbose_makefile
This is either "true" or "false". If it is true, many of the compiler and Swig options used to build the system are output during the make commands. If it is false, the output during the make commands just describes whats is being done without so much detail.

build_type
This is either "debug", "release".

extra_cxx_flags
Extra compiler flags used when compiling C++ code.

cppad_prefix
This is the directory where get_cppad.sh puts Cppad (relative to the top source directory).

test_cppad
This is either "true" or "false". If it is "true", get_cppad.sh will build and run a separate check of Cppad for this system. This takes a significant amount of time, but may be useful if you have any problems.

Get cppad
The next step is to get a copy of cppad using get_cppad.sh .

Build cppad_py
The next step is the build the Python cppad_py module using the command:
     
python setup.py build_ext --inplace --debug --undef NDEBUG
where python is the Python executable you will be using with cppad_py. If you want a faster version, with less error reporting, use
     
python setup.py build_ext --inplace

Testing

python
The next step is to test the cppad_py on your system by executing the following commands starting in top_srcdir :
     cd lib/example/python
     
python check_all.py
where python is the same version of python as above.

c++
You can also test the cppad_py c++ interface cpp_lib on your system by executing the following commands starting in top_srcdir :
     cd build
     make check_lib_cplusplus

import
If you are in top_srcdir you should be able to execute the following commands:
     
python
     import cppad_py
     quit()
We need to install cppad_py so you can import it from any directory.

Installing
Use the following command to install the debug version of cppad_py:
     
python setup.py build_ext --debug --undef NDEBUG install --prefix=prefix
or the following to install the release version:
     
python setup.py build_ext install --prefix=prefix
This will install cppad_py in the directory
     
prefix/lib/pythonmajor.minor/site_packages/cppad_py
where major and minor are the major and minor versions for python .

Python Path
You can check the current setting of your python path using the commands:
     
python
     import sys
     print(sys.path)
     quit()
The directory prefix/lib/pythonmajor.minor/site_packages must be in your python path.
Input File: setup.py