···1+{
2+ # Python package expression
3+ python,
4+ # Name of package (e.g. numpy or scipy)
5+ pkgName,
6+ # Atlas math library
7+ atlas
8+}:
9+10+{
11+12+ # First "install" the package, then import what was installed, and call the
13+ # .test() function, which will run the test suite.
14+ checkPhase = ''
15+ runHook preCheck
16+17+ _python=${python}/bin/${python.executable}
18+19+ # We will "install" into a temp directory, so that we can run the
20+ # tests (see below).
21+ install_dir="$TMPDIR/test_install"
22+ install_lib="$install_dir/lib/${python.libPrefix}/site-packages"
23+ mkdir -p $install_dir
24+ $_python setup.py install \
25+ --install-lib=$install_lib \
26+ --old-and-unmanageable \
27+ --prefix=$install_dir > /dev/null
28+29+ # Create a directory in which to run tests (you get an error if you try to
30+ # import the package when you're in the current directory).
31+ mkdir $TMPDIR/run_tests
32+ pushd $TMPDIR/run_tests > /dev/null
33+ # Temporarily add the directory we installed in to the python path
34+ # (not permanently, or this pythonpath will wind up getting exported),
35+ # and run the test suite.
36+ PYTHONPATH="$install_lib:$PYTHONPATH" $_python -c \
37+ 'import ${pkgName}; ${pkgName}.test("fast", verbose=10)'
38+ popd > /dev/null
39+40+ runHook postCheck
41+ '';
42+43+ # Creates a site.cfg telling the setup script where to find depended-on
44+ # math libraries.
45+ preBuild = ''
46+ echo "Creating site.cfg file..."
47+ cat << EOF > site.cfg
48+ [atlas]
49+ include_dirs = ${atlas}/include
50+ library_dirs = ${atlas}/lib
51+ EOF
52+ '';
53+}