From 6eea7c5a2f6588e1a4ffc30bd950043581177703 Mon Sep 17 00:00:00 2001 From: Florentin Labelle Date: Thu, 15 Jan 2026 16:55:00 +0100 Subject: [PATCH] python: improved local development experience for end to end scenarios --- docs/execute/binaries.md | 2 +- utils/_context/containers.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/execute/binaries.md b/docs/execute/binaries.md index 76f58486dac..50b82afd1ff 100644 --- a/docs/execute/binaries.md +++ b/docs/execute/binaries.md @@ -145,7 +145,7 @@ Use one of the four options: - Add a `python-load-from-s3` file in `binaries`, with a dd-trace-py commit ID or branch inside, the corresponding wheel will be loaded from S3 - Clone the dd-trace-py repo inside `binaries`: `cd binaries && git clone https://github.com/DataDog/dd-trace-py.git` -For fast local development (for `PARAMETRIC` and `INTEGRATION_FRAMEWORKS` scenarios): +For fast local development (for `PARAMETRIC`, `INTEGRATION_FRAMEWORKS`, otel and end-to-end scenarios): - **Prerequisites (for most use cases, a one-time setup)**: Make sure the native extensions are built for the Python version being used by the scenario you are running. For example, the `PARAMETRIC` and `INTEGRATION_FRAMEWORKS` scenarios require Python 3.11.14 from the `python:3.11-slim` image. - If they are not available (for example, if `ddtrace/internal/_encoding.cpython-311-aarch64-linux-gnu.so` does not exist), you will need to build them. - Ensure Docker is running. In `dd-trace-py`, run `scripts/ddtest` to start up a shell which is based off of the `testrunner` image. diff --git a/utils/_context/containers.py b/utils/_context/containers.py index 3cc9d38c523..35b079ae1c6 100644 --- a/utils/_context/containers.py +++ b/utils/_context/containers.py @@ -1002,6 +1002,17 @@ def configure(self, *, host_log_folder: str, replay: bool): except Exception: logger.info("No local dd-trace-js found") + if library == "python": + try: + with open("./binaries/python-load-from-local", encoding="utf-8") as f: + path = f.read().strip(" \r\n") + source = os.path.join(str(Path.cwd()), path) + resolved_path = Path(source).resolve() + self.volumes[str(resolved_path)] = {"bind": "/volumes/dd-trace-py", "mode": "ro"} + self.environment["PYTHONPATH"] = f"{resolved_path!s}/ddtrace/bootstrap:/volumes/dd-trace-py" + except FileNotFoundError: + logger.info("No local dd-trace-py found, do not mount any volume or set any python path") + if library in ("php", "cpp_nginx"): self.enable_core_dumps()