[Nix-dev] Python cannot find setup.py data_files in nix-shell
Benno Fünfstück
benno.fuenfstueck at gmail.com
Sat Jan 14 17:44:13 CET 2017
Hi K. Cong,
this bug happens because Nixpkgs uses the wheel's infrastructure to build
python packages, which appears to treat data files differently:
https://github.com/aquynh/capstone/pull/783/commits/23fe9f36622573c747e2bab6119ff245437bf276.
Here's a patch that fixes the issue for your package:
setup-py-data-files.patch:
diff -rup snap-3.0.2-3.0-centos6.5-x64-py2.6.orig/setup.py
snap-3.0.2-3.0-centos6.5-x64-py2.6/setup.py
--- snap-3.0.2-3.0-centos6.5-x64-py2.6.orig/setup.py 2017-01-14
17:37:02.614220670 +0100
+++ snap-3.0.2-3.0-centos6.5-x64-py2.6/setup.py 2017-01-14
17:38:10.928668352 +0100
@@ -151,6 +151,9 @@ for p in sys.path:
user_install = os.path.join(p[:n],instdir)
break
+if "bdist_wheel" in sys.argv:
+ user_install = instdir
+
# if Mac OS X, get a path for the Python dynamic library
dynlib_path = None
if uname[0] == "Darwin"
You can include it in your build like this:
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";
};
patches = [ ./setup-py-data-files.patch ];
};
};
Regards,
Benno
K. Cong <kc04bc at gmx.com> schrieb am Mo., 5. Dez. 2016 um 20:24 Uhr:
> 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!
>
>
> _______________________________________________
> nix-dev mailing list
> nix-dev at lists.science.uu.nl
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170114/90824c3f/attachment.html>
More information about the nix-dev
mailing list