-
Notifications
You must be signed in to change notification settings - Fork 1.3k
rework python build #1918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
rework python build #1918
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,127 +1,25 @@ | ||
| load("@container_structure_test//:defs.bzl", "container_structure_test") | ||
| load("@rules_oci//oci:defs.bzl", "oci_image", "oci_image_index") | ||
| load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
| load("//:checksums.bzl", ARCHITECTURES = "BASE_ARCHITECTURES") | ||
| load("//private/util:deb.bzl", "deb") | ||
| load("//:checksums.bzl", "BASE_ARCHITECTURES") | ||
| load(":python.bzl", "python3_image", "python3_image_index") | ||
|
|
||
| package(default_visibility = ["//visibility:public"]) | ||
|
|
||
| USERS = [ | ||
| "root", | ||
| "nonroot", | ||
| ] | ||
|
|
||
| DISTROS = [ | ||
| "debian12", | ||
| ] | ||
|
|
||
| DISTRO_VERSION = { | ||
| "debian12": "3.11", | ||
| } | ||
|
|
||
| [ | ||
| pkg_tar( | ||
| name = "python_aliases_%s" % distro, | ||
| symlinks = { | ||
| "/usr/bin/python": "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| "/usr/bin/python3": "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| }, | ||
| ) | ||
| for distro in DISTROS | ||
| ] | ||
| PYTHON_DISTROS = ["debian12"] | ||
|
|
||
| [ | ||
| oci_image_index( | ||
| name = ("python3" if (not mode) else mode[1:]) + "_" + user + "_" + distro, | ||
| images = [ | ||
| ("python3" if (not mode) else mode[1:]) + "_" + user + "_" + arch + "_" + distro | ||
| for arch in ARCHITECTURES | ||
| ], | ||
| ) | ||
| for mode in [ | ||
| "", | ||
| ":debug", | ||
| ] | ||
| for user in USERS | ||
| for distro in DISTROS | ||
| ] | ||
|
|
||
| [ | ||
| oci_image( | ||
| name = ("python3" if (not mode) else mode[1:]) + "_" + user + "_" + arch + "_" + distro, | ||
| # Based on //cc so that C extensions work properly. | ||
| base = "//cc" + (":cc_debug" if mode else ":cc") + "_" + user + "_" + arch + "_" + distro, | ||
| entrypoint = [ | ||
| "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| ], | ||
| # Use UTF-8 encoding for file system: match modern Linux | ||
| env = {"LANG": "C.UTF-8"}, | ||
| tars = [ | ||
| deb.package(arch, distro, "libbz2-1.0", "python"), | ||
| deb.package(arch, distro, "libdb5.3", "python"), | ||
| deb.package(arch, distro, "libexpat1", "python"), | ||
| deb.package(arch, distro, "liblzma5", "python"), | ||
| deb.package(arch, distro, "libsqlite3-0", "python"), | ||
| deb.package(arch, distro, "libuuid1", "python"), | ||
| deb.package(arch, distro, "libncursesw6", "python"), | ||
| deb.package(arch, distro, "libtinfo6", "python"), | ||
| deb.package(arch, distro, "python3-distutils", "python"), | ||
| deb.package(arch, distro, "zlib1g", "python"), | ||
| deb.package(arch, distro, "libcom-err2", "python"), | ||
| deb.package(arch, distro, "libcrypt1", "python"), | ||
| deb.package(arch, distro, "libgssapi-krb5-2", "python"), | ||
| deb.package(arch, distro, "libk5crypto3", "python"), | ||
| deb.package(arch, distro, "libkeyutils1", "python"), | ||
| deb.package(arch, distro, "libkrb5-3", "python"), | ||
| deb.package(arch, distro, "libkrb5support0", "python"), | ||
| deb.package(arch, distro, "libnsl2", "python"), | ||
| deb.package(arch, distro, "libreadline8", "python"), | ||
| deb.package(arch, distro, "libtirpc3", "python"), | ||
| deb.package(arch, distro, "libffi8", "python"), | ||
| deb.package(arch, distro, "libpython3.11-minimal", "python"), | ||
| deb.package(arch, distro, "libpython3.11-stdlib", "python"), | ||
| deb.package(arch, distro, "python3.11-minimal", "python"), | ||
| ":python_aliases_%s" % distro, | ||
| ], | ||
| ) | ||
| for mode in [ | ||
| "", | ||
| ":debug", | ||
| ] | ||
| for user in USERS | ||
| for arch in ARCHITECTURES | ||
| for distro in DISTROS | ||
| ] | ||
| PYTHON_ARCHITECTURES = BASE_ARCHITECTURES | ||
|
|
||
| [ | ||
| container_structure_test( | ||
| name = "python3_" + user + "_" + arch + "_" + distro + "_test", | ||
| size = "medium", | ||
| configs = ["testdata/python3.yaml"], | ||
| image = ":python3_" + user + "_" + arch + "_" + distro, | ||
| tags = [ | ||
| "manual", | ||
| arch, | ||
| ], | ||
| python3_image( | ||
| arch = arch, | ||
| distro = distro, | ||
| ) | ||
| for user in USERS | ||
| for arch in ARCHITECTURES | ||
| for distro in DISTROS | ||
| for distro in PYTHON_DISTROS | ||
| for arch in PYTHON_ARCHITECTURES | ||
| ] | ||
|
|
||
| # tests for version-specific things | ||
| [ | ||
| container_structure_test( | ||
| name = "version_specific_" + user + "_" + arch + "_" + distro + "_test", | ||
| size = "medium", | ||
| configs = ["testdata/" + distro + ".yaml"], | ||
| image = ":python3_" + user + "_" + arch + "_" + distro, | ||
| tags = [ | ||
| "manual", | ||
| arch, | ||
| ], | ||
| python3_image_index( | ||
| architectures = PYTHON_ARCHITECTURES, | ||
| distro = distro, | ||
| ) | ||
| for user in USERS | ||
| for arch in ARCHITECTURES | ||
| for distro in DISTROS | ||
| for distro in PYTHON_DISTROS | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| load("@container_structure_test//:defs.bzl", "container_structure_test") | ||
| load("@rules_oci//oci:defs.bzl", "oci_image", "oci_image_index") | ||
| load("@rules_pkg//:pkg.bzl", "pkg_tar") | ||
| load("//private/util:deb.bzl", "deb") | ||
|
|
||
| USERS = ["root", "nonroot"] | ||
| DEBUG_MODE = ["", "_debug"] | ||
|
|
||
| DISTRO_VERSION = { | ||
| "debian12": "3.11", | ||
| } | ||
|
|
||
| def python_alias(distro): | ||
| if native.existing_rule("python_aliases_" + distro): | ||
| return | ||
|
|
||
| pkg_tar( | ||
| name = "python_aliases_" + distro, | ||
| symlinks = { | ||
| "/usr/bin/python": "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| "/usr/bin/python3": "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| }, | ||
| ) | ||
|
|
||
| def python3_image_index(distro, architectures): | ||
| """python image index for a distro | ||
|
|
||
| Args: | ||
| distro: name of distribution | ||
| architectures: all architectures included in index | ||
| """ | ||
| [ | ||
| oci_image_index( | ||
| name = "python3" + mode + "_" + user + "_" + distro, | ||
| images = [ | ||
| "python3" + mode + "_" + user + "_" + arch + "_" + distro | ||
| for arch in architectures | ||
| ], | ||
| ) | ||
| for mode in DEBUG_MODE | ||
| for user in USERS | ||
| ] | ||
|
|
||
| def python3_image(distro, arch): | ||
| python_alias(distro) | ||
|
|
||
| [ | ||
| oci_image( | ||
| name = "python3" + mode + "_" + user + "_" + arch + "_" + distro, | ||
| # Based on //cc so that C extensions work properly. | ||
| base = "//cc:cc" + mode + "_" + user + "_" + arch + "_" + distro, | ||
| entrypoint = [ | ||
| "/usr/bin/python" + DISTRO_VERSION[distro], | ||
| ], | ||
| # Use UTF-8 encoding for file system: match modern Linux | ||
| env = {"LANG": "C.UTF-8"}, | ||
| tars = [ | ||
| deb.package(arch, distro, "libbz2-1.0", "python"), | ||
| deb.package(arch, distro, "libdb5.3", "python"), | ||
| deb.package(arch, distro, "libexpat1", "python"), | ||
| deb.package(arch, distro, "liblzma5", "python"), | ||
| deb.package(arch, distro, "libsqlite3-0", "python"), | ||
| deb.package(arch, distro, "libuuid1", "python"), | ||
| deb.package(arch, distro, "libncursesw6", "python"), | ||
| deb.package(arch, distro, "libtinfo6", "python"), | ||
| deb.package(arch, distro, "python3-distutils", "python"), | ||
| deb.package(arch, distro, "zlib1g", "python"), | ||
| deb.package(arch, distro, "libcom-err2", "python"), | ||
| deb.package(arch, distro, "libcrypt1", "python"), | ||
| deb.package(arch, distro, "libgssapi-krb5-2", "python"), | ||
| deb.package(arch, distro, "libk5crypto3", "python"), | ||
| deb.package(arch, distro, "libkeyutils1", "python"), | ||
| deb.package(arch, distro, "libkrb5-3", "python"), | ||
| deb.package(arch, distro, "libkrb5support0", "python"), | ||
| deb.package(arch, distro, "libnsl2", "python"), | ||
| deb.package(arch, distro, "libreadline8", "python"), | ||
| deb.package(arch, distro, "libtirpc3", "python"), | ||
| deb.package(arch, distro, "libffi8", "python"), | ||
| deb.package(arch, distro, "libpython3.11-minimal", "python"), | ||
| deb.package(arch, distro, "libpython3.11-stdlib", "python"), | ||
| deb.package(arch, distro, "python3.11-minimal", "python"), | ||
| ":python_aliases_%s" % distro, | ||
| ], | ||
| ) | ||
| for mode in DEBUG_MODE | ||
| for user in USERS | ||
| ] | ||
loosebazooka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| [ | ||
| container_structure_test( | ||
| name = "python3_" + user + "_" + arch + "_" + distro + "_test", | ||
| size = "medium", | ||
| configs = ["testdata/python3.yaml"], | ||
| image = ":python3_" + user + "_" + arch + "_" + distro, | ||
| tags = [ | ||
| "manual", | ||
| arch, | ||
| ], | ||
| ) | ||
| for user in USERS | ||
| ] | ||
|
|
||
| # tests for version-specific things | ||
| [ | ||
| container_structure_test( | ||
| name = "version_specific_" + user + "_" + arch + "_" + distro + "_test", | ||
| size = "medium", | ||
| configs = ["testdata/" + distro + ".yaml"], | ||
| image = ":python3_" + user + "_" + arch + "_" + distro, | ||
| tags = [ | ||
| "manual", | ||
| arch, | ||
| ], | ||
| ) | ||
| for user in USERS | ||
| ] | ||
loosebazooka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.