[Nix-dev] Python cannot find setup.py data_files in nix-shell

K. Cong kc04bc at gmx.com
Mon Dec 5 20:23:53 CET 2016


Hi,

I'm using the following Nix expression to install SNAP for use in a
nix-shell.

```
with import <nixpkgs> {};

let dependencies = rec {
  _snap = with python27Packages; buildPythonPackage {
    name = "snap-3.0.2";
    src = fetchurl {
      url =
"https://snap.stanford.edu/snappy/release/snap-3.0.2-3.0-centos6.5-x64-py2.6.tar.gz";
      sha256 = "07q3pkm0f49c236vv1yb4kzi09h4nldgdax07r7zr0wbvwlzv43w";
    };
  };
};
in with dependencies;

stdenv.mkDerivation rec {
  name = "snap";
  env = buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    python27
    graphviz
    gnuplot
    _snap
  ];
}
```

Unfortunately, when I try to do `import snap`, Python says:

  File
"/nix/store/qyavbs7cd4fy0y7grigwhnvfyrypa4a6-python2.7-snap-3.0.2/lib/python2.7/site-packages/snap.py",
line 20, in swig_import_helper
    import _snap
ImportError: No module named _snap

I noticed that _snap.so is not under that directory, but it is under an
even deeper directory. I'm guessing this is the problem.

/nix/store/qyavbs7cd4fy0y7grigwhnvfyrypa4a6-python2.7-snap-3.0.2/lib/python2.7/site-packages/nix/store/fmhcxqk5la805i418m861g3g60p4hvm0-python2.7-bootstrapped-pip-9.0.1/lib/python2.7/site-packages

_snap.so also happens to be one of the data_files field in the setup.py
script from the source. What should I change in my Nix expression so
that Python finds _snap.so?

Thanks!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20161205/3f0433e7/attachment.sig>


More information about the nix-dev mailing list