Various Python package fixes after the migration to unittestCheckHook#187778
Various Python package fixes after the migration to unittestCheckHook#187778vcunat merged 2 commits intoNixOS:staging-nextfrom
Conversation
|
I confirm that these two packages were failing and they now succeed with this PR. |
|
@FRidh Do you mind taking a look at |
91df9a2 to
9f659b6
Compare
|
I tried bumping to the latest version, to no avail. Looks like these were probably broken the entire time, it's just that they were never ran until this hook was added (Hydra build, it ran 0 tests). No clue what's going on here, considering it passes in upstream CI, and we run the same command. |
| substituteInPlace setup.py \ | ||
| --replace "wheel>=0.32.0,<0.33.0" "wheel>=0.31.0" | ||
| ''; | ||
| # ModuleNotFoundError: No module named 'cymem.cymem' |
There was a problem hiding this comment.
We should probably improve our check hooks by moving out of the source directory. Following is a work-around, but it works because I am using the absolute path to the source here.
diff --git a/pkgs/development/python-modules/cymem/default.nix b/pkgs/development/python-modules/cymem/default.nix
index 88e25720109..83f0ae05595 100644
--- a/pkgs/development/python-modules/cymem/default.nix
+++ b/pkgs/development/python-modules/cymem/default.nix
@@ -20,12 +20,12 @@ buildPythonPackage rec {
cython
];
- # ModuleNotFoundError: No module named 'cymem.cymem'
- doCheck = false;
-
+ preCheck = ''
+ cd $out
+ '';
checkInputs = [ pytestCheckHook ];
- pytestFlagsArray = [ "cymem" ];
+ pytestFlagsArray = [ "/build/source" ];
meta = with lib; {
description = "Cython memory pool for RAII-style memory management";
There was a problem hiding this comment.
I'm not sure if we can afford to assume /build. At least without sandboxing it won't work, I think.
There was a problem hiding this comment.
@FRidh Why does this fix the issue? Upstream does what we do (execute pytest from the source directory) in CI, and it passes just fine, so I'm confused as to why we need to do that. Note that I've tried with and without the cymem argument, and get the same result.
@vcunat We can't assume it, no, for exactly that reason.
There was a problem hiding this comment.
Absolute path to the root is in some variable defined by nix, for sure, but that might be a bit more complicated to get expanded correctly.
There was a problem hiding this comment.
I think that can be worked around pretty easily (not to say it'll be clean, but it'll work), but I'd like to understand why we have to deviate from upstream (and other packages that use pytest) before implementing it.
There was a problem hiding this comment.
So if I cd into cymem in preCheck, everything works fine (without the cymem argument to pytest).
I just don't understand why this doesn't happen upstream... unless it's because they install the package before running the tests -- which I guess is only required because this is a Cython module (otherwise pytest would fixup sys.path so the sources could be imported).
So since we also install it in the test environment (by adding it to PYTHONPATH), why is moving into that directory required? Clearly the tests are discovered just fine, and the package is installed whether we run the cd or not... so upstream's execution method should work fine, considering we install it just like they do.
Maybe pytest's sys.path modifying is conflicting with our installed copy when we're in the root dir, so it doesn't happen when we go one level down, or something??
why is this so confusing
There was a problem hiding this comment.
@FRidh Why does this fix the issue? Upstream does what we do (execute pytest from the source directory) in CI, and it passes just fine, so I'm confused as to why we need to do that. Note that I've tried with and without the
cymemargument, and get the same result.
That's because they build in place. Bad practice.
python setup.py build_ext --inplace
We need to move out of the directory because Python adds the current working directory to sys.path and so the source version without extension module gets seen and imported first.
Description of changes
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes