Overriding stdenv to change gcc in buildPythonPackage

If I have a python package derivation like

{ buildPythonPackage
, fetchPypi
...
}:
buildPythonPackage {
    pname = ...;
}

Which I’m trying to use it in a big environment python38.withPackages(ps: with ps; [ numpy my-package-from-above ... ])

Is it possible to override the stdenv just for that package? Specifically I’d like to compile this package with a different version of gcc while not messing with the other packages in the environment?

Should be able to override the version on the root python interpreter, but may run into with python packages inheriting stdenv from the root pkgs.

too be completely safe, you need to to do an overlay with:

final: prev {
  stdenv = gccXStdenv;
}

however, you will probably have to build everything from stdenv, which will take a while.

Or some how override the pkgs which gets passed when creating the package set might also be another option.