-
Notifications
You must be signed in to change notification settings - Fork 80
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 exec/target constraints parameters to python toolchain macro #169
Conversation
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.
Thank you! Small comment.
CI is failing because the README me is outdated. The test failure should state how to fix it.
nixpkgs/nixpkgs.bzl
Outdated
os = {"darwin": "osx"}.get(cpu, "linux") | ||
|
||
if repository_ctx.attr.target_constraints == None and repository_ctx.attr.exec_constraints == None: | ||
target_constraints = ["@platforms//cpu:x86_64"] | ||
target_constraints.append("@platforms//os:{}".format(os)) | ||
exec_constraints = target_constraints | ||
else: | ||
target_constraints = list(repository_ctx.attr.target_constraints) | ||
exec_constraints = list(repository_ctx.attr.exec_constraints) | ||
|
||
exec_constraints.append("@io_tweag_rules_nixpkgs//nixpkgs/constraints:support_nix") | ||
|
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.
This is the same as in nixpkgs_cc_configure
, correct? Could you factor this out into a function?
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.
with pleasure!
nixpkgs/nixpkgs.bzl
Outdated
@@ -890,6 +890,18 @@ def nixpkgs_cc_configure_deprecated( | |||
|
|||
def _nixpkgs_python_toolchain_impl(repository_ctx): | |||
cpu = get_cpu_value(repository_ctx) | |||
os = {"darwin": "osx"}.get(cpu, "linux") | |||
|
|||
if repository_ctx.attr.target_constraints == None and repository_ctx.attr.exec_constraints == None: |
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.
You can use if not variable and not other_variable
to cover uscases of empty strings and null-like values.
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.
empty list is not valid for specification by the consumer?
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.
This is just a soft-ball comment, Starlark is Pythonesque and I think it is generally a bad smell to use == None
in Python .
7f08c41
to
dc4683a
Compare
dc4683a
to
ef8f547
Compare
just copied the code from the CC toolchain, works fine