Hi there, when I run `./pants check {my_file.py}` ...
# general
p
Hi there, when I run
./pants check {my_file.py}
I see the "pants-sandbox-xxx" is not a valid Python package name error. I wonder if anyone has seen this issue and what could be the root cause? I am using python 3.9, mypy==1.4.1. Thanks!
PANTS_PYTHON_INTERPRETER_CONSTRAINTS=['==3.9.*'] on MacOS_ARM64
11:17:59.03 [WARN] DEPRECATED: Running Pants in an external Python interpreter via a
./pants` script is scheduled to be removed in version 2.18.0.dev0.`
11:18:10.08 [INFO] Completed: Building mypy.pex from mypy.lock
11:18:23.49 [ERROR] Completed: Typecheck using MyPy - mypy - mypy failed (exit code 2).
pants-sandbox-D4V2qW is not a valid Python package name
āœ• mypy failed.
c
taking a wild guess here: you may have your python source in the repo root? and when pants runs
mypy
with those sources then in the root of the sandbox, the sandbox will be seen as the package name.
e
Definitely go down the standard debug path and throw in a
--keep-sandboxes=on_failure
.
@curved-television-6568’s guess can be confirmed or denied quickly as well as other ideas make themselves apparent by inspecting the sandbox +
__run.sh
.
p
Thanks! I applied the --keep-sandboxes=on_failures option. The extra console log I see is
13:12:57.26 [INFO] Preserving local process execution dir /private/var/folders/n_/gd3n_80j2hn188krq4qj_2880000gn/T/pants-sandbox-SoUXMA for Run MyPy on 1 file.
e
Yup; so cd
/private/var/folders/n_/gd3n_80j2hn188krq4qj_2880000gn/T/pants-sandbox-SoUXMA
and have a look around. What do you see? What is in
__run.sh
? What happens when you run
./__run.sh
?
That is the sandbox directory where Pants runs MyPy; so it should be instructive to see what is laid out there.
The
__run.sh
script is not what Pants runs, but it is a generally good simulation of what the Rust engine code executes; so it can be useful for debugging.
p
Thanks for sharing the knowledge! Running __run.sh generates the same error "pants-sandbox-SoUXMA is not a valid Python package name".
e
Ok, great. You should be able to figure it out from there. You have everything you need in the sandbox to debug.
šŸ‘ 1