calling `python_binary_adaptor.sources` gets me a ...
# development
h
calling
python_binary_adaptor.sources
gets me a value of type
EagerFilesetWithSpec
, which is not what I want
a
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
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
hm, ok
maybe I've gone down a bit too deep a rabbit hole here
a
😄
h
basically, what I care about doing is getting the logic in
PythonBinary.entry_point
, available in a
PythonBinaryAdaptor
a
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
yeah I'm using code substantially baed on his
ok
a
(With an upsetting amount of
getattr
and
hasattr
, sorry about that 😞)