Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions python/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def _python_repository_impl(rctx):
# Make the Python installation read-only.
if not rctx.attr.ignore_root_user_error:
if "windows" not in rctx.os.name:
exec_result = rctx.execute(["chmod", "-R", "ugo-w", "lib"])
lib_dir = "lib" if "windows" not in platform else "Lib"
exec_result = rctx.execute(["chmod", "-R", "ugo-w", lib_dir])
if exec_result.return_code != 0:
fail_msg = "Failed to make interpreter installation read-only. 'chmod' error msg: {}".format(
exec_result.stderr,
Expand All @@ -131,6 +132,29 @@ def _python_repository_impl(rctx):

python_bin = "python.exe" if ("windows" in platform) else "bin/python3"

if "windows" in platform:
glob_include = [
"*.exe",
"*.dll",
"bin/**",
"DLLs/**",
"extensions/**",
"include/**",
"Lib/**",
"libs/**",
"Scripts/**",
"share/**",
]
else:
glob_include = [
"bin/**",
"extensions/**",
"include/**",
"lib/**",
"libs/**",
"share/**",
]

build_content = """\
# Generated by python/repositories.bzl

Expand All @@ -141,18 +165,7 @@ package(default_visibility = ["//visibility:public"])
filegroup(
name = "files",
srcs = glob(
include = [
"*.exe",
"*.dll",
"bin/**",
"DLLs/**",
"extensions/**",
"include/**",
"lib/**",
"libs/**",
"Scripts/**",
"share/**",
],
include = {glob_include},
# Platform-agnostic filegroup can't match on all patterns.
allow_empty = True,
exclude = [
Expand Down Expand Up @@ -206,6 +219,7 @@ py_runtime_pair(
py3_runtime = ":py3_runtime",
)
""".format(
glob_include = repr(glob_include),
python_path = python_bin,
python_version = python_short_version,
)
Expand Down