lol

pre-commit: 1.21.0 -> 2.4.0

authored by

Konstantin Alekseev and committed by
Jon
49ca8ce7 247b5468

+48 -26
+11 -5
pkgs/development/python-modules/pre-commit/default.nix
··· 6 6 , identify 7 7 , importlib-metadata 8 8 , importlib-resources 9 + , isPy27 9 10 , nodeenv 10 11 , python 11 12 , six ··· 15 16 16 17 buildPythonPackage rec { 17 18 pname = "pre-commit"; 18 - version = "1.21.0"; 19 + version = "2.4.0"; 20 + disabled = isPy27; 19 21 20 22 src = fetchPypi { 21 23 inherit version; 22 24 pname = "pre_commit"; 23 - sha256 = "0l5qg1cw4a0670m96s0ryy5mqz5aslfrrnwpriqgmrnsgdixhj4g"; 25 + sha256 = "1l0lcl3l2544m2k8jlmblfsjn0p2hdxrzzwy646xpvp0rcs2wgkh"; 24 26 }; 25 27 26 28 patches = [ 27 29 ./hook-tmpl-use-the-hardcoded-path-to-pre-commit.patch 30 + ./languages-use-the-hardcoded-path-to-python-binaries.patch 28 31 ]; 29 32 30 33 propagatedBuildInputs = [ ··· 36 39 six 37 40 toml 38 41 virtualenv 39 - importlib-metadata 40 - ] ++ lib.optional (pythonOlder "3.7") importlib-resources 41 - ++ lib.optional (pythonOlder "3.2") futures; 42 + ] ++ lib.optional (pythonOlder "3.8") importlib-metadata 43 + ++ lib.optional (pythonOlder "3.7") importlib-resources; 42 44 43 45 # slow and impure 44 46 doCheck = false; ··· 46 48 preFixup = '' 47 49 substituteInPlace $out/${python.sitePackages}/pre_commit/resources/hook-tmpl \ 48 50 --subst-var-by pre-commit $out 51 + substituteInPlace $out/${python.sitePackages}/pre_commit/languages/python.py \ 52 + --subst-var-by virtualenv ${virtualenv} 53 + substituteInPlace $out/${python.sitePackages}/pre_commit/languages/node.py \ 54 + --subst-var-by nodeenv ${nodeenv} 49 55 ''; 50 56 51 57 meta = with lib; {
+11 -21
pkgs/development/python-modules/pre-commit/hook-tmpl-use-the-hardcoded-path-to-pre-commit.patch
··· 1 - From d9e6999e32112602ec276634cb004eda3ca64ec3 Mon Sep 17 00:00:00 2001 2 - From: "Wael M. Nasreddine" <wael.nasreddine@gmail.com> 3 - Date: Mon, 13 Jan 2020 11:04:58 -0800 4 - Subject: [PATCH] hook-tmpl: use the hardcoded path to pre-commit, if found 5 - 6 - --- 7 - pre_commit/resources/hook-tmpl | 2 ++ 8 - 1 file changed, 2 insertions(+) 9 - 10 1 diff --git a/pre_commit/resources/hook-tmpl b/pre_commit/resources/hook-tmpl 11 - index 213d16e..3a99211 100755 2 + index 299144e..6d12543 100755 12 3 --- a/pre_commit/resources/hook-tmpl 13 4 +++ b/pre_commit/resources/hook-tmpl 14 - @@ -107,6 +107,8 @@ def _exe() -> Tuple[str, ...]: 15 - except OSError: 16 - pass 17 - 18 - + if os.path.isfile('@pre-commit@/bin/pre-commit') and os.access('@pre-commit@/bin/pre-commit', os.X_OK): 19 - + return ('@pre-commit@/bin/pre-commit', 'run') 20 - if distutils.spawn.find_executable('pre-commit'): 21 - return ('pre-commit', 'run') 22 - 23 - -- 24 - 2.23.1 5 + @@ -25,8 +25,8 @@ ARGS.append('--') 6 + ARGS.extend(sys.argv[1:]) 25 7 8 + DNE = '`pre-commit` not found. Did you forget to activate your virtualenv?' 9 + -if os.access(INSTALL_PYTHON, os.X_OK): 10 + - CMD = [INSTALL_PYTHON, '-mpre_commit'] 11 + +if os.access('@pre-commit@/bin/pre-commit', os.X_OK): 12 + + CMD = ['@pre-commit@/bin/pre-commit'] 13 + elif which('pre-commit'): 14 + CMD = ['pre-commit'] 15 + else:
+26
pkgs/development/python-modules/pre-commit/languages-use-the-hardcoded-path-to-python-binaries.patch
··· 1 + diff --git a/pre_commit/languages/node.py b/pre_commit/languages/node.py 2 + index 26f4919..4885ec1 100644 3 + --- a/pre_commit/languages/node.py 4 + +++ b/pre_commit/languages/node.py 5 + @@ -82,7 +82,7 @@ def install_environment( 6 + envdir = fr'\\?\{os.path.normpath(envdir)}' 7 + with clean_path_on_failure(envdir): 8 + cmd = [ 9 + - sys.executable, '-mnodeenv', '--prebuilt', '--clean-src', envdir, 10 + + '@nodeenv@/bin/nodeenv', '--prebuilt', '--clean-src', envdir, 11 + ] 12 + if version != C.DEFAULT: 13 + cmd.extend(['-n', version]) 14 + diff --git a/pre_commit/languages/python.py b/pre_commit/languages/python.py 15 + index e17376e..0c1d2ab 100644 16 + --- a/pre_commit/languages/python.py 17 + +++ b/pre_commit/languages/python.py 18 + @@ -204,7 +204,7 @@ def install_environment( 19 + ) -> None: 20 + envdir = prefix.path(helpers.environment_dir(ENVIRONMENT_DIR, version)) 21 + python = norm_version(version) 22 + - venv_cmd = (sys.executable, '-mvirtualenv', envdir, '-p', python) 23 + + venv_cmd = ('@virtualenv@/bin/virtualenv', envdir, '-p', python) 24 + install_cmd = ('python', '-mpip', 'install', '.', *additional_dependencies) 25 + 26 + with clean_path_on_failure(envdir):