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

add exec/target constraints parameters to python toolchain macro #169

Merged
merged 1 commit into from
Nov 24, 2021

Conversation

tek
Copy link
Member

@tek tek commented Nov 23, 2021

just copied the code from the CC toolchain, works fine

@tek tek requested a review from aherrmann November 23, 2021 15:07
Copy link
Member

@aherrmann aherrmann left a 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.

Comment on lines 893 to 895
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")

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with pleasure!

@@ -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:
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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 .

@tek tek force-pushed the tek/python-platforms branch 5 times, most recently from 7f08c41 to dc4683a Compare November 24, 2021 14:36
@tek tek added the merge-queue merge on green CI label Nov 24, 2021
@tek tek merged commit 0757940 into master Nov 24, 2021
@tek tek deleted the tek/python-platforms branch November 24, 2021 14:56
@mergify mergify bot removed the merge-queue merge on green CI label Nov 24, 2021
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.

3 participants