Building Ninja Python Package - no setup.py

I’m trying to build the Ninja Python package (as required for another task) and I’m having trouble.

Here’s my flake.nix as is at the moment.

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

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

        python = pkgs.python310;

        ninja = python.pkgs.buildPythonPackage {
          pname = "ninja";
          version = "1.11.1";

          src = pkgs.fetchPypi {
            pname = "ninja";
            version = "1.11.1";
            sha256 = "sha256-yDOkfTmy0e7j+cqIb6FYHv1b5gaLgnNKwimWHuh0j5A=";
          };

          nativeBuildInputs = [
            python.pkgs.scikit-build
            python.pkgs.setuptools_scm
            python.pkgs.setuptools
            pkgs.cmake
          ];
        };
    in
    {
      devShells.default = pkgs.mkShell {
        buildTools = [ ninja ];
      };
    }
  );
}

And I’m getting the following error

       last 10 log lines:
       > cmake: enabled parallel installing
       > building
       > Executing setuptoolsBuildPhase
       > Traceback (most recent call last):
       >   File "/build/ninja-1.11.1/build/nix_run_setup", line 8, in <module>
       >     exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
       >   File "/nix/store/412d25bdawy2idxfpnis8vjcm8cz2ag7-python3-3.10.11/lib/python3.10/tokenize.py", line 394, in open
       >     buffer = _builtin_open(filename, 'rb')
       > FileNotFoundError: [Errno 2] No such file or directory: 'setup.py'
       > /nix/store/kk3qbkyrski18j8fwrpd5dgvplbdz7b2-stdenv-linux/setup: line 1594: pop_var_context: head of shell_variables not a function context
       For full logs, run 'nix log /nix/store/5cayih23g2j43kxd9hciwz1hs4sa0drn-python3.10-ninja-1.11.1.drv'.

Any thoughts on what I can do to get this working? Thanks

cmake setup-hook enters the build/ directory. Perhaps you want to disable it altogether with dontUseCmakeConfigure = true;?

You might also wont to use format = "pyproject";.

1 Like

Thanks, I have used that before but apparently I’d completely forgotten!

Now I just need to get through it downloading bits of source code partway through building…