bazel-contrib / bazel-contrib/rules_python

`local_runtime_repo` writes absolute path of Xcode on macOS

未关闭
#3,123 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
help wanted
主要语言
Starlark
星标
688
派生
721
平均合并
15 小时 7 分钟
30 天内合并 PR
76

描述

# 🐞 bug report

(Sorry for all the annoying macOS specific bugs!)

### Affected Rule

The issue is caused by the rule: `local_runtime_repo`

### Is this a regression?

Yes(?)

### Description

Starting with this change: https://github.com/bazel-contrib/rules_python/pull/2760/files#diff-33a51eb016b4b2a4b53d940f07c5388bd572ef61689051bc6f266ea7e5533c72R99

If running on macOS, `/usr/bin/python3` is a system shim that will run a Python runtime located within Xcode. The path of Xcode will then show up in `base_executable`:

```
❯ /usr/bin/python3 python/private/get_local_runtime_info.py
{"major": 3, "minor": 9, "micro": 6, "include": "/Library/Python/3.9/include", "implementation_name": "cpython", "base_executable": "/Applications/Xcode-26.0.0-Beta.app/Contents/Developer/usr/bin/python3", "LDLIBRARY": "Python3.framework/Versions/3.9/Python3", "LIBDIR": "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/lib", "INSTSONAME": "Python3.framework/Versions/3.9/Python3", "PY3LIBRARY": "", "SHLIB_SUFFIX": ".so"}
```

This path then ends up in the run script for i.e. `py_binary`:

```
76: PYTHON_BINARY = '/Applications/Xcode-26.0.0-Beta.app/Contents/Developer/usr/bin/python3'
```

## 🔬 Minimal Reproduction

1. macOS
2. `local_runtime_repo` setup with `interpreter_path = "/usr/bin/python3"`
3. build a `py_binary` target and observe the resulting run script
4. Change/move your Xcode version or path and rebuild. The `py_binary` path will be unchanged.

贡献指南

打开贡献指南

调研方向

从 python/private/get_local_runtime_info.py 和 local_runtime_repo 规则开始,然后使用 interpreter_path="/usr/bin/python3" 和一个 py_binary 目标复现 macOS 情况。跟踪 base_executable 如何到达生成的运行脚本;完成的标准是,在更改或移动 Xcode 后重新构建,不会再让旧的 Xcode 路径嵌入该脚本中。

由索引模型根据 Issue 内容生成。

评估

技术栈
macos, python
领域
build-system, operating-systems
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。