poetry2nix icon indicating copy to clipboard operation
poetry2nix copied to clipboard

exceptiongroup 1.0.0rc8 missing flit_scm module

Open l0b0 opened this issue 2 years ago • 5 comments

Describe the issue

Building the below (from this project) using latest nixpkgs results in the following error:

ModuleNotFoundError: No module named 'flit_scm'

Additional context

l0b0 avatar Aug 09 '22 19:08 l0b0

I just ran into this myself. It looks like that flit isn't being included here by default.

I am like an intermediate nix user, but ended up getting around it by passing extraPackages to poetry2nix.mkPoetryEnv like so:

  outputs = { self, nixpkgs, flake-utils, poetry2nix }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = import nixpkgs {
          inherit system;
          config = { allowBroken = true; };
          overlays = [ poetry2nix.overlay ];
        };
      in {
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ pkgs.bashInteractive ];
          buildInputs = with pkgs; [
            # [SNIP]
            (pkgs.poetry2nix.mkPoetryEnv {
              projectDir = ./.;
              preferWheels = true;
              extraPackages = (ps: [ pythonPackages.flit ]); # <------
            })
          ];
        };
      })

dmizelle avatar Aug 18 '22 21:08 dmizelle

I've tried two similar things but it still fails:

extraPackages = (ps: [ pkgs.python310Packages.flit ]);

and

exceptiongroup = super.exceptiongroup.overridePythonAttrs (
  old: {
    nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ self.flit ];
  }
);

l0b0 avatar Aug 23 '22 17:08 l0b0

It looks like what's missing is deciphering what flitBuildHook evaluates to, and including that. I thought this required running tools/find-build-systems:

  1. Clone repo
  2. cd into repo
  3. nix-shell
  4. cd tools
  5. nix-build
  6. result/bin/python ./find-build-systems.py build-systems.json

However, the resulting file just seems to be a copy of the build-systems.json in the repo, so I'm out of ideas.

l0b0 avatar Sep 21 '22 12:09 l0b0

I solved this issue with the following overrides:

final.poetry2nix.overrides.withDefaults (self: super: {
  flit-scm = self.callPackage ./flit-scm.nix { };
  exceptiongroup = super.exceptiongroup.overridePythonAttrs (old: {
    nativeBuildInputs = old.nativeBuildInputs ++ [
      self.flit-scm
    ];
  });
})

where flit-scm.nix is

{ buildPythonPackage
, fetchPypi
, flit-core
, flitBuildHook
, setuptools-scm
}:
buildPythonPackage {
  pname = "flit-scm";
  version = "1.7.0";
  format = "flit";
  src = fetchPypi {
    pname = "flit_scm";
    version = "1.7.0";
    sha256 = "961bd6fb24f31bba75333c234145fff88e6de0a90fc0f7e5e7c79deca69f6bb2";
  };
  nativeBuildInputs = [
    flit-core
    flitBuildHook
    setuptools-scm
  ];
  pythonImportsCheck = [ "flit_scm" ];
}

considerate avatar Oct 07 '22 09:10 considerate

I guess flit-scm should be published to nixpkgs and then added as known build engines. Isn't it?

yajo avatar Oct 14 '22 11:10 yajo

Ran into similar problem trying to bump cattrs 22.2.0.

Jimlinz avatar Oct 21 '22 00:10 Jimlinz

@yajo flit-scm is not in 22.05 yet, but a PR to introduce it to the master branch was added just 11 hours ago. Not sure when/if it will be promoted to stable.

l0b0 avatar Oct 26 '22 03:10 l0b0

Seems to be merged now.

yajo avatar Oct 26 '22 07:10 yajo

Seems to be merged now.

I also backported it to 22.05.

adisbladis avatar Oct 26 '22 09:10 adisbladis

Thanks all, this is fixed in master!

cpcloud avatar Nov 02 '22 13:11 cpcloud