Skip to content

Commit c21e3cb

Browse files
committed
fix windows permission issue
1 parent 71c8520 commit c21e3cb

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/datacustomcode/deploy.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ def prepare_dependency_archive(directory: str, docker_network: str) -> None:
293293
cmd = docker_build_cmd(docker_network)
294294
cmd_output(cmd, env=docker_env)
295295

296-
with tempfile.TemporaryDirectory() as temp_dir:
296+
# ignore_cleanup_errors=True: on Windows, Docker creates files inside the
297+
# mounted volume whose permissions prevent the host from deleting them.
298+
# The archive has already been copied out, so silently skipping leftover
299+
# files is safe and avoids a fatal error on context-manager exit.
300+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as temp_dir:
297301
logger.info(
298302
f"Building dependencies archive with docker network: {docker_network}"
299303
)
@@ -318,7 +322,10 @@ def docker_build_cmd(network: str) -> str:
318322

319323

320324
def docker_run_cmd(network: str, temp_dir: str) -> str:
321-
cmd = f"docker run --rm -v {temp_dir}:/workspace {DOCKER_IMAGE_NAME} "
325+
# Normalise path separators: Docker expects forward slashes even on Windows,
326+
# and quoting handles paths that contain spaces.
327+
docker_path = temp_dir.replace("\\", "/")
328+
cmd = f'docker run --rm -v "{docker_path}:/workspace" {DOCKER_IMAGE_NAME} '
322329

323330
if network != "default":
324331
cmd = cmd + f"--network {network} "

tests/test_deploy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class TestPrepareDependencyArchive:
5555
)
5656
EXPECTED_DOCKER_RUN_CMD = (
5757
"docker run --rm "
58-
"-v /tmp/test_dir:/workspace "
58+
'-v "/tmp/test_dir:/workspace" '
5959
"datacloud-custom-code-dependency-builder "
6060
)
6161

0 commit comments

Comments
 (0)