about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/ninja
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/python-modules/ninja')
-rw-r--r--nixpkgs/pkgs/development/python-modules/ninja/default.nix71
-rw-r--r--nixpkgs/pkgs/development/python-modules/ninja/no-download.patch10
-rw-r--r--nixpkgs/pkgs/development/python-modules/ninja/stub/ninja/__init__.py11
-rw-r--r--nixpkgs/pkgs/development/python-modules/ninja/stub/pyproject.toml11
4 files changed, 45 insertions, 58 deletions
diff --git a/nixpkgs/pkgs/development/python-modules/ninja/default.nix b/nixpkgs/pkgs/development/python-modules/ninja/default.nix
index d3ab12c29a55..0ff678569302 100644
--- a/nixpkgs/pkgs/development/python-modules/ninja/default.nix
+++ b/nixpkgs/pkgs/development/python-modules/ninja/default.nix
@@ -1,72 +1,47 @@
 { lib
 , buildPythonPackage
-, fetchFromGitHub
-, fetchurl
-, cmake
-, setuptools-scm
-, scikit-build
-, pytestCheckHook
-, pytest-virtualenv
+, flit-core
+, ninja
 }:
-let
-  # these must match NinjaUrls.cmake
-  ninja_src_url = "https://github.com/Kitware/ninja/archive/v1.11.1.g95dee.kitware.jobserver-1.tar.gz";
-  ninja_src_sha256 = "7ba84551f5b315b4270dc7c51adef5dff83a2154a3665a6c9744245c122dd0db";
-  ninja_src = fetchurl {
-    url = ninja_src_url;
-    sha256 = ninja_src_sha256;
-  };
-in
+
 buildPythonPackage rec {
   pname = "ninja";
-  version = "1.11.1";
+  inherit (ninja) version;
   format = "pyproject";
 
-  src = fetchFromGitHub {
-    owner = "scikit-build";
-    repo = "ninja-python-distributions";
-    rev = version;
-    hash = "sha256-scCYsSEyN+u3qZhNhWYqHpJCl+JVJJbKz+T34gOXGJM=";
-  };
-  patches = [
-    # make sure cmake doesn't try to download the ninja sources
-    ./no-download.patch
-  ];
+  src = ./stub;
 
-  inherit ninja_src;
   postUnpack = ''
-    # assume that if the hash matches, the source should be fine
-    if ! grep "${ninja_src_sha256}" $sourceRoot/NinjaUrls.cmake; then
-      echo "ninja_src_sha256 doesn't match the hash in NinjaUrls.cmake!"
-      exit 1
-    fi
-    mkdir -p "$sourceRoot/Ninja-src"
-    pushd "$sourceRoot/Ninja-src"
-    tar -xavf ${ninja_src} --strip-components 1
-    popd
-  '';
+    substituteInPlace "$sourceRoot/pyproject.toml" \
+      --subst-var version
 
-  postPatch = ''
-    sed -i '/cov/d' setup.cfg
+    substituteInPlace "$sourceRoot/ninja/__init__.py" \
+      --subst-var-by BIN_DIR "${ninja}/bin"
   '';
 
-  dontUseCmakeConfigure = true;
+  inherit (ninja) setupHook;
 
   nativeBuildInputs = [
-    setuptools-scm
-    scikit-build
-    cmake
+    flit-core
   ];
 
-  nativeCheckInputs = [
-    pytestCheckHook
-    pytest-virtualenv
+  preBuild = ''
+    cp "${ninja.src}/misc/ninja_syntax.py" ninja/ninja_syntax.py
+  '';
+
+  pythonImportsCheck = [
+    "ninja"
+    "ninja.ninja_syntax"
   ];
 
   meta = with lib; {
     description = "A small build system with a focus on speed";
+    longDescription = ''
+      This is a stub of the ninja package on PyPI that uses the ninja program
+      provided by nixpkgs instead of downloading ninja from the web.
+    '';
     homepage = "https://github.com/scikit-build/ninja-python-distributions";
     license = licenses.asl20;
-    maintainers = with maintainers; [ _999eagle ];
+    maintainers = with maintainers; [ _999eagle tjni ];
   };
 }
diff --git a/nixpkgs/pkgs/development/python-modules/ninja/no-download.patch b/nixpkgs/pkgs/development/python-modules/ninja/no-download.patch
deleted file mode 100644
index 0937a5fde1ea..000000000000
--- a/nixpkgs/pkgs/development/python-modules/ninja/no-download.patch
+++ /dev/null
@@ -1,10 +0,0 @@
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -64,6 +64,7 @@
-   # Download selected source archive
-   ExternalProject_add(download_ninja_source
-     SOURCE_DIR ${Ninja_SOURCE_DIR}
-+    DOWNLOAD_COMMAND ""
-     URL ${${src_archive}_url}
-     URL_HASH SHA256=${${src_archive}_sha256}
-     DOWNLOAD_DIR ${ARCHIVE_DOWNLOAD_DIR}
diff --git a/nixpkgs/pkgs/development/python-modules/ninja/stub/ninja/__init__.py b/nixpkgs/pkgs/development/python-modules/ninja/stub/ninja/__init__.py
new file mode 100644
index 000000000000..fcf70f10ba31
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/ninja/stub/ninja/__init__.py
@@ -0,0 +1,11 @@
+import os
+import subprocess
+import sys
+
+BIN_DIR = '@BIN_DIR@'
+
+def _program(name, args):
+    return subprocess.call([os.path.join(BIN_DIR, name)] + args, close_fds=False)
+
+def ninja():
+    raise SystemExit(_program('ninja', sys.argv[1:]))
diff --git a/nixpkgs/pkgs/development/python-modules/ninja/stub/pyproject.toml b/nixpkgs/pkgs/development/python-modules/ninja/stub/pyproject.toml
new file mode 100644
index 000000000000..0a8a6314288a
--- /dev/null
+++ b/nixpkgs/pkgs/development/python-modules/ninja/stub/pyproject.toml
@@ -0,0 +1,11 @@
+[build-system]
+requires = ["flit_core"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "ninja"
+version = "@version@"
+description = "Ninja is a small build system with a focus on speed"
+
+[project.scripts]
+ninja = "ninja:ninja"