Closed zhenhua-wang closed 1 month ago
Hey, sorry for the late response.
I think I have found the issue, if you specify the :program
using an absolute path instead of an relative like the default configuration sys.path
contains the expected file path. This is an debugy
bug, one would expect cwd
to affect the value of sys.path
.
Thanks for checking. Sorry, I didn't describe my situation clearly. I have a test.py
in a subfolder called test. When I run dape on this test.py
, Sys.path
points to the test subfolder. Since the test file imports functions from lib/lib.py
, it needs to be run from the root folder to correctly resolve the path. My current fix for this is to add os.getcwd()
to Sys.Path
manually at the beginning of the test file. I wonder if there is a way in dape
to make it point to the root folder as well?
My project structure looks like this.
root/
lib/
lib.py
test/
test.py
main.py
Ah I see, this has nothing to do with dape
but with how sys.path
works, AFAIK cwd
has no affect on sys.path
.
PYTONPATH
like debugpy :program "main.py" :env (:PYTHONPATH dape-cwd)
to add root
folder to sys.path
site-packages
with pip
and editable install see linkdebugpy-module :module "unittest" :args ["test.test"]
(make sure that root/test/__init__.py
exists)Thanks for the explain! Your first solution works great for me.
Thank you for this very useful package!
I find this behavior when dape is started from an sub-folder in a project. Although
cwd
andcommand-cwd
point to the project root, thesys.path
variable in python does not include the project root, instead it has the current directory (the subfolder). I wonder if I change this and include the project root insys.path
for dape repl?