Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#3,784 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
python
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu với bản tái hiện tối thiểu được liên kết, đặc biệt là bin.py và lib.py, sử dụng rules_python 2.0.0 hoặc 2.0.1 cùng với thiết lập Bazel trên Windows đã được báo cáo. Theo dõi cách py_binary và py_library xây dựng đường dẫn import runfiles, sau đó thêm một bài kiểm thử hồi quy bao quát việc import lib.py ở thư mục gốc và xác nhận rằng ví dụ không còn phân giải lib thành package môi trường được tạo nữa.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

🐞 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.

Ngôn ngữ chính
Starlark
Star
690
Fork
722
Merge trung bình
1 ngày 55 phút
Pull request đã merge (30 ngày)
38

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bazel-contrib/rules_python

Tất cả issue của bazel-contrib/rules_python

Issue tương tự

Thêm issue về Build System

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.