From 5745a788892d017e1c4f979915125e8041e1a39b Mon Sep 17 00:00:00 2001 From: Martin Trojer Date: Thu, 23 Jan 2025 06:01:27 -0800 Subject: [PATCH] [python] make sure project-root is used in buck mode Reviewed By: dulmarod Differential Revision: D68555040 fbshipit-source-id: e2ef220014ed3bd43f67e6c19f8cd1328b975c44 --- infer/src/integration/Python.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/infer/src/integration/Python.ml b/infer/src/integration/Python.ml index df04fa6609..a40bbc4c4a 100644 --- a/infer/src/integration/Python.ml +++ b/infer/src/integration/Python.ml @@ -110,7 +110,14 @@ let dump_textual_file ~version pyc module_ = let process_file ~is_binary file = let open IResult.Let_syntax in - let sourcefile = Textual.SourceFile.create file in + let sourcefile = + let file' = + (* if we are in buck-mode, we need to use absolute paths in order for Config.project_root + to be properly applied in SourceFile.create *) + if Config.buck then Utils.filename_to_absolute ~root:Config.buck2_root file else file + in + Textual.SourceFile.create file' + in let* code = FFI.from_file ~is_binary file |> Result.map_error ~f:Error.ffi in let* pyir = PyIR.mk ~debug:false code |> Result.map_error ~f:Error.ir in let textual = PyIR2Textual.mk_module pyir in