old_setup.py#

View page source

Old Configure and Build the cppad_py Python Module#

See Also#

setup.py

Errors#

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

Syntax#

python3 old_setup.py install --prefix=prefix

External Requirements#

  1. bash

  2. cmake

  3. swig

  4. c++

  5. git

  6. pkg-config

  7. python version 3

  8. python-numpy

  9. python-scipy

  10. python-setuptools

Include Mixed Effects Modeling#

If include_mixed is true, the external packages listed below are also required. Note that, for most cases, get_cppad_mixed.sh will get all the required packages.

  1. The wget program.

  2. A fortran compiler.

  3. The gsl library including its development headers.

  4. suitesparse package. Note that only cholmod is really required from suitesparse.

Download#

Use the following command to download the current version of cppad_py:

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

Configure#

Before running old_setup_py or bin/get_cppad.sh , you should check and possibly change the settings in install_settings.py .

Get cppad#

The next step is to get a copy of cppad using get_cppad.sh. If you want to use the Laplace Approximation of Mixed Effects Models class, you will have to set include_mixed to true and use bin/get_cppad_mixed.sh to install cppad and other non-standard requirements.

prefix#

We use prefix to denote the prefix where cppad_py will be installed. This is the same as the value of cmake_install_prefix . You can create a variable with this value using the command

      eval $(bin/install_settings.py)
      prefix="$cmake_install_prefix"

libdir#

The value libdir is the suffix (after the prefix) where the libraries will be installed. This can be determined by running the command:

#  bin/libdir.py ; echo

You can create a variable with this value using the command

      libdir=$(bin/libdir.py)

LD_LIBRARY_PATH#

Make sure the directory prefix/libdir is in your LD_LIBRARY_PATH For example, if you set prefix and libdir as above,

      export LD_LIBRARY_PATH=$prefix/$libdir

In mac OS LD_LIBRARY_PATH should be replaced by DYLD_LIBRARY_PATH . For example,

      export DYLD_LIBRARY_PATH=$prefix/$libdir

In msys2 and cygwin you do not need to set LD_LIBRARY_PATH because static, instead of dynamic, libraries are used.

PKG_CONFIG_PATH#

Make sure the directory prefix/libdir/pkgconfig is in your PKG_CONFIG_PATH. For example,

      export PKG_CONFIG_PATH=$prefix/$libdir/pkgconfig

Local Build#

You should first remove any previous local copy of the Python cppad_py module (that might exist) using the command

      rm -r build/lib.*

You can build a local copy of the Python cppad_py module using the following command in the cppad_py.git directory:

      python3 old_setup.py bdist

This will create the directory

      build/lib.name/cppad_py

where name identifies your system and version of python. For example, you can set a variable equal to the value of name by executing the command

      name=$(ls build | grep '^lib\.' | sed -e 's|^lib\.||')

The next step is to copy the cppad_py directory to the cppad_py.git directory. For example,

      cp -r build/lib.$name/cppad_py cppad_py

Local Test#

You can test the local copy by executing the following commands in the cppad_py.git directory:

      PYTHONPATH=""
      python3 example/python/check_all.py

This test will use the local copy of cppad_py.git/cppad_py create by the local build instructions directly above.

PYTHONPATH#

In order to use the installed version of cppad_py, you must add the directory

      prefix/libdir/python3.minor/site-packages

to your PYTHONPATH where minor is the minor version corresponding to python3. For example,

      minor=$(echo "import sys;print(sys.version_info.minor)" | python3)
      export PYTHONPATH=$prefix/$libdir/python3.$minor/site-packages

Install#

Use the following command to build and install cppad_py:

      python3 old_setup.py install --prefix=$prefix

(see prefix above for how to set this shell variable).

This will install cppad_py in the directory

      prefix/libdir/python3.minor /site-packages/cppad_py

Test Install#

You can test the installed version by executing the command

      python3 example/python/check_all.py

If the directory cppad_py.git/cppad_py exists, you will be testing the local version, instead of the installed version. If this directory exists when the install command is run, it is removed by the install command.

Mac Os#

The Mac Os system has only been tested using brew and port to install packages not included with the system.

Cygwin#

A cygwin install, on 2021-05-06 and with include_mixed false, completed successfully by doing the following: First the following packages were added to the default set installed by the cygwin setup-x86_64 program: gcc-core, gcc-g++, gcc-fortran, python3-devel, python-pip-wheel, python-setuptools-wheel, lapack-devel, libopenblas, git, vim, cmake, make, swig. Then the pip3 program was used to install numpy and scipy. Then the install instructions above were used to install and test cppad_py.

Msys2#

A msys2 install with, include_mixed false, was attempted on 2021-05-09. First the following packages were installed using pacman: vim, git, make, cmake, swig. Next the mingw-w64-x86_64 version of following packages were installed using pacman: python, python-scipy, python-setuptools, gcc The problem is that old_setup.py is mixing windows and unix paths. An attempt was made to fix the environment variables using cygpath utility, but other related problems still persisted.

Child

Title

old_setup.py.error

Error Messages During Installation