I'm looking for advice if folks have had to handle...
# general
v
I'm looking for advice if folks have had to handle a python module + a script in the same folder. In my case this is for a build script / CI tool, so it doesn't share dependencies with the module in the same folder. What makes this trouble: pants assumes the
__init__
file in the same folder is a dependency of the script (as well as
__init__
files in parent folders, and I haven't found an invocation of
!__init__.py
in the BUILD file that changes this behavior.
I think I found my own answer:
Copy code
python_sources(
    sources=[*python_sources.sources.default, "!build.py"],
)

python_sources(
    name="build",
    sources=["build.py"],
    overrides={
        "build.py": {"dependencies": ["!./__init__.py"]}
    },
)
e
super minor: You can just use
python_source
for the single
build.py
file ro have a little bit more clarity. (You can declare the dependencies directly instead of needing to go through
overrides
)
v
I was finding that python_source naming is different that what python_sources generates (the name of the source_file is not included in the result) - so for a separate pants target that's looking for all
build.py
in the repository,
python_source
on it's own doesn't work for us.
e
interesting!