lol

python3.pkgs.ninja-python: replace with a stub implementation

Instead of packaging the upstream package, which downloads Ninja from
the web, we can stub it out to use ninja from nixpkgs.

+42 -57
+22 -47
pkgs/development/python-modules/ninja/default.nix
··· 1 1 { lib 2 2 , buildPythonPackage 3 - , fetchFromGitHub 4 - , fetchurl 5 - , cmake 6 - , setuptools-scm 7 - , scikit-build 8 - , pytestCheckHook 9 - , pytest-virtualenv 3 + , flit-core 4 + , ninja 10 5 }: 11 - let 12 - # these must match NinjaUrls.cmake 13 - ninja_src_url = "https://github.com/Kitware/ninja/archive/v1.11.1.g95dee.kitware.jobserver-1.tar.gz"; 14 - ninja_src_sha256 = "7ba84551f5b315b4270dc7c51adef5dff83a2154a3665a6c9744245c122dd0db"; 15 - ninja_src = fetchurl { 16 - url = ninja_src_url; 17 - sha256 = ninja_src_sha256; 18 - }; 19 - in 6 + 20 7 buildPythonPackage rec { 21 8 pname = "ninja"; 22 - version = "1.11.1"; 9 + inherit (ninja) version; 23 10 format = "pyproject"; 24 11 25 - src = fetchFromGitHub { 26 - owner = "scikit-build"; 27 - repo = "ninja-python-distributions"; 28 - rev = version; 29 - hash = "sha256-scCYsSEyN+u3qZhNhWYqHpJCl+JVJJbKz+T34gOXGJM="; 30 - }; 31 - patches = [ 32 - # make sure cmake doesn't try to download the ninja sources 33 - ./no-download.patch 34 - ]; 12 + src = ./stub; 35 13 36 - inherit ninja_src; 37 14 postUnpack = '' 38 - # assume that if the hash matches, the source should be fine 39 - if ! grep "${ninja_src_sha256}" $sourceRoot/NinjaUrls.cmake; then 40 - echo "ninja_src_sha256 doesn't match the hash in NinjaUrls.cmake!" 41 - exit 1 42 - fi 43 - mkdir -p "$sourceRoot/Ninja-src" 44 - pushd "$sourceRoot/Ninja-src" 45 - tar -xavf ${ninja_src} --strip-components 1 46 - popd 47 - ''; 15 + substituteInPlace "$sourceRoot/pyproject.toml" \ 16 + --subst-var version 48 17 49 - postPatch = '' 50 - sed -i '/cov/d' setup.cfg 18 + substituteInPlace "$sourceRoot/ninja/__init__.py" \ 19 + --subst-var-by BIN_DIR "${ninja}/bin" 51 20 ''; 52 21 53 - dontUseCmakeConfigure = true; 22 + inherit (ninja) setupHook; 54 23 55 24 nativeBuildInputs = [ 56 - setuptools-scm 57 - scikit-build 58 - cmake 25 + flit-core 59 26 ]; 60 27 61 - nativeCheckInputs = [ 62 - pytestCheckHook 63 - pytest-virtualenv 28 + preBuild = '' 29 + cp "${ninja.src}/misc/ninja_syntax.py" ninja/ninja_syntax.py 30 + ''; 31 + 32 + pythonImportsCheck = [ 33 + "ninja" 34 + "ninja.ninja_syntax" 64 35 ]; 65 36 66 37 meta = with lib; { 67 38 description = "A small build system with a focus on speed"; 39 + longDescription = '' 40 + This is a stub of the ninja package on PyPI that uses the ninja program 41 + provided by nixpkgs instead of downloading ninja from the web. 42 + ''; 68 43 homepage = "https://github.com/scikit-build/ninja-python-distributions"; 69 44 license = licenses.asl20; 70 45 maintainers = with maintainers; [ _999eagle tjni ];
-10
pkgs/development/python-modules/ninja/no-download.patch
··· 1 - --- a/CMakeLists.txt 2 - +++ b/CMakeLists.txt 3 - @@ -64,6 +64,7 @@ 4 - # Download selected source archive 5 - ExternalProject_add(download_ninja_source 6 - SOURCE_DIR ${Ninja_SOURCE_DIR} 7 - + DOWNLOAD_COMMAND "" 8 - URL ${${src_archive}_url} 9 - URL_HASH SHA256=${${src_archive}_sha256} 10 - DOWNLOAD_DIR ${ARCHIVE_DOWNLOAD_DIR}
+9
pkgs/development/python-modules/ninja/stub/ninja/__init__.py
··· 1 + import os 2 + import subprocess 3 + import sys 4 + 5 + def _program(name, args): 6 + return subprocess.call([os.path.join('@BIN_DIR@', name)] + args, close_fds=False) 7 + 8 + def ninja(): 9 + raise SystemExit(_program('ninja', sys.argv[1:]))
+11
pkgs/development/python-modules/ninja/stub/pyproject.toml
··· 1 + [build-system] 2 + requires = ["flit_core"] 3 + build-backend = "flit_core.buildapi" 4 + 5 + [project] 6 + name = "ninja" 7 + version = "@version@" 8 + description = "Ninja is a small build system with a focus on speed" 9 + 10 + [project.scripts] 11 + ninja = "ninja:ninja"