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

Reset the PY2/PY3 mode along data dependencies #6441

Closed
brandjon opened this issue Oct 18, 2018 · 2 comments
Closed

Reset the PY2/PY3 mode along data dependencies #6441

brandjon opened this issue Oct 18, 2018 · 2 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Python Native rules for Python type: bug

Comments

@brandjon
Copy link
Member

The part of the build configuration that chooses the python major version can be either PY2, PY3, or unknown. Currently when it's set, it stays that way for all transitive deps. We should reset it across data deps.

The rationale is that you want to enforce (via any srcs_version attrs that are present) that the source files and libraries you depend on have the same version as you, but you don't want to require that of other python binaries that you invoke as a separate process.

Implementation wise, it's straightforward to do this for the case of a py_binary's data attr. It's not so clear how to do it when you have a src file generated by another type of rule, like a genrule or sh_binary. Would you have to attach the transition to all sorts of attributes, or is there a way to attach the transition to a particular entry of the py_binary's srcs based on the kind of rule that generates it? (Though conditioning on rule type rather than provider is a code smell too.) TBD.

@brandjon brandjon added type: bug P2 We'll consider working on this in future. (Assignee optional) team-Rules-Python Native rules for Python labels Oct 18, 2018
@brandjon brandjon self-assigned this Oct 18, 2018
@brandjon
Copy link
Member Author

This proposal is rendered obsolete by the (nearly completed) work described in #6583.

@lefevere-lyft
Copy link

lefevere-lyft commented Feb 9, 2020

This proposal is rendered obsolete by the (nearly completed) work described in #6583.

Is there something specific that users have to do to avoid the fact that python configurations are propagated through data?
I have the following simple example of a c++ data dependency used by both PY2 and PY3 targets and the c++ gets built twice. I would like to build it once.
I tried looking at #6583 but I could not find anything relevant to this problem there.

cc_binary(
  name = "cpptest",
  srcs =["cpptest.cc"]
)

py_binary(
  name = "py2test",
  srcs = ["pytest.py"],
  main = "pytest.py",
  python_version = "PY2",
  data = [
      ":cpptest"
  ]
)

py_binary(
  name = "py3test",
  srcs = ["pytest.py"],
  main = "pytest.py",
  python_version = "PY3",
  data = [
      ":cpptest"
  ],
)

@brandjon Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Python Native rules for Python type: bug
Projects
None yet
Development

No branches or pull requests

2 participants