Surfacing all bootstrap runfiles in PyExecutableInfo
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 52/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- Calme
- Stack technique
- python
- Domaine
- build-system
Piste de recherche
Lisez python/private/py_executable.bzl et python/private/py_executable_info.bzl, en commençant par _create_providers et le chemin files_without_interpreter existant. Suivez la manière dont stage2 bootstrap et les fichiers venv parviennent à app_runfiles, puis vérifiez que le champ runfiles choisi est exposé pour py_binary et py_test et documenté pour les consommateurs.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
🚀 feature request
Relevant Rules
Adding a runfile object containing all "runfiles" of the (stage2) bootstrappers to PyExecutableInfo (impacts py_binary, py_test).
Description
We have a custom collect_layers rule that takes a py_binary and produces different output groups that map to different layers in an OCI image that will be built in downstream rules. Most of this is captured by PyRuntimeInfo (for the interpreter) and PyExecutableInfo.app_runfiles - however, we would like to split 3rd party deps/runfiles (from PyPI) and our own code into different layers for optimization. At the moment, we are effectively rebuilding similar depsets to app_runfiles but are doing so via an aspect that traverses the build graph in order to do so efficiently without flattening the depset.
https://github.com/bazel-contrib/rules_python/issues/3324 added extra fields to identify the stage2_bootstrap, but additional files required by the stage2 bootstrapper to work correctly (like the venv site-packages files venv _bazel_site_init.pth and bazel_site_init.py) are still only surfaced via the PyExecutableInfo.app_runfiles - this makes it impossible to add them to my output groups without flattening that depset which is not desirable.
Describe the solution you'd like
It would be great if PyExecutableInfo could return a stage2_runfiles (for stage2 specifically) or bootstrap_runfiles (for all bootstrap-related files) fields which includes any additional runfiles it needs.
Describe alternatives you've considered
At the moment, these "extra runfiles" are already modeled somewhat in code under files_without_interpreter, we just surface them via a targeted patch of the provider like so:
# This patch is for rules_python 1.9.0, as of time of writing
diff --git python/private/py_executable.bzl python/private/py_executable.bzl
index 284aea6b..95bb4676 100644
--- python/private/py_executable.bzl
+++ python/private/py_executable.bzl
@@ -491,6 +491,7 @@ WARNING: Target: {}
app_runfiles = app_runfiles.build(ctx),
# File|None; the venv `bin/python3` file, if any.
venv_python_exe = venv.interpreter if venv else None,
+ files_without_interpreter = venv.files_without_interpreter if venv else None,
)
def _create_zip_main(ctx, *, stage2_bootstrap, runtime_details, venv):
@@ -1094,6 +1095,7 @@ def py_executable_base_impl(ctx, *, semantics, is_test, inherited_environment =
app_runfiles = app_runfiles,
venv_python_exe = exec_result.venv_python_exe,
interpreter_args = ctx.attr.interpreter_args,
+ files_without_interpreter = exec_result.files_without_interpreter,
)
def _get_build_info(ctx, cc_toolchain):
@@ -1639,7 +1641,8 @@ def _create_providers(
stage2_bootstrap,
app_runfiles,
venv_python_exe,
- interpreter_args):
+ interpreter_args,
+ files_without_interpreter):
"""Creates the providers an executable should return.
Args:
@@ -1700,6 +1703,7 @@ def _create_providers(
app_runfiles = app_runfiles,
venv_python_exe = venv_python_exe,
interpreter_args = interpreter_args,
+ files_without_interpreter = files_without_interpreter,
),
]
diff --git python/private/py_executable_info.bzl python/private/py_executable_info.bzl
index defbd3a0..c1b7592a 100644
--- python/private/py_executable_info.bzl
+++ python/private/py_executable_info.bzl
@@ -87,5 +87,6 @@ mode is not enabled.
:::{versionadded} 1.9.0
:::
""",
+ "files_without_interpreter": "Extra files required by the stage2 bootstrapper",
},
)
At the moment, we are still relying on bootstrap_impl=system_python (but "hack" the shebang to point to the interpreter in runfiles - this is the very first layer in the image before the other two).
I believe that the venv/bin/python3 symlink is also required for the stage1 bootstrap if one were to use bootstrap_impl=script - if so, it might be nicer to model this as a a generic bootstrap_runfiles field in which all bootstrap runfiles could live (so everything under venv and the stage2 bootstrap file itself)?
- Langage dominant
- Starlark
- Étoiles
- 687
- Forks
- 726
- Merge moyen
- 1 j 7 h
- PR mergées (30 j)
- 77
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de bazel-contrib/rules_python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
bazel-contrib/rules_python#4251 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
bazel-contrib/rules_python#4164 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
go:embed stdlib_list.txt file in gazelle/python/std_modules.go is missingPeut-être pris @udaya2899 l’a pris il y a 16 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
bazel-contrib/rules_python#3821 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
bazel-contrib/rules_python#4269 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
bazel-contrib/rules_python#4250 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de bazel-contrib/rules_python
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
crossplane/cli#432 ·
Les mainteneurs répondent en général sous 3 jours
-
Build: the CUDA backend fails without cuDNN instead of skipping the cuDNN shim (as the cuDF shim does)Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
beehive-lab/TornadoVM#1248 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
SimVascular/svZeroDSolver#253 ·
-
docs hermes medium
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Popoboxxo/ReqogniLoom#1353 ·
Les mainteneurs répondent en général sous 1 jour
-
difficulty: easy domain: devops effort: 1-4h enhancement good first issue smart-contracts Stellar Wave
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Kaycee276/Chesster#469 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour