···11+{
22+ # Python package expression
33+ python,
44+ # Name of package (e.g. numpy or scipy)
55+ pkgName,
66+ # Atlas math library
77+ atlas
88+}:
99+1010+{
1111+1212+ # First "install" the package, then import what was installed, and call the
1313+ # .test() function, which will run the test suite.
1414+ checkPhase = ''
1515+ runHook preCheck
1616+1717+ _python=${python}/bin/${python.executable}
1818+1919+ # We will "install" into a temp directory, so that we can run the
2020+ # tests (see below).
2121+ install_dir="$TMPDIR/test_install"
2222+ install_lib="$install_dir/lib/${python.libPrefix}/site-packages"
2323+ mkdir -p $install_dir
2424+ $_python setup.py install \
2525+ --install-lib=$install_lib \
2626+ --old-and-unmanageable \
2727+ --prefix=$install_dir > /dev/null
2828+2929+ # Create a directory in which to run tests (you get an error if you try to
3030+ # import the package when you're in the current directory).
3131+ mkdir $TMPDIR/run_tests
3232+ pushd $TMPDIR/run_tests > /dev/null
3333+ # Temporarily add the directory we installed in to the python path
3434+ # (not permanently, or this pythonpath will wind up getting exported),
3535+ # and run the test suite.
3636+ PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \
3737+ 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)'
3838+ popd > /dev/null
3939+4040+ runHook postCheck
4141+ '';
4242+4343+ # Creates a site.cfg telling the setup script where to find depended-on
4444+ # math libraries.
4545+ preBuild = ''
4646+ echo "Creating site.cfg file..."
4747+ cat << EOF > site.cfg
4848+ [atlas]
4949+ include_dirs = ${atlas}/include
5050+ library_dirs = ${atlas}/lib
5151+ EOF
5252+ '';
5353+}