How to nix-ify python packages with circular dependencies?

I’ve been working towards packaging jax and jaxlib. I have it mostly working but as I try to run the test suite, I’ve been discovering a set of circular dependencies: jax test suite -> optax -> chex -> jax. I guess that pip just doesn’t really care, downloads all of them, and yolo’s it?

But ofc nix is not happy about this particular scenario. Is there a way to package all these guys? How does nix work around this? I’d like to be able to run as much of the test suite as possible…

Is there a way I could sneakily get chex to “forget” about its dependency on jax? Then code could just fail at import-time.

Check out how attrs and uvicorn handle their tests.

You can always disable tests, and then add a passthru.pkgWithTests which runs the test suite with circular dependencies.

we do something similar for hypothesis, which has a dependency on pytest, which has a dependency on hypothesis.

2 Likes

Thanks for all the pointers guys! I ended up finding that there were only a small number of “experimental” tests relying on this circular dependency hell, so I opted to only run the main test suite for now.