From 92917a175f48d2b9146075410f309100e26db73e Mon Sep 17 00:00:00 2001 From: David Douard <david.douard@sdfa3.org> Date: Tue, 20 Feb 2024 14:48:14 +0100 Subject: [PATCH] setup: fix editable install Add missing links in editable install to parser source files generated by tree-sitter. Since the Translator can build the extension on the fly, this should work ok for strict editable install. Note that this also fixes the building of the sdist package, including generated files to build the tree-sitter parser extension. Thanks to lunar for this solution. --- setup.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/setup.py b/setup.py index 26cf606..5b11860 100755 --- a/setup.py +++ b/setup.py @@ -100,6 +100,27 @@ class custom_build(build_py): else: self.run_command("ts_build") + def get_output_mapping(self): + output_mapping = super().get_output_mapping() + for fname in ( + "src/grammar.json", + "src/tree_sitter/parser.h", + "src/parser.c", + "src/node-types.json", + ): + output_mapping[f"{self.build_lib}/{fname}"] = fname + return output_mapping + + def get_source_files(self): + source_files = super().get_source_files() + source_files.extend( + [ + "swh/search/query_language/grammar.js", + "swh/search/query_language/token.js", + ] + ) + return source_files + class custom_sdist(sdist): def make_release_tree(self, base_dir, files): -- GitLab