Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit c2feddc

Browse files
committed
Cleanup tmp dir *before* creating the prefix
1 parent 6a02d9b commit c2feddc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jupyterlite_xeus_python/env_build_addon.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ def __init__(self, *args, **kwargs):
8181
self.root_prefix = "/tmp/xeus-python-kernel"
8282
self.env_name = "xeus-python-kernel"
8383

84-
self.prefix_path.mkdir(parents=True, exist_ok=True)
84+
# Cleanup tmp dir in case it's not empty
85+
shutil.rmtree(self.root_prefix, ignore_errors=True)
86+
Path(self.root_prefix).mkdir(parents=True, exist_ok=True)
8587

8688
self.orig_config = os.environ.get("CONDARC")
8789

@@ -91,9 +93,6 @@ def pre_build(self, manager):
9193
if not self.packages:
9294
return []
9395

94-
# Cleanup tmp dir
95-
shutil.rmtree(self.root_prefix, ignore_errors=True)
96-
9796
# Create emscripten env with the given packages
9897
self.create_env()
9998

@@ -159,6 +158,8 @@ def create_env(self):
159158
channels.extend(["-c", channel])
160159

161160
if MAMBA_AVAILABLE:
161+
# Mamba needs the directory to exist already
162+
self.prefix_path.mkdir(parents=True, exist_ok=True)
162163
return self._create_env_with_config("mamba", channels)
163164

164165
if MICROMAMBA_AVAILABLE:

0 commit comments

Comments
 (0)