Hi folks! Quick question. I've noticed that someti...
# general
a
Hi folks! Quick question. I've noticed that sometimes I need to add
sources=["*.py"]
in my
python_library
target in order for my
pex_binary
in the same BUILD to run successfully, or else it would
ImportError: No module named path.to.entry_point
; but in some other cases I don't need that
source=["*.py"]
for things to work. What's the magic here?
w
targets have default sources globs, which you can see in their help: see
Copy code
./pants help python_library
Copy code
sources
    type: Iterable[str] | None
    default: ('*.py', '*.pyi', '!test_*.py', '!*_test.py', '!tests.py', '!conftest.py', '!test_*.pyi', '!*_test.pyi', '!tests.pyi')
    A list of files and globs that belong to this target.

    Paths are relative to the BUILD file's directory. You can ignore files/globs by prefixing them with `!`.

    Example: `sources=['example.py', 'test_*.py', '!test_ignore.py']`.
h
You shouldn't need that, unless - does one of the relevant source files match
test_*.py
or
*_test.py
?
w
in the case of
python_library
, it avoids grabbing what look like test files
a
Ohhhhhhhhh
yes it starts with
test_
gotcha! super helpful! thanks!!
👍 1
w
sure thing!