average-sugar-68948
02/16/2023, 4:10 PM--debug-adapter
with a python target in VS Code at Pants version 2.16.0.dev5
. It starts up and connects ok, but in one of my projects it fails on importing a (generated) protobuf module. In another simple project breakpoints simply aren't hit. Both of these things seem to point to the debugger not being aware of the sandboxing. I tried adding run_goal_use_sandbox=False,
to my target to no avail (which maybe wouldn't work with generated protobuf modules anyway?). If I revert to 2.14.0
things seem to work ok. Any ideas to try? @bitter-ability-32190bitter-ability-32190
02/16/2023, 4:15 PMbitter-ability-32190
02/16/2023, 4:16 PMrun_goal_use_sandbox=False
bitter-ability-32190
02/16/2023, 4:16 PMlaunch.json
pathMappings
look like?average-sugar-68948
02/16/2023, 4:22 PMaverage-sugar-68948
02/16/2023, 4:27 PMrun_goal_use_sandbox
or not). Without --debug-adapter
it runs fine, but with it I get an import error not finding generated proto modulesbitter-ability-32190
02/16/2023, 4:30 PMbitter-ability-32190
02/16/2023, 4:30 PMaverage-sugar-68948
02/16/2023, 4:39 PM./pants run --debug-adapter :run
average-sugar-68948
02/16/2023, 4:39 PM2.14.0
but not 2.16.0.dev5
bitter-ability-32190
02/16/2023, 4:40 PMPANTS_SHA=1767af454873dc26c66e3ef89306f733bb9ddcdd ./pants ...
average-sugar-68948
02/16/2023, 4:44 PMbitter-ability-32190
02/16/2023, 4:45 PMbitter-ability-32190
02/16/2023, 4:46 PMaverage-sugar-68948
02/16/2023, 5:03 PM__init__.py
thing. https://www.pantsbuild.org/docs/protobuf-python recommends adding empty __init__.py
files, but that messes with debugging apparentlybitter-ability-32190
02/16/2023, 5:17 PMbitter-ability-32190
02/16/2023, 5:18 PM__init__
being the issue?average-sugar-68948
02/16/2023, 5:19 PMaverage-sugar-68948
02/16/2023, 5:19 PMaverage-sugar-68948
02/16/2023, 5:20 PMbitter-ability-32190
02/16/2023, 5:20 PMenough-analyst-54434
02/16/2023, 5:30 PMproto
dir to - say `proto2`and update this dep correspondingly: https://github.com/jonas25007/pants-proto-test/blob/main/BUILD#L4 does that work? If so I'll leave you the pleasure of understanding why.average-sugar-68948
02/20/2023, 1:33 PMenough-analyst-54434
02/20/2023, 5:43 PMproto/
dir on the sys.path
both in the sandbox and in your local repo with run_goal_use_sandbox=False
. Since there are two sources of the same package (proto
), you need to be using namespace packages. You can either PEP-420, which is no __init__.py
, or, if you need __init__.py
, they must not be empty, but contain ns-package magic. For example, this works and debug breakpoints are hit: echo "__path__ = __import__('pkgutil').extend_path(__path__, __name__)" > proto/__init__.py
, see: https://packaging.python.org/en/latest/guides/packaging-namespace-packages/#pkgutil-style-namespace-packagesaverage-sugar-68948
02/21/2023, 6:54 PM