Skip to content

Commit

Permalink
Copy upstream fix
Browse files Browse the repository at this point in the history
Upstream fix in bazelbuild#1898
  • Loading branch information
chasezheng authored Sep 22, 2024
1 parent eebad61 commit d69f1a6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion python/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit d69f1a6

Please sign in to comment.