Skip to content

Commit

Permalink
fix comments and remove unneeded logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamYoblick committed Jul 26, 2024
1 parent 1245e8e commit aaab993
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/debugpy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# for license information.

import sys
import os

if __name__ == "__main__":

Expand All @@ -29,10 +28,17 @@
# -----
#
# In the third case, running 'python -m debugpy' will not work because the module is not installed
# in any environment. Running 'python <path_to_debugpy>' will work, just like the second case.
# But running 'debugpy' will not work because even though the entry point is defined,
# that path is not in sys.path, so 'import debugpy' will fail. So just like in the second case,
# we need to modify sys.path[0].
# in any environment. Running 'python <install_dir>/debugpy' will work, just like the second case.
# But running the entry point will not work because python doesn't know where to find the debugpy module.
#
# In this case, no changes to sys.path are required. You just have to do the following before calling
# the entry point:
# 1. Add <install_dir> to PYTHONPATH.
# On Windows, this is set PYTHONPATH=%PYTHONPATH%;<install_dir>
# 2. Add <install_dir>/bin to PATH. (OPTIONAL)
# On Windows, this is set PATH=%PATH%;<install_dir>\bin
# 3. Run the entry point from a command prompt
# On Windows, this is <install_dir>\bin\debugpy.exe, or just 'debugpy' if you did the previous step.
#
# -----
#
Expand All @@ -55,15 +61,8 @@
# or its submodules will resolve accordingly.
if "debugpy" not in sys.modules:

# if the user has specified a path to the debugpy module, replace sys.path[0] with
# the specified path. Otherwise, replace sys.path[0] with the parent directory of debugpy/
debugpy_path = os.environ.get("DEBUGPY_PATH")
if (debugpy_path is not None):
sys.path[0] = debugpy_path
else:
# Do not use dirname() to walk up - this can be a relative path, e.g. ".".
sys.path[0] = sys.path[0] + "/../"

# Do not use dirname() to walk up - this can be a relative path, e.g. ".".
sys.path[0] = sys.path[0] + "/../"
import debugpy # noqa
del sys.path[0]

Expand Down

0 comments on commit aaab993

Please sign in to comment.