bazel-contrib / bazel-contrib/rules_python

Windows: `pywin32` doesn't work with the hermetic Python toolchain

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

説明

# 🐞 bug report

### Affected Rule

rules_python

### Is this a regression?

Probably not.

### Description

I'm trying to do `import win32api` on Windows, but got
```
ModuleNotFoundError: No module named 'win32api'
```
even if I specify `pywin32==303` in the requirements.txt file.

## 🔬 Minimal Reproduction

Fetch the reproducible case at https://github.com/meteorcloudy/my_tests/tree/master/pywin32_test

then run
```
bazel run //:bin
```

## 🔥 Exception or Error

$ bazel run //:bin
INFO: Invocation ID: 3c7000e6-65e3-4816-a2b5-551faa933a03
INFO: Reading 'startup' options from c:\users\pcloudy\.bazelrc: --output_user_root=C:/src/tmp
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=375
INFO: Options provided by the client:
Inherited 'build' options: --python_path=C:/python3/python.exe
INFO: Reading rc options for 'run' from c:\users\pcloudy\.bazelrc:
Inherited 'build' options: --curses=yes --color=yes --verbose_failures --announce_rc --disk_cache=C:/src/tmp/bazel_disk_cache
INFO: Analyzed target //:bin (40 packages loaded, 3463 targets configured).
INFO: Found 1 target...
Target //:bin up-to-date:
bazel-bin/bin.exe
bazel-bin/bin.zip
INFO: Elapsed time: 15.868s, Critical Path: 7.96s
INFO: 6 processes: 5 internal, 1 local.
INFO: Build completed successfully, 6 total actions
INFO: Running command line: bazel-bin/bin.exe
Traceback (most recent call last):
File "C:\temp\2\Bazel.runfiles_s_pq9z9_\runfiles\__main__\bin.py", line 1, in
import win32api
ModuleNotFoundError: No module named 'win32api'

## 🌍 Your Environment

**Operating System:**

  

Windows

**Output of `bazel version`:**

  

6.3.1

**Rules_python version:**

  

0.24.0

**Anything else relevant?**
If I do `import win32.win32api`, I get
```
ImportError: DLL load failed while importing win32api: The specified module could not be found.
```

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

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

調査の方向性

リンクされた pywin32_test の再現手順、その requirements.txt、およびエントリポイント bazel run //:bin から始め、rules_python の hermetic toolchain が Windows 上で pywin32 をどのように扱うかを調べます。不足している win32api の import と DLL-load エラーを再現し、その後、サンプルが pywin32==303 で正常に実行されることを確認します。

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

評価

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

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

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