rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

bzlmod hermetic python toolchain: calling pylint is not possible due to the pylint package configuration problem

Open wizard29 opened this issue 1 year ago β€’ 4 comments

🐞 bug report

Affected Rule

The issue is caused by the rule: py_console_script_binary

Is this a regression?

No. The problem is the same for the previous 0.26.0 version

Description

I am trying to lint the python code within the hermetic python repository based on the https://github.com/bazelbuild/rules_python/tree/main/examples/bzlmod/entry_points/tests. It doesn't work once I refer a certain version of the python_rules in my repository instead of local_path_override.

I played around this problem and found the following: I put the WS inside the https://github.com/bazelbuild/rules_python/tree/main/examples level of the downloaded repository and uncommented https://github.com/wizard29/python_rules_clarification_repo/blob/e3c9e474029237cab783b04dd2dea98dc6e09c4a/MODULE.bazel#L7 So, It started behaving properly.

πŸ”¬ Minimal Reproduction

The code to reproduce the issue: https://github.com/wizard29/python_rules_clarification_repo

πŸ”₯ Exception or Error


python_rules_clarification_repo> bazelisk run //python_application:pylint_test
INFO: Analyzed target //python_application:pylint_test (1 packages loaded, 4015 targets configured).
INFO: Found 1 target...
Target //python_application:pylint_test up-to-date:
  bazel-bin/python_application/pylint_test.zip
  bazel-bin/python_application/pylint_test.exe
INFO: Elapsed time: 30.695s, Critical Path: 29.67s
INFO: 14 processes: 10 internal, 4 local.
INFO: Build completed successfully, 14 total actions
INFO: Running command line: external/bazel_tools/tools/test/tw.exe python_application/pylint_test.exe
Executing tests from //python_application:pylint_test
-----------------------------------------------------------------------------
.
----------------------------------------------------------------------
Ran 1 test in 7.589s

OK
OUT:
ERR: Problem importing module async.py: No module named 'rules_python~0'
Problem importing module bad_chained_comparison.py: No module named 'rules_python~0'
Problem importing module base: No module named 'rules_python~0'
Problem importing module base_checker.py: No module named 'rules_python~0'
Problem importing module classes: No module named 'rules_python~0'
Problem importing module dataclass_checker.py: No module named 'rules_python~0'
Problem importing module deprecated.py: No module named 'rules_python~0'
Problem importing module design_analysis.py: No module named 'rules_python~0'
Problem importing module ellipsis_checker.py: No module named 'rules_python~0'
Problem importing module exceptions.py: No module named 'rules_python~0'
Problem importing module format.py: No module named 'rules_python~0'
Problem importing module imports.py: No module named 'rules_python~0'
Problem importing module lambda_expressions.py: No module named 'rules_python~0'
Problem importing module logging.py: No module named 'rules_python~0'
Problem importing module method_args.py: No module named 'rules_python~0'
Problem importing module misc.py: No module named 'rules_python~0'
Problem importing module modified_iterating_checker.py: No module named 'rules_python~0'
Problem importing module nested_min_max.py: No module named 'rules_python~0'
Problem importing module newstyle.py: No module named 'rules_python~0'
Problem importing module non_ascii_names.py: No module named 'rules_python~0'
Problem importing module raw_metrics.py: No module named 'rules_python~0'
Problem importing module refactoring: No module named 'rules_python~0'
Problem importing module similar.py: No module named 'rules_python~0'
Problem importing module spelling.py: No module named 'rules_python~0'
Problem importing module stdlib.py: No module named 'rules_python~0'
Problem importing module strings.py: No module named 'rules_python~0'
Problem importing module threading_checker.py: No module named 'rules_python~0'
Problem importing module typecheck.py: No module named 'rules_python~0'
Problem importing module unicode.py: No module named 'rules_python~0'
Problem importing module unsupported_version.py: No module named 'rules_python~0'
Problem importing module utils.py: No module named 'rules_python~0'
Problem importing module variables.py: No module named 'rules_python~0'
Problem importing module base_reporter.py: No module named 'rules_python~0'
Problem importing module collecting_reporter.py: No module named 'rules_python~0'
Problem importing module json_reporter.py: No module named 'rules_python~0'
Problem importing module multi_reporter.py: No module named 'rules_python~0'
Problem importing module reports_handler_mix_in.py: No module named 'rules_python~0'
Problem importing module text.py: No module named 'rules_python~0'
Problem importing module ureports: No module named 'rules_python~0'
Traceback (most recent call last):
  File "C:\Users\alexa\AppData\Local\Temp\Bazel.runfiles_96fusd3n\runfiles\_main\entry_points\rules_python_entry_point_pylint.py", line 19, in 
    sys.exit(run_pylint())
             ^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Temp\Bazel.runfiles_96fusd3n\runfiles\rules_python~0.27.0~pip~pip_extensions_311_pylint\site-packages\pylint\__init__.py", line 34, in run_pylint
    PylintRun(argv or sys.argv[1:])
  File "C:\Users\alexa\AppData\Local\Temp\Bazel.runfiles_96fusd3n\runfiles\rules_python~0.27.0~pip~pip_extensions_311_pylint\site-packages\pylint\lint\run.py", line 162, in __init__
    args = _config_initialization(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alexa\AppData\Local\Temp\Bazel.runfiles_96fusd3n\runfiles\rules_python~0.27.0~pip~pip_extensions_311_pylint\site-packages\pylint\config\config_initialization.py", line 114, in _config_initialization
    for exc_name in linter.config.overgeneral_exceptions:
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'overgeneral_exceptions'

🌍 Your Environment

Operating System:

  
Windows 10
  

Output of bazel version:

  
bazel 7.0.0rc4
  

Rules_python version:

  
0.27.0
  

Anything else relevant?

wizard29 avatar Nov 22 '23 10:11 wizard29

Hey Guys, I just rechecked the workspace configuration instead of the blzmod. It works properly. So, there is some problem with the bzlmod only.

wizard29 avatar Nov 26 '23 15:11 wizard29

I found a workaround of the problem with the bzlmod.

bazel_dep(name = "rules_python", version = "0.27.0")

archive_override(
    module_name = "rules_python",
    integrity = "sha256-mswJRMlK2yP7ocmYi0h2ixusxlg7UqJYaJXFt0keLjE=",
    strip_prefix = "rules_python-0.27.0",
    urls = ["https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz"],
)

Solves the issue but it doesn't seem to be a smooth solution. Hope this will be fixed.

wizard29 avatar Nov 26 '23 16:11 wizard29

I wonder how #1766 would affect this.

aignas avatar Feb 29 '24 01:02 aignas

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[bot] avatar Aug 27 '24 22:08 github-actions[bot]