bazel-contrib / bazel-contrib/rules_python

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

オープン
#3,784 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Starlark
スター
688
フォーク
721
平均マージ
15時間 7分
マージ済み PR(30日)
76

説明

# 🐞 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
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 "", line 291, in run_path
File "", line 98, in _run_module_code
File "", 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
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.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされた最小再現ケースから始め、特に bin.py と lib.py を、rules_python 2.0.0 または 2.0.1 と報告されている Windows の Bazel セットアップで確認します。py_binary と py_library が runfiles のインポートパスをどのように構築するかを追跡し、次にルートの lib.py のインポートを対象とする回帰テストを追加して、example で lib が生成された環境パッケージに解決されなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
build-system
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。