Skip to content

Commit 64017bd

Browse files
committed
Do not symlink on Windows
1 parent 6506112 commit 64017bd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

build_env.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
import sys
2222
import textwrap
2323
import venv
24-
from typing import Dict, List, Optional
24+
from typing import Dict, List
2525

2626
import importlib_metadata
2727

28-
2928
EnvFile = collections.namedtuple("EnvFile", ["path", "site_packages_path"])
3029

3130

@@ -112,7 +111,6 @@ def get_files(build_env_input: Dict) -> List[EnvFile]:
112111
for depfile in build_env_input["files"]:
113112
# Bucket files into external and workspace groups.
114113
# Only generated workspace files are kept.
115-
type_ = depfile["t"]
116114
input_path = pathlib.Path(depfile["p"])
117115

118116
# If this is a directory, expand to each recursive child.
@@ -144,9 +142,12 @@ def install_data_file(env_path: pathlib.Path, file: EnvFile) -> None:
144142

145143
def install_site_file(site_packages_path: pathlib.Path, file: EnvFile) -> None:
146144
site_path = site_packages_path / file.site_packages_path
147-
if not site_path.exists():
145+
if not site_path.exists() and file.path.exists():
148146
site_path.parent.mkdir(parents=True, exist_ok=True)
149-
site_path.symlink_to(file.path.resolve())
147+
try:
148+
site_path.symlink_to(file.path.resolve())
149+
except OSError:
150+
site_path.write_bytes(file.path.read_bytes())
150151

151152

152153
def install_files(env_path: pathlib.Path, files: List[EnvFile]) -> None:
@@ -246,7 +247,7 @@ def main():
246247
cwd = os.environ.get("BUILD_WORKING_DIRECTORY", os.getcwd())
247248
env_path = pathlib.Path(cwd) / pathlib.Path(sys.argv[1])
248249

249-
builder = venv.EnvBuilder(clear=True, symlinks=True, with_pip=True)
250+
builder = venv.EnvBuilder(clear=True, symlinks=sys.platform != 'win32', with_pip=True)
250251
builder.create(str(env_path))
251252

252253
install_files(env_path, files)

0 commit comments

Comments
 (0)