Python Package Wheel No matching distribution found

for replacement in diffs, look at

and the actual diff:

However, I feel like the best scenario is to upstream a patch like I said above where the build is able to read from the environment. And then just have attrs like: NFSTREAM_PCAP_LIB= "${lib.getLib libpcap}/lib/libpcap.a"; in your nix expression.

Hi!

Sorry, i’m probably asking you a lot of useless questions :confused:
But i’ve added in the patch something like this for all the libraries:

+                           os.env.get("NFSTREAM_LIB_PCAP", '/local/lib/libpcap.a'),
+                           os.env.get("NFSTREAM_LIB_NDPI", '/local/lib/libndpi.a'),
+                           os.env.get("NFSTREAM_LIB_CRYPT", '/local/lib/libgcrypt.a'),
+                           os.env.get("NFSTREAM_LIB_GPG", '/local/lib/libgpg-error.a)'

But it doesn’t find the libs:

gcc: error: /local/lib/libpcap.a: No such file or directory
gcc: error: /local/lib/libndpi.a: No such file or directory
gcc: error: /local/lib/libgcrypt.a: No such file or directory
gcc: error: /local/lib/libgpg-error.a: No such file or directory

I guess that i’m missing something :confused:

patching is only half it.

The other half is passing those env vars along.

buildPythonPackage {
  ...
  NFSTREAM_LIB_PCAP = "${pkgsStatic.libpcap}/lib/libpcap.a";

Uh sorry. I thought that those vars should be inserted in patches [ … ];
Now i get this error:

nfstream/engine/engine_cc.c:16:10: fatal error: ndpi_api.h: No such file or directory
   16 | #include <ndpi_api.h>
      |          ^~~~~~~~~~~~

and

error: builder for '/nix/store/hsk36bl9pl6rci19bcgkkrkymh3qalbp-python3.9-nfstream-6.3.5.drv' failed with exit code 1;
       last 10 log lines:
       >     self.distribution.run_command(command)
       >   File "/nix/store/66iaz17xwjx2s6wl3j2qn9s6210b0s28-python3-3.9.6/lib/python3.9/distutils/dist.py", line 985, in run_command
       >     cmd_obj.run()
       >   File "setup.py", line 62, in run
       >     setup_engine_cc()
       >   File "setup.py", line 40, in setup_engine_cc
       >     subprocess.check_call([platform_compiler, '-I${ndpi}/include/ndpi', '-shared', '-o',
       >   File "/nix/store/66iaz17xwjx2s6wl3j2qn9s6210b0s28-python3-3.9.6/lib/python3.9/subprocess.py", line 373, in check_call
       >     raise CalledProcessError(retcode, cmd)
       > subprocess.CalledProcessError: Command '['gcc', '-I${ndpi}/include/ndpi', '-shared', '-o', 'nfstream/engine/engine_cc.so', '-g', '-fPIC', '-DPIC', '-O2', '-Wall', 'nfstream/engine/engine_cc.c', '/nix/store/5i7z7iidkhiwdb760p18b8px8g686rha-libpcap-1.10.0/lib/libpcap.a', '/nix/store/hjlb70jlc829gv26kbyxygs7w9sb4srx-ndpi-3.4/lib/libndpi.a', '/nix/store/1iklhpn4i1r3jdrzfmpzw1da1ikjdzgp-libgcrypt-static-x86_64-unknown-linux-musl-1.9.4/lib/libgcrypt.a', '/nix/store/8c7gvkasijdkpwq1m5nhwgl12y1jsam6-libgpg-error-static-x86_64-unknown-linux-musl-1.41/lib/libgpg-error.a']' returned non-zero exit status 1.
       For full logs, run 'nix log /nix/store/hsk36bl9pl6rci19bcgkkrkymh3qalbp-python3.9-nfstream-6.3.5.drv'.

I hope not to stress you too much!

Add all of the libraries to buildInputs, in addition to what you already have done. This should pass the correct -I arguments to gcc. -I is how gcc allows for additional paths to be added when resolving bracketed includes (e.g. #includes <xxx.h> )

buildPythonPackage {
  ...
  buildInputs = with pkgsStatic; [
    libpcap
    ....
  ];

  ...
  NFSTREAM_LIB_PCAP = "${pkgsStatic.libpcap}/lib/libpcap.a";

okay, two things:

first i guess that i should patch this too:

subprocess.check_call([platform_compiler, '-I/usr/local/include/ndpi', '-shared', '-o

i tried with the same methods but got some errors

second : According to the website there are also some Prerequisites, should i add them too?

Doesn’t have to be patched, because gcc here is the nixpkgs wrapped gcc, which will be aware of buildInputs.

upstream (generally) knows best. Just note that the version of documentation, and source code you are consuming don’t have to be in sync.

but those dependencies should be:

  nativeBuildInputs = [
    pkg-config flex bison gettext autoreconfHook
  ];

I’ve added the changes that u suggest, and now get this error about pkg-config.
the derivation is here: http://ix.io/3Dil

and error:

these 2 derivations will be built:
  /nix/store/q6s3anbzrif0n2nnm6zlbhf6kimrd82v-ndpi-static-x86_64-unknown-linux-musl-3.4.drv
  /nix/store/bivxl9aajj9dhv2q9x1yn9yjv0r01g3v-python3.9-nfstream-6.3.5.drv
building '/nix/store/q6s3anbzrif0n2nnm6zlbhf6kimrd82v-ndpi-static-x86_64-unknown-linux-musl-3.4.drv'...
unpacking sources
unpacking source archive /nix/store/r0i1b97x1iv5nh04hl242lss0ynf494m-source
source root is source
patching sources
applying patch /nix/store/dybyfbdi49il1s45pf5xdm1wwpx8n6q4-3.4-CVE-2021-36082.patch
patching file src/lib/protocols/netbios.c
patching file src/lib/protocols/tls.c
updateAutotoolsGnuConfigScriptsPhase
configuring
configure flags: --prefix=/nix/store/jw4lm75h3bmmhh8542w2npdc7k9kfdr7-ndpi-static-x86_64-unknown-linux-musl-3.4 --disable-shared --enable-static --disable-shared --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-musl
pkg-config is missing: please install it (apt-get install pkg-config) and try again
building
no Makefile, doing nothing
installing
install flags: SHELL=/nix/store/wv35g5lff84rray15zlzarcqi9fxzz84-bash-4.4-p23/bin/bash install
make: *** No rule to make target 'install'.  Stop.
error: builder for '/nix/store/q6s3anbzrif0n2nnm6zlbhf6kimrd82v-ndpi-static-x86_64-unknown-linux-musl-3.4.drv' failed with exit code 2;
       last 10 log lines:
       > patching file src/lib/protocols/tls.c
       > updateAutotoolsGnuConfigScriptsPhase
       > configuring
       > configure flags: --prefix=/nix/store/jw4lm75h3bmmhh8542w2npdc7k9kfdr7-ndpi-static-x86_64-unknown-linux-musl-3.4 --disable-shared --enable-static --disable-shared --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-musl
       > pkg-config is missing: please install it (apt-get install pkg-config) and try again
       > building
       > no Makefile, doing nothing
       > installing
       > install flags: SHELL=/nix/store/wv35g5lff84rray15zlzarcqi9fxzz84-bash-4.4-p23/bin/bash install
       > make: *** No rule to make target 'install'.  Stop.
       For full logs, run 'nix log /nix/store/q6s3anbzrif0n2nnm6zlbhf6kimrd82v-ndpi-static-x86_64-unknown-linux-musl-3.4.drv'.
error: 1 dependencies of derivation '/nix/store/bivxl9aajj9dhv2q9x1yn9yjv0r01g3v-python3.9-nfstream-6.3.5.drv' failed to build

okay, litte update… I guess that we are really close :smiley:

patching sources
applying patch /nix/store/hnkxp053djcywdq2c5h20v34pg1ygc0f-s.patch
patching file setup.py
autoreconfPhase
autoreconf: export WARNINGS=
autoreconf: error: 'configure.ac' is required
error: builder for '/nix/store/8gq727i8c8chrvb66gvndbmsf9cn50hp-python3.9-nfstream-6.3.5.drv' failed with exit code 1;
       last 10 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/pm457am0szzch8c8glmcdd59bzq7bb4n-source
       > source root is source
       > setting SOURCE_DATE_EPOCH to timestamp 315619200 of file source/tests/zoom.pcap
       > patching sources
       > applying patch /nix/store/hnkxp053djcywdq2c5h20v34pg1ygc0f-s.patch
       > patching file setup.py
       > autoreconfPhase
       > autoreconf: export WARNINGS=
       > autoreconf: error: 'configure.ac' is required
       For full logs, run 'nix log /nix/store/8gq727i8c8chrvb66gvndbmsf9cn50hp-python3.9-nfstream-6.3.5.drv'.

Maybe i can get it right without using autoreconfHook, but using autoconf and specify a configurePhase?

Either they don’t intend for you to do a normal autoconf workflow, or their sdist is missing some of the build files.

I would check the logic of the setup.py to see what it intended for.

But, my guess is that you will want:

  nativeBuildInputs = [ autoconf automake libtool pkg-config flex bison gettext libjson ];

One thing to note with buildPythonPackage is that it by default has strictDeps = true; which means that if you want a command from a package to be available, it needs to go into nativeBuildInputs, or you can set strictDeps = false;, and then commands from buildInputs will also be available

i guess that the problem here is this:

subprocess.check_call([platform_compiler, '-I/usr/local/include/ndpi', '-shared', '-o',
                            'nfstream/engine/engine_cc.so',
                            '-g', '-fPIC', '-DPIC', '-O2', '-Wall', 'nfstream/engine/engine_cc.c',

ndpi build successfully but nfstream doesn’t find /usr/local/include/ndpi

nfstream/engine/engine_cc.c:16:10: fatal error: ndpi_api.h: No such file or directory
   16 | #include <ndpi_api.h>
      |          ^~~~~~~~~~~~

According to them:

git clone --branch dev https://github.com/ntop/nDPI.git
cd nDPI
./autogen.sh
./configure
make
sudo mkdir /usr/local/include/ndpi
sudo cp -a src/include/. /usr/local/include/ndpi/
sudo cp example/ndpiReader /usr/local/bin/ndpiReader
sudo cp src/lib/libndpi.a /usr/local/lib/libndpi.a
cd ..
rm -rf nDPI

Should i patch this in some way?

see nfstream: init at 6.3.5 by heph2 · Pull Request #162743 · NixOS/nixpkgs · GitHub