bazel-contrib / bazel-contrib/rules_python

[proposal] requires_python attribute

Ouverte
#2,444 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Starlark
Étoiles
688
Forks
721
Merge moyen
15 h 7 min
PR mergées (30 j)
76

Description

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?

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par examiner la proposition d’un attribut PyInfo.requires_python et la manière dont py_binary valide actuellement ses sources. Examinez comment la plage de contraintes serait liée à setuptools et si rules_lint pourrait limiter le linting aux sources compatibles. Pour considérer le travail comme terminé, il faudrait disposer d’une conception approuvée et d’un comportement clairement défini pour la vérification de cohérence, ce que l’issue ne spécifie pas encore.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
build-system
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.