Closed dragoscarp closed 4 months ago
My understanding is that the py_binary()
and py_test()
rules may specify Python versions and that whatever the current Python toolchain happens to be will propagate to other rules as needed. See this and this in the rules_python examples for a sense of what I mean. Please correct me if I'm wrong, @rickeylev, or if I'm overlooking some subtlety in this feature request!
Correct. Library rules shouldn't be specifying a version because that's the responsibility of a higher level rule.
Do you want to force a particular version because you're building something for packaging (e.g. for pypi distribution)? If so, then the rule that performs the packaging (e.g. py_wheel, py_package, or what have you) should use a transition to set the python version.
Thank you for the answers!
Maybe I'm missing something, but as an example I think it should be possible to have py_binary
targets depending on a pybind_extension
target.
How could I do this for target version_3_10
or version_3_9
in this example?
https://github.com/bazelbuild/rules_python/blob/c5c03b2477dd1ce0c06c9dc60bf816995f222bcf/examples/multi_python_versions/tests/BUILD.bazel#L35
As per the documentation, please add the pybind_extension
target to the data
attribute – not the deps
attribute – of the py_*
target.
Thank you! It seems to work indeed when the data
attribute is used!
When used in a multi python version bzlmod workspace add an attribute to select the python version for
pybind_extension
,pybind_library
andpybind_library_test
rules.