-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial support for rules_python. #65
Conversation
Hmm. GitHub won't let me assign @rickeylev as well. |
bazel_dep(name = "rules_python", version = "0.27.0") | ||
|
||
python = use_extension("@rules_python//python/extensions:python.bzl", "python") | ||
use_repo(python, "pythons_hub") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The @pythons_hub
is an internal detail of rules_python. It's basically just a registry so that it can auto-register the toolchains and make pip integration easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feared as much. Hence why I really wanted you to review. :)
@@ -167,6 +168,23 @@ def _get_python_bin(repository_ctx): | |||
python_bin = _norm_path(python_bin) | |||
return python_bin | |||
|
|||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way this is trying to work is fundamentally flawed. The core issue is the repository phase can't know what interpreter a target will use, and it can't know the full set of toolchains registered. The @pythons_hub
only keeps track of python.toolchain()
calls, but that doesn't include any custom user toolchains.
I'm not really sure this will work, either. IIRC, the label isn't a canonical one (one that starts with '@@`, so it won't be able to resolve (you would have to use_repo() the apparent name)
From what I remember, these labels are also host specific. This is because they're just used to drive pip.parse()
(which does various repository phase things, so has to have a host-capable interpreter available).
What you really want is to get this information from the toolchain directly. e.g., in the regular rule code, do something like
def _pybindthing_impl(ctx):
py_lib_path = ctx.toolchains["pything"].lib_path
ctx.actions.run(...stuff using py_lib_path...)
This should be pretty easy. If you can give a run down of the information needed, we can figure out how to make it available from the toolchains.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh snap. I just realised that I still owe you a reply on bazelbuild/rules_python#824 (comment). :(
I'm going to close this PR since it isn't going to fly. |
Fixes #64.