Deprecate and remove implicit py_binary zipapp support
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- build-system
Rechercherichtung
Durchsuche das Repository nach build_python_zip und python_zip_file und untersuche anschließend die referenzierten BUILD-Dateien, my_rule.bzl-Implementierungen und rule.bzl-Transitions. Vergleiche jede Verwendung mit den Migrationsfällen in diesem Issue und identifiziere die betroffenen Bazel-Ziele. Erledigt bedeutet, dass alte implizite zipapp-Pfade entfernt oder zu py_zipapp_binary oder py_zipapp_test migriert wurden, ohne die relevanten Builds zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The implicit zipapp support of py_binary and py_test is being deprecated and removed. It is replaced by the py_zipapp_binary and py_zipapp_test rules. There are several ways the implicit zipapp logic may be activated.
For reference, these are the two loads you're most likely to need:
load("@rules_python//python/zipapp:py_zipapp_binary.bzl", "py_zipapp_binary")
load("@rules_python//python/zipapp:py_zipapp_test.bzl", "py_zipapp_test")
The flag name you want to look for is build_python_zip.
Windows-specific note: Windows enables zipapp by default, so the absence of the flag is the same as
--build_python_zip=true!
Migration guide
This guide tries to give information on how to handle all possible cases of what may need to be migrated. Most changes are small, should be transparent, and can be done incrementally.
In practice, the most likely scenario you'll need to fix is using the
--build_python_zip flag on the command line -- see the "Migrate explicit --build_python_zip" section for that case.
Disable legacy zipapp flag
Add common --build_python_zip=false --@rules_python//python/config_settings:build_python_zip=false to your .bazelrc
Windows-specific note: Windows enables zipapp by default
Migrate explicit --build_python_zip usage
TLDR: Replace --build_python_zip on the command line with a py_zipapp_binary target in a BUILD file.
Replace this:
# File: BUILD
py_binary(name="bin")
# Command line
bazel build //:bin --build_python_zip
With this:
# File: BUILD
load("@rules_python//python/zipapp:py_zipapp_binary", "py_zipapp_binary")
py_binary(name="bin")
py_zipapp_binary(name = "bin_zipapp", binary=":bin")
# Command line
bazel build //:bin_zipapp
Migrate py_binary using config_settings with py_zipapp rule
TLDR: Add py_zipapp_binary for each py_binary you want as a zipapp
Replace this:
py_binary(
name = "bin"
config_settings = {
"@rules_python//python/config:build_python_zip": "true",
"//command_line_option:build_python_zip": "true",
},
...
)
With this:
load("@rules_python//python/zipapp:py_zipapp_binary", "py_zipapp_binary")
py_binary(
name = "bin"
...
)
py_zipapp_binary(
name = "bin.zipapp",
binary = ":bin",
)
Migrate filegroup using python_zip_file output group
Replace this:
TLDR: Add py_zipapp_binary and point the filegroup to it.
py_binary(name = "bin", ...)
filegroup(
name = "bin_zip_file",
output_group = "python_zip_file",
srcs = [":bin"],
)
With this:
load("@rules_python//python/zipapp:py_zipapp_binary", "py_zipapp_binary")
py_binary(name = "bin", ...)
py_zipapp_binary(name = "bin_zipapp", binary=":bin")
filegroup(
name = "bin_zip_file",
output_group = "python_zip_file",
srcs = [":bin_zipapp"],
)
Migrate Starlark using python_zip_file output group
TLDR: Add py_zipapp target and use it as the input target instead.
Replace this:
# File: my_rule.bzl
def _my_rule_impl(ctx):
zip_file = ctx.attr.binary[OutputGroupInfo]["python_zip_file"].to_list()[0]
# File: BUILD.bazel
py_binary(name="bin", ...)
my_rule(name = "mytarget", binary=":bin", ...)
With this:
# File: my_rule.bzl
def _my_rule_impl(ctx):
zip_file = ctx.attr.binary[OutputGroupInfo]["python_zip_file"].to_list()[0]
# File: BUILD.bazel
load("@rules_python//python/zipapp:py_zipapp_binary", "py_zipapp_binary")
py_binary(name="bin", ...)
py_zipapp_binary(name = "bin_zipapp", binary=":bin")
my_rule(name = "mytarget", binary=":bin_zipapp", ...)
Migration transitions setting build_python_zip flags
TLDR: Remove the build_python_zip flags from the transition and refactor into a separate target.
Replace this:
# File: rule.bzl
my_transition = transition(
outputs = [
"//command_line_settings:build_python_zip",
"@rules_python//python/config_settings:build_python_zip",
],
...
)
my_rule(cfg = my_transition, ...)
# File: BUILD
py_binary(name="bin", ...)
my_rule(target=":bin")
With this:
# File: rule.bzl
my_transition = transition(
outputs = [],
...
)
my_rule(cfg = my_transition, ...)
# File: BUILD
load("@rules_python//python/zipapp:py_zipapp_binary", "py_zipapp_binary")
py_binary(name="bin", ...)
py_zipapp_binary(name="bin_zipapp", binary=":bin")
my_rule(target=":bin_zipapp")
- Vorherrschende Sprache
- Starlark
- Sterne
- 687
- Forks
- 726
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 77
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus bazel-contrib/rules_python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bazel-contrib/rules_python#4251 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
bazel-contrib/rules_python#4164 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
go:embed stdlib_list.txt file in gazelle/python/std_modules.go is missingEvtl. vergeben @udaya2899 hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
bazel-contrib/rules_python#3821 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
bazel-contrib/rules_python#4269 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
bazel-contrib/rules_python#4250 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in bazel-contrib/rules_python
Ähnliche Issues
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
libsdl-org/SDL#16530 ·
Maintainer antworten meist innerhalb von 1 Tag
-
complexity: trivial good first issue impact: low
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
ueberdosis/tiptap#8522 ·
Maintainer antworten meist innerhalb von 1 Tag
-
in: build type: dependency-upgrade
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 62/100
spring-projects/spring-ldap#1791 ·
Maintainer antworten meist innerhalb von 1 Tag
-
:maddi-inspection-kotlin:test runs out of heap in a full maddi test run; exit 1 with no failing testOffenbuild/ci front-end:kotlin
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
taisei-project/taisei#454 ·