Cross language dependency: py_binary() depends upon cc_binary() rule feasible ?

517 views
Skip to first unread message

JG

unread,
Jul 18, 2018, 7:18:33 PM7/18/18
to bazel-dev
Dear Bazel users,

a.   Looks like, py_binary(..) supports easily py_library(..) rule variants. However, our expectations to use cc_custom_target_binary(…) as cc_binnary(…) rule variants under py_binary(..) dependency. Here, we are facing “does not have mandatory providers: 'py' error” consistently, some existing references inline:


bazel wiki: py_binary

https://github.com/bazelbuild/bazel/issues/4237

https://github.com/tensorflow/models/issues/831 

https://groups.google.com/forum/#!topic/bazel-discuss/QrdrQpYiyCA 


As alternative, does it makes sense to investigate into sh_binary Attributes common to all build rules,  dependencies, Build configurationsMake variables  areas to navigate for any feasible Bazel solution, or this problem itself "By Design" Bazel features/limitations over Cross Language binary dependency support coverage ?

Any idea/hint would be very highly appreciated.


Thanks in advance!

Kind Regards,
JG

László Csomor

unread,
Jul 19, 2018, 5:56:38 AM7/19/18
to jg.i...@gmail.com, bazel-dev
Hi JG,

Unfortunately Bazel doesn't yet support py_* rules to depend on cc_* rules. There are no design limitations against it, but we haven't implemented this support yet.
The error message you see means that the interface that py_* binary rules expect from their dependencies (the "py" provider) is not implemented by the cc_* rule.


--
László Csomor | Software Engineer | laszlo...@google.com

Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado


--
You received this message because you are subscribed to the Google Groups "bazel-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-dev+...@googlegroups.com.
To post to this group, send email to baze...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-dev/7e86f89b-63fe-4e02-b0ba-167e57c2cb29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ulf Adams

unread,
Jul 19, 2018, 6:03:38 AM7/19/18
to László Csomor, jg.i...@gmail.com, bazel-dev
As a workaround, you may be able to make the py_binary have a data dependency on the cc_binary and make the name of the cc_binary lib<name>.so to get it to build a dynamic library. I believe this is what others are doing. I would expect py_binary.deps -> cc_binary to continue to be illegal even when we implement py/cc interop.

Marcel Hlopko

unread,
Jul 19, 2018, 12:02:15 PM7/19/18
to Ulf Adams, László Csomor, Joyabrata Ghosh, bazel-dev
You'll have to also set linkshared = 1 on the cc_binary in order to make shared library.

I can imagine allowing py_library\py_binary to depend on cc_library. But that's also TBD, I'm not promising anything :)


For more options, visit https://groups.google.com/d/optout.


--
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Geschäftsführer: Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg, HRB 86891
Reply all
Reply to author
Forward
0 new messages