Python - ModuleNotFoundError: No module named 'reader'

I’m trying to build yaml-extender which is on PyPi but not in nixpkgs. I have the following flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    yaml-extender = {
      url = "git+https://github.com/AdunSG/yaml-extender";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, yaml-extender }:
    let
      supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
      forEachSystem = nixpkgs.lib.genAttrs supportedSystems;
      nixpkgsFor = forEachSystem (system: import nixpkgs { inherit system; });

    in {
      packages = forEachSystem (system:
        let pkgs = nixpkgsFor.${system}; in rec {
          yaml-extender-pkg = pkgs.python3Packages.buildPythonApplication {
            pname = "yaml-extender";
	    version = "0.3.2";
            pyproject = true;
            src = yaml-extender;
            build-system = with pkgs.python3Packages; [ setuptools wheel pyyaml ];
          };

	  default = yaml-extender-pkg;
      });

    }; # outputs
}

It builds fine, but when I try to run it, I get:

$ nix build
$ result/bin/yaml-extender test1.yaml 
Traceback (most recent call last):
  File "/nix/store/gnmi24ldw3n9qyvrbw4z7yrggfwdip6d-yaml-extender-0.3.2/bin/.yaml-extender-wrapped", line 6, in <module>
    from reader.__main__ import main
ModuleNotFoundError: No module named 'reader'

The only reference to reader in the source repo is in pyproject.toml:

[project.scripts]
yaml-extender = "reader.__main__:main"

Is reader provided by a package? If so, how do I figure out which one? I can’t find anything on PyPi or in nixpkgs. Is it some sort of tool that setuptools expects to be present in the environment? I don’t have much Python experience.

This is an unaddressed bug in the library. See: Fixes cli call by Ch3ri0ur · Pull Request #8 · AdunSG/yaml-extender · GitHub

1 Like