Non mandatory test with pytest

Hello
Sorry if this may be an obvious question but I’m still new with nix.

I’m trying to build a python package with nix, uproot, using its expression from nixpkgs.

The package uses pytest in the check phase.
One of the tests requires the package “ROOT” (to test against the original implementation), but since uproot itself does not require it, it’s a non mandatory test, using importorskip.

Uproot builds fine, but when reaching the check phase it fails due to the ROOT test being skipped.

How can I solve this?

Thanks in advance

You have two options:

1 - Make a package for ROOT and add it to checkInputs in your uproot package
2 - Disable the failing tests in uproot. The way do this depends on how the tests are implemented in that package. Alternatively, you may disable all the tests in uproot by adding doCheck = false to your package.

Building ROOT is not ideal because ROOT takes a while (hours) to build, which is probably why it is not an input in nixpkgs.
I think I can try using an overlay to override the doCheck attribute.

I asked because I was using uproot from nixpkgs and I feared I was doing something wrong.
Is it normal for a derivation to fail because of a skipped test or is it something about my configuration that makes it so?

No, that’s not normal and shouldn’t happen.
It was fixed with pythonPackages.uproot: 3.4.19 -> 3.7.0 · NixOS/nixpkgs@3c2fc5f · GitHub
So you could either build from that nixpkgs tree or wait a few days until it makes it into unstable.

Unfortunately this happens a lot, especially in the python ecosystem, where a maintainer will leave off dependencies for their tests. I usually just disable the tests if they’re missing dependencies not defined in the package’s setup.py.

For context:
Original PR: pythonPackages.uproot: 3.4.19 -> 3.7.0 by jonringer · Pull Request #63490 · NixOS/nixpkgs · GitHub
Python2 build was fixed here: Merge pull request #63490 from jonringer/bump_uproot · NixOS/nixpkgs@7cb82ca · GitHub

To answer your original question, you can checkout nixpkgs from a certain commit (like the current master), then pull out the package that you need and add it to an overlay.

checking out nixpkgs at a commit: [Nix-dev] Best way to install nix packages from github repo
adding a python package to an overlay: Nixpkgs 23.11 manual | Nix & NixOS

unfortunately i don’t think you can compose many python overlays at this time, but this should help

I see, so it was a matter of being in an older nixpkgs commit.

I had actually managed to add an overlay to skip the test, but I guess I can do a channel upgrade, shouldn’t matter much with my setup.

I think leaving root out was the right choice here, given how long it takes to build.
Thanks for disabling the tests.

Just tested it and it works.

I don’t think we need to add ROOT for uproot tests. The input root files for reading are already generated and saved in the repo: https://github.com/scikit-hep/uproot/tree/master/tests/samples
Perhaps in the future, once they implement writing files, it would need ROOT to validate the output.

I think that’s what they were actually doing, the failing test was this one

1 Like

No we don’t. But two of the tests were failing because they tried to fetch files from the network which is disallowed in (sandboxed) builds. That’s why those two are now disabled and the rest successfully run through.

1 Like