Building with python36 but I see it builds python39 and issue overriding numpy

Hello

I am trying to work with a program that I can’t share unfortunately. My teammate are updating it, updating dependencies and so on, but in the meantime since I am not that familiar with Python I decided to give myself a challenge. And it is not going great.


I am importing an old version of the nixpkgs that still has python36. What surprises me is that looking at the logs from nix develop it looks like it is building python39-minimal and I am not sure about why:

{
  description = "A very basic flake";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs?rev=139cadbf1ce28cb6f246a589b9cef49968e76676";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }@inp:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };

        python =
          let
            packageOverrides = self: super:
              { }; in
          pkgs.python36.override { inherit packageOverrides; self = pkgs.python36; };

        devenv = python.withPackages (ps: [
        ]);
      in
      {
        devShell = pkgs.mkShell {
          packages = [
            devenv
          ];
        };
      });
}
$ nix develop
[1/0/94 built] building python3-minimal-3.9.7 (unpackPhase): unpacking source archive /nix/store/xl3cvn2w3d17z4298508g5skrr8la12y-Python-3.9.7.tar.xz

My second point is about numpy, apparently my derivation tries to build a version that does not support python36 but I can’t figure out how to override it properly.

{
  description = "A very basic flake";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs?rev=139cadbf1ce28cb6f246a589b9cef49968e76676";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }@inp:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };

        python =
          let
            packageOverrides = self: super:
              { }; in
          pkgs.python36.override { inherit packageOverrides; self = pkgs.python36; };

        devenv = python.withPackages (ps: [
          ps.numpy
        ]);
      in
      {
        devShell = pkgs.mkShell {
          packages = [
            devenv
          ];
        };
      });
}
$ nix develop
error: numpy-1.21.2 not supported for interpreter python3.6
(use '--show-trace' to show detailed location information)

For example if I want to install pandas with an old version of numpy

{
  description = "A very basic flake";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs?rev=139cadbf1ce28cb6f246a589b9cef49968e76676";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }@inp:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs { inherit system; };

        python =
          let
            packageOverrides = self: super: {
              numpy = super.numpy.overridePythonAttrs (old: rec {
                version = "0.19.5";
                src = super.fetchPypi {
                  pname = "numpy";
                  inherit version;
                  hash = "sha256-JQn+rtpy/OA2deLszSKEuxyttqBzcAil50H+JDHUdCE=";
                };
              });
            };
          in
          pkgs.python36.override { inherit packageOverrides; self = python; };

        devenv = python.withPackages (ps: [
          ps.pandas
        ]);
      in
      {
        devShell = pkgs.mkShell {
          packages = [
            devenv
          ];
        };
      });
}

I still get the error “numpy-1.21.2 not supported for interpreter python3.6”

numpy-0.19-5 is the last one with support for python 3.6 Release v1.19.5 · numpy/numpy · GitHub

You didn’t override disabled of numpy.

I don’t see anything wrong with your overlay but I could also miss something. It could be the case that you are just building the Python used for other build tools. You could try --dry-run to see what else will be build.

1 Like