setup.py#

View page source

Install cppad_py Python Module#

See Also#

old_setup.py

Errors#

If you encounter an error during this process, see setup.py.error .

cppad_py.git#

To begin the install process, create the cppad_py.git directory and make it the current working directory as follows:

git clone https://github.com/bradbell/cppad_py.git cppad_py.git
cd cppad_py.git

version#

We use version for its value in the pyproject.toml file (not including the quotes). You can set the shell variable version to this value, and see the value, with the following commands:

eval $(grep '^version *=' pyproject.toml | sed -e 's| ||g')
echo $version

System Dependencies#

The following command will use your system package manager to install some packages required by cppad_py:

bin/system_depend.sh

Simple Case#

In the simple case, the install setting include_mixed is false. After possibly changing some of the other settings in install_settings.py, execute the following commands:

bin/get_cppad.sh
python3 -m build
pip install dist/cppad_py-$version.tar.gz

You may need to add --user of specify some other install prefix in the pip command above. If you use this form of the install, you will not be able to use any of the mixed routines.

Example#

If you place the Python Code below in the file temp.py , the following command should execute without error:

python3 temp.py

Python Code:

import numpy
import cppad_py
x    = numpy.array( [ 1, 2], dtype = float)
ax   = cppad_py.independent(x)
ay   = ax * ax
f    = cppad_py.d_fun(ax, ay)
x[0] = 2.0
x[1] = 3.0
y    = f.forward(0, x)
assert all( y == x * x )
J    = f.jacobian(x)
assert J.shape == (2,2)
assert J[0,0] == 2.0 * x[0]
assert J[0,1] == 0.0
assert J[1,0] == 0.0
assert J[1,1] == 2.0 * x[1]

Testing#

The following command will test this install:

pytest example/python/core/*_xam.py

Mixed Case#

In the mixed case, include_mixed is true. After possibly changing some of the other settings in install_settings.py, execute the following commands:

bin/get_cppad_mixed.sh
python3 -m build
pip install dist/cppad_py-$version.tar.gz

If you use this form of the install, you will be able to use any of the mixed routines.

Testing#

The following command will test this install:

pytest example/python/*/*_xam.py

Child

Title

setup.py.error

setup.py Error Messages