From 09484b3b3712653c9365da2366da18a9dc4cf99e Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 20 Mar 2024 10:28:52 +0100 Subject: [PATCH 1/3] python311Packages.tree-sitter: 0.20.4 -> 0.21.1 Changelog: https://github.com/tree-sitter/py-tree-sitter/releases/tag/v0.21.1 --- .../python-modules/tree-sitter/default.nix | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/pkgs/development/python-modules/tree-sitter/default.nix b/pkgs/development/python-modules/tree-sitter/default.nix index cd572618a2fd..6843791f89fc 100644 --- a/pkgs/development/python-modules/tree-sitter/default.nix +++ b/pkgs/development/python-modules/tree-sitter/default.nix @@ -1,37 +1,42 @@ { lib , buildPythonPackage -, fetchPypi +, fetchFromGitHub , pytestCheckHook , pythonOlder , setuptools -, wheel }: buildPythonPackage rec { pname = "tree-sitter"; - version = "0.20.4"; - format = "pyproject"; + version = "0.21.1"; + pyproject = true; disabled = pythonOlder "3.7"; - src = fetchPypi { - pname = "tree_sitter"; - inherit version; - hash = "sha256-atsSPi8+VjmbvyNZkkYzyILMQO6DRIhSALygki9xO+U="; + src = fetchFromGitHub { + owner = "tree-sitter"; + repo = "py-tree-sitter"; + rev = "refs/tags/v${version}"; + hash = "sha256-U4ZdU0lxjZO/y0q20bG5CLKipnfpaxzV3AFR6fGS7m4="; + fetchSubmodules = true; }; nativeBuildInputs = [ setuptools - wheel ]; - # PyPI tarball doesn't contains tests and source has additional requirements - doCheck = false; + nativeCheckInputs = [ + pytestCheckHook + ]; pythonImportsCheck = [ "tree_sitter" ]; + preCheck = '' + rm -r tree_sitter + ''; + meta = with lib; { description = "Python bindings to the Tree-sitter parsing library"; homepage = "https://github.com/tree-sitter/py-tree-sitter"; From b2e6139e42ae065699ba8fb22371b742a2f7e816 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 20 Mar 2024 10:40:41 +0100 Subject: [PATCH 2/3] python311Packages.py-tree-sitter: remove Was merged with tree-sitter --- .../python-modules/py-tree-sitter/default.nix | 34 ------------------- pkgs/top-level/python-aliases.nix | 1 + pkgs/top-level/python-packages.nix | 2 -- 3 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 pkgs/development/python-modules/py-tree-sitter/default.nix diff --git a/pkgs/development/python-modules/py-tree-sitter/default.nix b/pkgs/development/python-modules/py-tree-sitter/default.nix deleted file mode 100644 index 9358a0fbca88..000000000000 --- a/pkgs/development/python-modules/py-tree-sitter/default.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ lib -, stdenv -, buildPythonPackage -, fetchFromGitHub -, setuptools -}: - -buildPythonPackage rec { - pname = "py-tree-sitter"; - version = "0.20.4"; - format = "pyproject"; - - src = fetchFromGitHub { - owner = "tree-sitter"; - repo = "py-tree-sitter"; - rev = "refs/tags/v${version}"; - hash = "sha256-R97WcsHQMcuEOCg/QQ9YbGTRD30G9PRv0xAbxuoFyC4="; - fetchSubmodules = true; - }; - - nativeBuildInputs = [ - setuptools - ]; - - pythonImportsCheck = [ "tree_sitter" ]; - - meta = with lib; { - homepage = "https://github.com/tree-sitter/py-tree-sitter"; - description = "Python bindings for tree-sitter"; - license = licenses.mit; - maintainers = with maintainers; [ siraben ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/top-level/python-aliases.nix b/pkgs/top-level/python-aliases.nix index 96fccb3f3ecc..fed4bac69f27 100644 --- a/pkgs/top-level/python-aliases.nix +++ b/pkgs/top-level/python-aliases.nix @@ -501,6 +501,7 @@ mapAliases ({ thumborPexif = throw "thumborPexif has been removed, because it was unused."; # added 2024-01-07 torrent_parser = torrent-parser; # added 2023-11-04 transip = throw "transip has been removed because it is no longer maintained. TransIP SOAP V5 API was marked as deprecated"; # added 2023-02-27 + py-tree-sitter = throw "Was merged with tree-sitter."; # added 2024-03-20 trezor_agent = trezor-agent; # Added 2024-01-07 tumpa = throw "tumpa was promoted to a top-level attribute"; # added 2022-11-19 tvdb_api = tvdb-api; # added 2023-10-20 diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 1a37a8282e82..35e5871a4984 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10299,8 +10299,6 @@ self: super: with self; { py-tes = callPackage ../development/python-modules/py-tes { }; - py-tree-sitter = callPackage ../development/python-modules/py-tree-sitter { }; - py-ubjson = callPackage ../development/python-modules/py-ubjson { }; py-zabbix = callPackage ../development/python-modules/py-zabbix { }; From 62ef647346faf34e7f48c32009a966893a56db39 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Wed, 20 Mar 2024 12:41:44 +0100 Subject: [PATCH 3/3] python312Packages.tree-sitter: add patch to replace distutils --- .../development/python-modules/tree-sitter/default.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkgs/development/python-modules/tree-sitter/default.nix b/pkgs/development/python-modules/tree-sitter/default.nix index 6843791f89fc..039b9ce21cea 100644 --- a/pkgs/development/python-modules/tree-sitter/default.nix +++ b/pkgs/development/python-modules/tree-sitter/default.nix @@ -1,6 +1,7 @@ { lib , buildPythonPackage , fetchFromGitHub +, fetchpatch , pytestCheckHook , pythonOlder , setuptools @@ -21,6 +22,15 @@ buildPythonPackage rec { fetchSubmodules = true; }; + patches = [ + # Replace distutils with setuptools, https://github.com/tree-sitter/py-tree-sitter/pull/214 + (fetchpatch { + name = "replace-distutils.patch"; + url = "https://github.com/tree-sitter/py-tree-sitter/commit/80d3cae493c4a47e49cc1d2ebab0a8eaf7617825.patch"; + hash = "sha256-00coI8/COpYMiSflAECwh6yJCMJj/ucFEn18Npj2g+Q="; + }) + ]; + nativeBuildInputs = [ setuptools ];