diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -28,10 +28,6 @@ The tests expect: - `/usr/share/elasticsearch/jdk/bin/java` to exist. - `org.elasticsearch.bootstrap.Elasticsearch` to be in java's classpath. -- The `tree-sitter` module is required in the python venv to launch the yarn build. To install it, run: -```bash -pip install tree-sitter==0.19.0 -``` - Emscripten is required for generating tree-sitter WASM module. The following commands need to be executed for the setup: ```bash cd /opt && git clone https://github.com/emscripten-core/emsdk.git && cd emsdk && \ diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ import os import shutil import subprocess +import sys from setuptools import find_packages, setup from setuptools.command.build_py import build_py @@ -71,7 +72,13 @@ description = "Builds swh_ql.so" def run(self): - subprocess.run([yarn, "build-so"], check=True) + # setup_requires changes sys.path so the build dependencies + # can be imported even though they are in a temporary + # directory (usually `.eggs`). We need to pass this updated sys.path to + # 'yarn build-so', as it invokes a Python script that needs to import + # tree_sitter + env = {**os.environ, "PYTHONPATH": os.pathsep.join(sys.path)} + subprocess.run([yarn, "build-so"], check=True, env=env) print("swh_ql.so file generated") @@ -163,7 +170,7 @@ [swh.cli.subcommands] search=swh.search.cli """, - setup_requires=["setuptools-scm"], + setup_requires=["setuptools-scm", "tree-sitter==0.19.0"], use_scm_version=True, extras_require={"testing": parse_requirements("test")}, include_package_data=True,