Provide current_py_toolchain - #731
Merged
Merged
Conversation
jheaff1
force-pushed
the
current_py_toolchain
branch
2 times, most recently
from
June 14, 2022 15:51
913db56 to
6b4ec43
Compare
jheaff1
marked this pull request as ready for review
June 14, 2022 16:39
jheaff1
force-pushed
the
current_py_toolchain
branch
3 times, most recently
from
June 15, 2022 13:52
a443073 to
e9b8226
Compare
Contributor
Author
|
CI now passes, may I please ask for a review? |
f0rmiga
suggested changes
Jun 15, 2022
f0rmiga
reviewed
Jun 15, 2022
jheaff1
force-pushed
the
current_py_toolchain
branch
from
June 16, 2022 10:30
09824e0 to
e9b8226
Compare
This commit introduces the current_py_toolchain rule, exposing the PYTHON2 and PYTHON3 "make" variables in bazel rules, analagous to @bazel_tools//tools/cpp:current_cc_toolchain. See https://docs.bazel.build/versions/main/be/make-variables.html#custom_variables
jheaff1
force-pushed
the
current_py_toolchain
branch
from
June 16, 2022 10:33
8beb89d to
94ca634
Compare
Contributor
Author
|
@f0rmiga Thanks for the review, I have applied your suggested changes |
Member
|
@jheaff1 thanks for addressing my comments! |
f0rmiga
approved these changes
Jun 21, 2022
mattem
pushed a commit
to mattem/rules_python
that referenced
this pull request
Jul 7, 2022
This commit introduces the current_py_toolchain rule, exposing the PYTHON2 and PYTHON3 "make" variables in bazel rules, analagous to @bazel_tools//tools/cpp:current_cc_toolchain. See https://docs.bazel.build/versions/main/be/make-variables.html#custom_variables Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
| name = "test_current_py_toolchain", | ||
| srcs = [], | ||
| outs = ["out.txt"], | ||
| cmd = "$(PYTHON3) --version > $(location out.txt)", |
There was a problem hiding this comment.
Is there a way to use genrule and a python toolchain in conjunction with pip deps?
Contributor
Author
There was a problem hiding this comment.
See the use of entry_point in pip.md
you could use this in a genrule
Contributor
Author
There was a problem hiding this comment.
I’m assuming you want to run T he entrypoint of a pip package? If you want to use a pip package as a library, use the requirement macro and setup the PYTHONPATH environment variable to include the location of the pip packages. Eg
”PYTHONPATH=$(location {}”.format(requirement(‘the_pip_package’)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces the current_py_toolchain rule, exposing the
PYTHON2 and PYTHON3 "make" variables in bazel rules, analagous to
@bazel_tools//tools/cpp:current_cc_toolchain.
This is useful when building 3rd party libraries which require python via rules_foreign_cc.
See
https://docs.bazel.build/versions/main/be/make-variables.html#custom_variables
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Bazel rules can refer to the python interpreter via "Make" Variables.
Does this PR introduce a breaking change?
Other information