How do you make a working nix shell with python 3.7, with numpy etc.?

I know python 3.7 is outdated, but I’m in a uni course where we have to upload our python homework to a server which will grade it. That server is running python 3.7 and it will often give me feedback that a function or a parameter to a function doesn’t exist, as while coding locally I’m using python 3.12 (because, understandably, python 3.7 was removed from nix packages)

I would rather code in 3.7 so that I can get those errors locally and not have to hunt for backwards compatible functions one at a time when handing the homework in repeatedly…

I thought to myself “That’s easy! I’ll just use flakes!” so I grabbed the nixpkgs commit which added python 3.7.16, added it to my flake inputs and used it as I would use nixpkgs.

inputs = {
  nixpkgs-python3-7-16.url = "github:NixOS/nixpkgs/10bab2150ce14073a97d65703227550205e193d8";
}

With this, I can use python 3.7 quite effortlessly in the shell via nix develop or direnv. (flakes are awesome aren’t they?)

However, problems arise when I try to add python packages/libraries. I need numpy, scipy, matplotlib and itertools. In current nixpkgs all I need to do is:

pkgs.python3.withPackages (
  p: with p; [
    numpy
    scipy
    matplotlib
    more-itertools
  ]
);

If I use nixpkgs-python3-7-16 (and python37 in place of python3), it will start compiling the packages locally (which I don’t mind, with direnv I can do that just once and have them available for the rest of the semester), but it will run into issues. One of the issues is networkx which will complain that it is incompatible with python 3.7…

So then I looked for a commit which added networkx version which is compatible with python 3.7, but that doesn’t work and will still complain…

I really don’t have time to debug this because every time I change the commit or change the way I add these packages to the environment, I get long compile times. Can anyone please point me in the right direction for getting it working?