Details and current non-working solutions:
I've been experimenting with using Bazel at Bluecore (~35 engineers with a lot of Python). Here are the current approaches, and why none of them really work:
Built-in rules:
* No support for PyPI packages, requiring manual effort to import each one.
* Namespace packages cause problems (see below).
* Skylark rules can't see the imports attribute, so custom rules can't interact with it correctly https://github.com/bazelbuild/bazel/issues/2617
* The imports attribute is weird: it has cross-rule effects in a way that seems surprising to me (this isn't fatal, but I think it does decrease "usability" of the rules)
rules_python: This seems to be an "official" attempt to make Python work? It makes using PyPI packages much easier, but still has problems:
* Not reproducible, since it depends on whatever "pip" resolves the dependencies to. This is convenient, but the results can change between builds. It seems to me that an approach like Maven bazel-deps would be better, where we can check in the results of dependency resolution so future builds gets the exact same results.
* Namespace packages such as Google's APIs don't work (fatal for us): https://github.com/bazelbuild/rules_python/issues/14
PEX via bazel_rules_pex [2]: PEX is a tool that packages python like PAR/subpar, originally from Twitter and the Pants build tool [3], and also used by Buck [4]. These rules actually work! I wrote a tool to generate the appropriate WORKSPACE and BUILD declarations, and so far I've been able to get Bluecore's code to work.
* PEX has bugs related to resolving packages correctly
* PEX is slow: Both in terms of building a PEX, and executing it. For packages that depend on large libraries (e.g. scipy, numpy, scikit-learn), this makes the edit/test cycle very slow.
My own Python zip rules: As an experiment, I've written rules that package everything into one zip, mostly to see if it can be substantially faster than PEX and to understand the issues better. I think this is a workable solution, but I would rather not have to maintain my own set of build rules.
The Path Forward
In my opinion, the "ideal" solution is to "bless" rules_python as the official rules and fix its issues. The problem is this will require someone who has understanding of Bazel internals, as well as deep knowledge about Python's somewhat arcane imports system. Probably this means the Bazel team and Google would need to take this up.
An alternative is that the "external" Bazel users could collaborate on a set of Skylark rules, like the Scala and Rust rules. From what I understand of Bazel and Python, I think to workaround the import issues, this would probably need to abandon the native rules entirely, and take the "produce a single zip" approach to avoid the imports/namespace package weirdness.
I'd love to help with this, if anyone is interested.
Evan Jones
[1] https://github.com/bazelbuild/rules_python
[2] https://github.com/benley/bazel_rules_pex
[3] https://github.com/pantsbuild/pex
[4] https://buckbuild.com/rule/python_binary.html
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f3703ac4-135d-422b-81c3-0986469c3c7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f3703ac4-135d-422b-81c3-0986469c3c7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAAsxKoyGg1TmpTdTDZU-L01gxm5W%3Dkwi2KrnuH-4nsi2WqU0gQ%40mail.gmail.com.To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f3703ac4-135d-422b-81c3-0986469c3c7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/NMO6KPyPKh4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/9e928339-991b-4c49-a9e3-329ea949e9d5%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/9e928339-991b-4c49-a9e3-329ea949e9d5%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CACRPLjgwfx2PZP7xqEbf2F38sdaKuZ5oxD9iUkgmVXX1XqUAcA%40mail.gmail.com.
Dave
To unsubscribe from this group and all its topics, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/9e928339-991b-4c49-a9e3-329ea949e9d5%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
I'd be willing to participate in a python-bazel interest group.I spent a few months last fall trying to use Bazel as our build system in a majority-python shop. I got things mostly working, but was unable to make progress on a few fronts:
- Test coverage support for Python (https://github.com/bazelbuild/rules_python/issues/43)
- Python 3 support (e.g., https://github.com/bazelbuild/rules_python/issues/33, https://github.com/google/containerregistry/issues/42)
- Support for pip packages with native components (https://github.com/bazelbuild/rules_python/issues/48)
- Packaging everything in to a docker image
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/f3703ac4-135d-422b-81c3-0986469c3c7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
I hope it's not too late to join the party but I am also interested into what's the plan are, I can also try to help as much as I can since we are facing similar issues in my organization, thanks Evan for starting the discussion.
Mouad
If it is still possible I would like to join this call. Looks like the road map has covered the most issues with python support in bazel. Would be nice to hear how you plan to implement everything and if I can provide some help.Alexey Dudko
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/NMO6KPyPKh4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/840bf39d-c39a-40f8-a171-d14b81a28dcb%40googlegroups.com.
The link Dave Stanke posted should be an open Google Hangout for anyone to join, today at 1:00 PM/13:00 US/Eastern / 18:00 UTC:EvanOn Tue, Jan 30, 2018 at 6:02 AM, Alexey Dudko <dud...@gmail.com> wrote:If it is still possible I would like to join this call. Looks like the road map has covered the most issues with python support in bazel. Would be nice to hear how you plan to implement everything and if I can provide some help.Alexey Dudko
--
You received this message because you are subscribed to a topic in the Google Groups "bazel-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bazel-discuss/NMO6KPyPKh4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/840bf39d-c39a-40f8-a171-d14b81a28dcb%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CACRPLjj%3DDkBt%2B46e0imp7WZBmP8rf8vSmZC%2BM07-JwADgKuZsA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/CAAsxKoybiyW%2BeWSkfJZfYMQdCh%2Bj9QJ09u1bF582LFOj8L9rNg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.