https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

09/30/2019, 9:53 PM
calling
python_binary_adaptor.sources
gets me a value of type
EagerFilesetWithSpec
, which is not what I want
a

aloof-angle-91616

09/30/2019, 10:08 PM
is there a branch i can look at here? weren't we able to just get the sources snapshot from the target earlier?
I don't want the snapshot though, I want the entire
SourcesField
object
basically I'm trying to duplicate this method: https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/python/targets/python_binary.py#L144-L152 on
PYthonBinaryAdaptor
, but I need the
SourcesField
in order to do that
a

average-vr-56795

09/30/2019, 10:22 PM
I suspect https://github.com/pantsbuild/pants/issues/6659 will be an issue for you
You should be able to (ugly though it may be)
next(filter(lambda f: isinstance(f, SourcesField), target_adaptor.field_adaptors))
except for that bug
Feel free to redesign as much of that class as you fancy to make it not a) ugly and b) broken 😉
h

hundreds-breakfast-49010

09/30/2019, 10:25 PM
hm, ok
maybe I've gone down a bit too deep a rabbit hole here
a

average-vr-56795

09/30/2019, 10:25 PM
😄
h

hundreds-breakfast-49010

09/30/2019, 10:26 PM
basically, what I care about doing is getting the logic in
PythonBinary.entry_point
, available in a
PythonBinaryAdaptor
a

average-vr-56795

09/30/2019, 10:27 PM
I believe all you need to do that is to check “Hey, the EagerFilesetWithSpec, does its snapshot contain exactly one file? If so, that’s the default entrypoint”
Modulo source_root stripping, which IIRC @hundreds-father-404 implemented somewhere
So the logic would be roughly:
Is there an entry_point field? Great, use it Is the source snapshot exactly one file? Great, strip the source root and use it Else no entry point for you
h

hundreds-breakfast-49010

09/30/2019, 10:28 PM
yeah I'm using code substantially baed on his
ok
a

average-vr-56795

09/30/2019, 10:29 PM
(With an upsetting amount of
getattr
and
hasattr
, sorry about that 😞)