bulky-evening-62934
04/16/2020, 2:16 PMERROR: The 'sources' field in target XXXX:XXXX must have 0 or 1 files, but it had 2 files.
could I include more than 1 file for pants binary ?hundreds-father-404
04/16/2020, 2:22 PMbinary
targets, if it uses more than 1 source file, you’ll want to create a python_library
with the other files and include it in dependencies
.
python_binary
should either have no source files or one, such as app.py
or main.py
. This allows Pants to infer what the entry_point
is if you end up leaving off that field.
For example
# example/BUILD
# this will use the default sources of `*.py`
# and the default target name of `example:example`
python_library()
python_binary(
name="app",
dependencies=[':example'],
)
bulky-evening-62934
04/16/2020, 2:27 PMhundreds-father-404
04/16/2020, 2:28 PMresources()
targethundreds-father-404
04/16/2020, 2:30 PM./pants target-types
to get a list of all the targets and ./pants target-types --details='resources'
to see all of its fields, including which fields are required etc
(If that doesn’t work, try target-types2
)bulky-evening-62934
04/16/2020, 2:42 PMhappy-kitchen-89482
04/16/2020, 6:01 PMmain.py
in the python_library
and have no sources at all in the python_binary
(but you then must explicitly specify the entry_point=
in the python_binary
). If you have a single source in your python_binary
then you can leave off the entry_point=
because Pants will assume that the single source is the entry point module.