bazel-contrib / bazel-contrib/rules_python

Runtime error python3xy.dll not found: Missing srcs in python_repository's libpython rule for os:windows

Đang mở
#1,823 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
type: toolchain
Ngôn ngữ chính
Starlark
Star
688
Fork
721
Merge trung bình
15 giờ 7 phút
Pull request đã merge (30 ngày)
76

Mô tả

# 🐞 bug report

The srcs attribute for this cc_library for os:windows is` ["python3.dll", "libs/python{python_version_nodot}.lib"]`. It is missing the version-specific binary, eg python311.dll.

https://github.com/bazelbuild/rules_python/blob/c5c03b2477dd1ce0c06c9dc60bf816995f222bcf/python/repositories.bzl#L318-L326

This will result in a runtime error (python311.dll not found) in the following scenario.
1. User creates a cc_binary which has `#include ` and which depends on the libpython above.
2. User never defines `#Py_LIMITED_ABI `
3. User attempts to run the cc_binary

The Python.h includes the pyconfig.h, which causes msvc to attempt linking against python3xy.dll via the` #pragma comment(lib, ...) `mechanism. The relevant code from the cpython project is here.
https://github.com/python/cpython/blob/d610d821fd210dce63a1132c274ffdf8acc510bc/PC/pyconfig.h.in#L315-L331

I have resolved this locally by globbing *.dll into the libpython cc_library.

A similar issue occurs if the user defines `#Py_DEBUG`, which causes msvc to attempt linking against the debug binary python3xy_d.dll. I did not see a way to request debug binaries using the python_repository rule but if that were enabled, I think globbing *.dll would fix that case too.

### Affected Rule

python_repository

### Is this a regression?

Unsure.

### Description

See above.

## 🔬 Minimal Reproduction

See above.

## 🔥 Exception or Error

Runtime error python3xy.dll not found

## 🌍 Your Environment

**Operating System:**

  

Windows 10

**Output of `bazel version`:**

  

7.0.2

**Rules_python version:**

  

0.31.0

**Anything else relevant?**

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

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

Hướng nghiên cứu

Bắt đầu trong python/repositories.bzl, quanh các dòng 318-326, nơi cc_library libpython dành cho Windows định nghĩa srcs của nó. Tái hiện kịch bản cc_binary được báo cáo trên Windows và kiểm tra cách Python.h chọn DLL runtime dành riêng cho phiên bản. Hoàn thành khi target được tạo cung cấp python3xy.dll cần thiết trong thời gian chạy mà không xuất hiện lỗi thiếu DLL đã được báo cáo.

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

Đánh giá

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

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.