Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Starting from version 2.0.0 is no longer allowed to have a package called lib in the root

Aperta
#3,784 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
build-system

Direzione di ricerca

Inizia con la riproduzione minima collegata, in particolare bin.py e lib.py, usando rules_python 2.0.0 o 2.0.1 e la configurazione Bazel su Windows segnalata. Traccia il modo in cui py_binary e py_library costruiscono il percorso di importazione dei runfiles, quindi aggiungi un test di regressione che copra un import di lib.py dalla radice e conferma che l’esempio non risolva più lib nel pacchetto dell’ambiente generato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🐞 bug report

Affected Rule

py_binary + py_library

Is this a regression?

Yes, it started with 2.0.0, before that the problem was not there

Description

It is no longer possible to have a lib.py in the root and import it.
It seems that this colides now with some lib that is in the path. This was before not the case.
Considering that lib is not a Python library, I would not have expected having any colision.

🔬 Minimal Reproduction

You can grab this example and upgrade to rules_python 2.0.0
https://github.com/limdor/bazel-examples/tree/v1.8.0/python

🔥 Exception or Error

Traceback (most recent call last):
  File "c:\b\t45fapsg\execroot\_main\bazel-out\x64_windows-fastbuild-st-591ff087943d\bin\bin.exe.runfiles\_main\_bin_stage2_bootstrap.py", line 541, in <module>
    main()
  File "c:\b\t45fapsg\execroot\_main\bazel-out\x64_windows-fastbuild-st-591ff087943d\bin\bin.exe.runfiles\_main\_bin_stage2_bootstrap.py", line 535, in main
    _run_py_path(main_filename, args=sys.argv[1:])
  File "c:\b\t45fapsg\execroot\_main\bazel-out\x64_windows-fastbuild-st-591ff087943d\bin\bin.exe.runfiles\_main\_bin_stage2_bootstrap.py", line 323, in _run_py_path
    runpy.run_path(main_filename, run_name="__main__")
  File "<frozen runpy>", line 291, in run_path
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "c:\b\t45fapsg\execroot\_main\bazel-out\x64_windows-fastbuild-st-591ff087943d\bin\bin.exe.runfiles\_main\bin.py", line 1, in <module>
    from lib import sum
ImportError: cannot import name 'sum' from 'lib' (C:\temp\bazel._bin.venv.l8l95vit\lib\__init__.py)
bazel run failed with exit code 1

🌍 Your Environment

Operating System:

Windows

Output of bazel version:

8.7.0

Rules_python version:

2.0.0 as well as 2.0.1

Anything else relevant?

That is not a big issue for me, I workaround the problem my renaming lib.py to my_lib.py. However the bigger question would be what are the names that can have problems and the ones that not? I could have imagine names from the Python standard library to have problems with it but afaik lib is not one of them.

Lingua principale
Starlark
Stelle
690
Fork
722
Merge medio
1g 55m
PR unite (30g)
38

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bazel-contrib/rules_python

Tutte le issue di bazel-contrib/rules_python

Issue simili

Altre issue su Build System

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.