https://pantsbuild.org/ logo
#general
Title
# general
a

adamant-magazine-16751

10/10/2022, 11:37 AM
Hi, is it possible to override an undeclared first-party dependency? I have a directory containing 2 python source files, say
a.py
and
b.py
.
a.py
depends on
b.py
without explicitly importing it. I also have a BUILD file containing
python_sources
target. Is there a way to tell pants that
a
depends on
b
so that it's properly packaged in pexes?
f

fast-nail-55400

10/10/2022, 11:41 AM
Use the
overrides
attribute on
python_sources
to set the dependency. https://www.pantsbuild.org/docs/reference-python_sources#codeoverridescode
Probably:
Copy code
overrides={
  "a.py": {
    "dependencies": ["b.py"],
  }
}
a

adamant-magazine-16751

10/10/2022, 11:45 AM
Thanks, I found it before, but had some trouble pulling it off for first-party dependencies. Finally I had to use relative path for b.py:
"dependencies": ["./b.py"]
Anyway, it works. Thanks 🙂
f

fast-nail-55400

10/10/2022, 11:59 AM
Can you open an issue re the need for the
./
? That seems like a bug to me.
a

adamant-magazine-16751

10/10/2022, 12:07 PM
Sure, I can do that a bit later today. I'll try to setup a simple example and check if I can reproduce it then
f

fast-nail-55400

10/10/2022, 12:16 PM
Thanks!
2 Views