high-magician-46188
12/20/2022, 11:05 AMpants run ...
.
When the script is a single file, it works perfectly.
However, I can't figure out how to configure it to work with relative imports.
Will appreciate any help.
Details in ๐งต....
UnownedDependencyError: Pants cannot infer owners for the following imports in the target scripts/pants/utils/render.py:render-script-src:
* .lib (line: 1)
...
Command: pants run ./scripts/pants/utils/render.py
BUILD:
python_sources(
name="render-script-src",
sources=["render.py", "lib.py", "__init__.py"], # These files are in the same directory. Tried both with and without the init.py file.
interpreter_constraints=["==3.9.*"],
run_goal_use_sandbox=False,
resolve="render-script",
)
python_requirement(
name="render-script-requirements",
requirements=[],
resolve="render-script",
)
In pants.toml, root_patterns
has "/scripts/pants/utils"
.
Tried the following import forms:
from scripts.pants.utils import lib
from pants.utils import lib
from utils import lib
from . import lib
curved-television-6568
12/20/2022, 2:54 PMimport lib
?happy-kitchen-89482
12/20/2022, 3:20 PMmynamespace
and then from my namespace import ...
high-magician-46188
12/20/2022, 4:06 PM