bazel-contrib / bazel-contrib/rules_python

[proposal] requires_python attribute

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

描述

While having a global Python interpreter choice works fine for small repositories, in large repositories there are potentially considerable code compatibility concerns across interpreter/virtualenv versions and migrations of language versions require supporting split states where some targets have converted and others may not have converted.

Today it's possible to set up multiple Python toolchains and multiple virtualenvs and use build configuration to choose how a given target or group are built/tested and that works fine.

A problem we've encountered is that users who wish to _drop backwards compatibility_ have a hard time doing so in a sound way. Consider a service which has been able to adopt a new interpreter and would like to adopt new language features such as `:=` or `match`. Code which has adopted a syntax extension feature like this is no longer backwards compatible to earlier interpreters which can cause problems both in linting and if there are targets configured for older interpreters which depend on targets that have adopted these features.

The idea I've been kicking around is to extend `PyInfo` with a `requires_python` attribute expressing the interpreter constraint range same as in `setuptools`. It should also be possible for at a minimum the `py_binary` rule implementation to perform a consistency check over all the `PyInfo.requires_python` values and ensure that the rule as defined contains only compatible sources. It would also be desirable to be able to restrict eg. `rules_lint` behavior so that 3.8 linting would be applied only to 3.8 compatible sources; the alternative being choking on 3.11 features.

Thoughts?

贡献指南

打开贡献指南

调研方向

首先审查 PyInfo.requires_python 属性的提案,以及 py_binary 当前如何验证其源文件。考虑约束范围将如何与 setuptools 关联,以及 rules_lint 是否可以将 linting 限制为兼容的源文件。要视为完成,需要一份达成共识的设计和明确的⼀致性检查行为,而 issue 目前尚未对此作出规定。

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

评估

技术栈
python
领域
build-system
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

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