Skip to content
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

Enable passing in custom py_runtime #98

Merged
merged 2 commits into from
Aug 17, 2024

Conversation

chrisirhc
Copy link
Contributor

@chrisirhc chrisirhc commented Aug 7, 2024

Could use some help and opinions on the attribute name.
This does add rules_python as a bazel dep in order to use the PyRuntimeInfo provider. Not sure if that's undesirable. It seems to make sense since rules_uv already depends on the toolchain made available by it.

Example usage:

# in MODULE.bazel
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    python_version = "3.11",
)
use_repo(
    python,
    "python_3_11",
)

# in BUILD.bazel
pip_compile(
    name = "requirements_3_11",
    py3_runtime = "@python_3_11//:py3_runtime",
    requirements_in = "requirements.in",
    requirements_txt = "requirements_3_11.txt",
)

Fixes #97

@chrisirhc chrisirhc requested a review from a team as a code owner August 7, 2024 06:34
@chrisirhc chrisirhc force-pushed the chua/08-07-custom-interpreter branch from ecee048 to fd886bb Compare August 12, 2024 02:43
@mark-thm
Copy link
Collaborator

It seems like there should be a way to pass a constraint to the toolchain resolution, I’m just unsure how to do it.

@chrisirhc
Copy link
Contributor Author

It seems like there should be a way to pass a constraint to the toolchain resolution, I’m just unsure how to do it.

I'm not sure how to do it either, though our use of rules_uv requires multiple pip_compile rules with a different version of python for each of them. This seems to work well in our use case since we'd need to specify a different runtime for the non-default python toolchain.

I'm also not sure how to add tests for this.

@mark-thm
Copy link
Collaborator

Thanks -- this seems like something we can/should be able to get help for on Bazel slack, I'll start a thread.

@mark-thm
Copy link
Collaborator

https://bazelbuild.slack.com/archives/CA306CEV6/p1723577616413499

@chrisirhc
Copy link
Contributor Author

chrisirhc commented Aug 14, 2024

Added an example of usage in the PR description to help with the conversation/thread.

@chrisirhc chrisirhc force-pushed the chua/08-07-custom-interpreter branch from fd886bb to 9caae52 Compare August 15, 2024 01:24
@chrisirhc chrisirhc force-pushed the chua/08-07-custom-interpreter branch from 9caae52 to 8ac045c Compare August 15, 2024 02:55
@keith
Copy link
Contributor

keith commented Aug 15, 2024

seems like this will be super nice for projects that support multiple py versions where the default is not the lowest supported version

@mark-thm mark-thm merged commit 261f2e3 into theoremlp:main Aug 17, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to select python version
3 participants