gentle-flower-25372
10/02/2024, 7:10 PMpants run and the script outputs a file. That file is being dropped in the sandbox instead of a directory in the monorepo. Is there a known pattern for calling scripts with pants run that write files to the filesystem in a standard/normal place (not the sandbox)? In my case we're generating api client using openapi.fast-nail-55400
10/02/2024, 7:22 PMrun_shell_command target type (https://www.pantsbuild.org/stable/reference/targets/run_shell_command) be useful? Your Python script's target would be an execution_dependencies for the run_shell_command and then you could just copy the captured output into the appropriate part of the repository.fast-nail-55400
10/02/2024, 7:22 PMcp {chroot}/some/output.txt dest/path/output.txtfast-nail-55400
10/02/2024, 7:23 PMpants run the run_shell_command target instead of the original Python target.fast-nail-55400
10/02/2024, 7:25 PMrun_shell_command but the use of {chroot} is relevant:https://github.com/pantsbuild/example-adhoc/blob/main/javascript/BUILDgentle-flower-25372
10/02/2024, 7:29 PM{chroot} is a good thing to know. I think with this knowledge I should be able to get something working.broad-processor-92400
10/03/2024, 12:49 AMpants run, while the Python files used for executing will be in the chroot. Are you using __file__ or similar to locate the output file relative to a source file? If so, changing that might be a good approachgentle-flower-25372
10/03/2024, 12:53 AM__file__ to create the file relative to the script.broad-processor-92400
10/03/2024, 5:12 PMbroad-processor-92400
10/03/2024, 5:13 PMgentle-flower-25372
10/03/2024, 5:16 PMbreezy-twilight-65275
10/04/2024, 7:56 AMshell_command with a python_source wrapped in an adhoc_tool (because python_source does not support output_files directly).
Now I am wondering whether the {chroot} substitution is documented somewhere (would think about a PR otherwise) and whether there is a similar way to inject the build root path into the cp command. I know that the working dir will be the directory where the BUILD file is located and I could work relative to that. However I think injecting build root would make it a bit easier to comprehend the file reference.gentle-flower-25372
10/04/2024, 6:09 PMpants run //my/script.py -- --output my/path.txt