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

gazelle plugin is not working with Python 3.11 in 0.27.0 release #1589

Closed
aignas opened this issue Dec 2, 2023 · 0 comments · Fixed by #1590
Closed

gazelle plugin is not working with Python 3.11 in 0.27.0 release #1589

aignas opened this issue Dec 2, 2023 · 0 comments · Fixed by #1590

Comments

@aignas
Copy link
Collaborator

aignas commented Dec 2, 2023

🐞 bug report

Affected Rule

@rules_python_gazelle_plugin//python is broken when used in gazelle_binary with the latest release when using Python 3.11 as the default toolchain.

Is this a regression?

Yes, introduced in #1455.

Description

See https://bazelbuild.slack.com/archives/CA306CEV6/p1700496408567889

🔬 Minimal Reproduction

See https://github.com/aignas/rules_python_repro_gazelle_binary_rule

🔥 Exception or Error

Traceback (most recent call last):
  File "/tmp/Bazel.runfiles_tugoo1fs/runfiles/rules_python_gazelle_plugin/python/__main__.py", line 19, in <module>
    import parse
ModuleNotFoundError: No module named 'parse'
Traceback (most recent call last):
  File "/var/folders/rl/v9dqv4mx1jsgwx81qjy74scc0000gn/T/Bazel.runfiles_o1h0_q7c/runfiles/rules_python_gazelle_plugin/python/__main__.py", line 19, in <module>
    import parse
ModuleNotFoundError: No module named 'parse'
gazelle: ERROR: failed to parse: EOF
aignas added a commit that referenced this issue Dec 2, 2023
Before this change there was a bug in how the parsing helpers were being
used in case we were using Python 3.11 toolchain, which is using a more
strict version of the entrypoint template. This change moves the python
code to a different location to ensure that the top level package is
something more unique than just "python" and updates the non-bzlmod
tests to run under 3.11.

We also change ".bazelrc" to use explicit "__init__.py" definition to
avoid non-reproducible errors in the future.

Fixes #1589
github-merge-queue bot pushed a commit that referenced this issue Dec 3, 2023
…1590)

Before this change there was a bug in how the parsing helpers were being
used in case we were using Python 3.11 toolchain, which is using a more
strict version of the entrypoint template. This change adds `imports =
["."]`
to ensure that the gazelle helper components are on PYTHONPATH and
updates
the non-bzlmod tests to run under 3.11.

We also:
* Change `.bazelrc` to use explicit `__init__.py` definition to avoid
  non-reproducible errors in the future.
* Add a dedicated `gazelle_binary` that uses `DEFAULT_LANGUAGES` *and*
  `//python`.

Fixes #1589
aignas added a commit that referenced this issue Dec 4, 2023
…1590)

Before this change there was a bug in how the parsing helpers were being
used in case we were using Python 3.11 toolchain, which is using a more
strict version of the entrypoint template. This change adds `imports =
["."]`
to ensure that the gazelle helper components are on PYTHONPATH and
updates
the non-bzlmod tests to run under 3.11.

We also:
* Change `.bazelrc` to use explicit `__init__.py` definition to avoid
  non-reproducible errors in the future.
* Add a dedicated `gazelle_binary` that uses `DEFAULT_LANGUAGES` *and*
  `//python`.

Fixes #1589
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 a pull request may close this issue.

1 participant