|
21 | 21 | import sys
|
22 | 22 | import textwrap
|
23 | 23 | import venv
|
24 |
| -from typing import Dict, List, Optional |
| 24 | +from typing import Dict, List |
25 | 25 |
|
26 | 26 | import importlib_metadata
|
27 | 27 |
|
28 |
| - |
29 | 28 | EnvFile = collections.namedtuple("EnvFile", ["path", "site_packages_path"])
|
30 | 29 |
|
31 | 30 |
|
@@ -112,7 +111,6 @@ def get_files(build_env_input: Dict) -> List[EnvFile]:
|
112 | 111 | for depfile in build_env_input["files"]:
|
113 | 112 | # Bucket files into external and workspace groups.
|
114 | 113 | # Only generated workspace files are kept.
|
115 |
| - type_ = depfile["t"] |
116 | 114 | input_path = pathlib.Path(depfile["p"])
|
117 | 115 |
|
118 | 116 | # 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:
|
144 | 142 |
|
145 | 143 | def install_site_file(site_packages_path: pathlib.Path, file: EnvFile) -> None:
|
146 | 144 | 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(): |
148 | 146 | 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()) |
150 | 151 |
|
151 | 152 |
|
152 | 153 | def install_files(env_path: pathlib.Path, files: List[EnvFile]) -> None:
|
@@ -246,7 +247,7 @@ def main():
|
246 | 247 | cwd = os.environ.get("BUILD_WORKING_DIRECTORY", os.getcwd())
|
247 | 248 | env_path = pathlib.Path(cwd) / pathlib.Path(sys.argv[1])
|
248 | 249 |
|
249 |
| - builder = venv.EnvBuilder(clear=True, symlinks=True, with_pip=True) |
| 250 | + builder = venv.EnvBuilder(clear=True, symlinks=sys.platform != 'win32', with_pip=True) |
250 | 251 | builder.create(str(env_path))
|
251 | 252 |
|
252 | 253 | install_files(env_path, files)
|
|
0 commit comments