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