Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to modify the pydevd_file_utils.PATHS_FROM_ECLIPSE_TO_PYTHON value without having to modify that file?

I am using the pydev plugin to debug a remote application.

This (remote) application has a structure of files that differs from the structure where my Eclipse is running. This leads to problems when I set the breakpoints from the Eclipse IDE because the pydev debugger server cannot match the absolute path of the file with the file on the remote application and hence the breakpoint isn´t hit.

I dont want to hardcode the pydevd_file_utils.PATHS_FROM_ECLIPSE_TO_PYTHON constant to enable filepath translations.

Do you know some way to modify this value without changing the file?

Thanks!

like image 524
John Avatar asked Oct 26 '25 13:10

John


1 Answers

There are 2 ways of setting the path translation:

  1. Use an environment variable such as PATHS_FROM_ECLIPSE_TO_PYTHON that maps the paths from the client to the server side.

The value is a json string with a list(list(str, str)) such that:

PATHS_FROM_ECLIPSE_TO_PYTHON=[["c:/local/path", "/path/in/server"]]

Note that you may set the environment variable in any place you'd like (such as the Environment tab in the Python interpreter preferences page, in the OS itself, in the launch config, etc).

  1. Use the pydevd API to set the tracing at runtime from the python process:
from pydevd_file_utils import setup_client_server_paths

MY_PATHS_FROM_ECLIPSE_TO_PYTHON = [
    ('/home/user/local-project', '/remote/path/to/project'),
]
setup_client_server_paths(MY_PATHS_FROM_ECLIPSE_TO_PYTHON)

# At this point we could connect to the remote debugger client with:
import pydevd
pydevd.settrace("10.0.0.12")

See: https://www.pydev.org/manual_adv_remote_debugger.html for more info on the Remote Debugging.

Note: the mapping set in Window > Preferences select PyDev > Debug > Source Locator doesn't really map to that environment variable nor the actual debugger mapping (that's a separate translation that only translates paths which are found on Eclipse locally and it's not really passed on to the debugger to hit breakpoints remotely).

like image 142
frost-nzcr4 Avatar answered Oct 29 '25 03:10

frost-nzcr4