diff --git a/python/repositories.bzl b/python/repositories.bzl index 8bb8a9ced9..30c284191a 100644 --- a/python/repositories.bzl +++ b/python/repositories.bzl @@ -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, @@ -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 @@ -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 = [ @@ -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, )