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

Runfiles library cannot be imported by PY2 targets when the incompatible_default_to_explicit_init_py flag is enabled. #413

Closed
chowder opened this issue Feb 3, 2021 · 2 comments
Labels
Can Close? Will close in 30 days if there is no new activity

Comments

@chowder
Copy link
Contributor

chowder commented Feb 3, 2021

Affected Rule

This relates to the following py_library rule with paired with the incompatible_default_to_explicit_init_py flag:

https://github.com/bazelbuild/rules_python/blob/master/python/runfiles/BUILD#L40-L44

Is this a regression?

It is not.

Description

By default the, empty __init__.py files are automatically created by Bazel in the runfiles tree - this behaviour can be disabled with the incompatible_default_to_explicit_init_py flag, and I think is expected to flip some time in the future.

These __init__.py files are still required by Python 2 (I know, I know), so for those who are already using the flag above, the runfiles library becomes un-importable to them.

It would be trivial to add the __init__.py files explicitly - but I'm not sure if that's fully sensible given the structure of the repo.

🔬 Minimal Reproduction

BUILD:

py_binary(
    name = "main",
    srcs = ["main.py"],
    deps = [
        "@rules_python//python/runfiles:runfiles",
    ],
    python_version = "PY2",
)

main.py

from rules_python.python.runfiles import runfiles

.bazelrc

build --incompatible_default_to_explicit_init_py
@chowder chowder changed the title Runfiles library does not work in Python 2 when the incompatible_default_to_explicit_init_py flag is enabled. Runfiles library cannot be imported by PY2 targets when the incompatible_default_to_explicit_init_py flag is enabled. Feb 4, 2021
@github-actions
Copy link

github-actions bot commented Aug 3, 2021

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

@github-actions github-actions bot added the Can Close? Will close in 30 days if there is no new activity label Aug 3, 2021
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

@github-actions github-actions bot closed this as completed Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? Will close in 30 days if there is no new activity
Projects
None yet
Development

No branches or pull requests

1 participant