From e35ae455b3a6be9b5d18777a0fc5a0fba67f407e Mon Sep 17 00:00:00 2001 From: chase Date: Sun, 22 Sep 2024 16:34:21 +0200 Subject: [PATCH] Copy upstream fix Upstream fix in https://github.com/bazelbuild/rules_python/pull/1898 --- python/repositories.bzl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/python/repositories.bzl b/python/repositories.bzl index f897904e70..9e5d086391 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -98,7 +98,7 @@ def _python_repository_impl(rctx): ) # Write distutils.cfg to the Python installation. - if "windows" in rctx.os.name: + if "windows" in platform: distutils_path = "Lib/distutils/distutils.cfg" else: distutils_path = "lib/python{}/distutils/distutils.cfg".format(python_short_version) @@ -107,6 +107,27 @@ def _python_repository_impl(rctx): elif rctx.attr.distutils_content: rctx.file(distutils_path, rctx.attr.distutils_content) + if "linux" in platform: + # Workaround around https://github.com/indygreg/python-build-standalone/issues/231 + for url in urls: + head_and_release, _, _ = url.rpartition("/") + _, _, release = head_and_release.rpartition("/") + if not release.isdigit(): + # Maybe this is some custom toolchain, so skip this + break + + if int(release) >= 20240224: + # Starting with this release the Linux toolchains have infinite symlink loop + # on host platforms that are not Linux. Delete the files no + # matter the host platform so that the cross-built artifacts + # are the same irrespective of the host platform we are + # building on. + # + # Link to the first affected release: + # https://github.com/indygreg/python-build-standalone/releases/tag/20240224 + rctx.delete("share/terminfo") + break + # Make the Python installation read-only. if not rctx.attr.ignore_root_user_error: if "windows" not in rctx.os.name: