1616 ENV_EXTENSIONS ,
1717)
1818
19+ JUPYTERLITE_XEUS_PYTHON_DEBUG = 'JUPYTERLITE_XEUS_PYTHON_DEBUG'
20+
1921JUPYTERLITE_XEUS_PYTHON = "@jupyterlite/xeus-python-kernel"
2022
2123# TODO Make this configurable
@@ -62,7 +64,7 @@ def from_string(self, s):
6264
6365class XeusPythonEnv (FederatedExtensionAddon ):
6466
65- __all__ = ["pre_build" , " post_build" ]
67+ __all__ = ["post_build" ]
6668
6769 xeus_python_version = Unicode ().tag (
6870 config = True , description = "The xeus-python version to use"
@@ -102,7 +104,7 @@ def __init__(self, *args, **kwargs):
102104
103105 self .orig_config = os .environ .get ("CONDARC" )
104106
105- def pre_build (self , manager ):
107+ def post_build (self , manager ):
106108 """yield a doit task to create the emscripten-32 env and grab anything we need from it"""
107109 # Install the jupyterlite-xeus-python ourselves
108110 for pkg_json in self .env_extensions (ENV_EXTENSIONS ):
@@ -138,18 +140,14 @@ def pre_build(self, manager):
138140 # (make jupyterlite-xeus-python extension somewhat configurable?)
139141 dest = self .output_extensions / "@jupyterlite" / "xeus-python-kernel" / "static"
140142
141- task_dep = ["pre_build:federated_extensions:*" ]
142-
143143 for file in ["python_data.js" , "python_data.data" ]:
144144 yield dict (
145- task_dep = task_dep ,
146145 name = f"xeus:copy:{ file } " ,
147146 actions = [(self .copy_one , [Path (self .cwd .name ) / file , dest / file ])],
148147 )
149148
150149 for file in ["xpython_wasm.js" , "xpython_wasm.wasm" ]:
151150 yield dict (
152- task_dep = task_dep ,
153151 name = f"xeus:copy:{ file } " ,
154152 actions = [
155153 (
@@ -162,6 +160,16 @@ def pre_build(self, manager):
162160 ],
163161 )
164162
163+ if not os .environ .get (JUPYTERLITE_XEUS_PYTHON_DEBUG , False ):
164+ # Cleanup
165+ shutil .rmtree (self .cwd .name , ignore_errors = True )
166+ shutil .rmtree (self .root_prefix , ignore_errors = True )
167+
168+ if self .orig_config is not None :
169+ os .environ ["CONDARC" ] = self .orig_config
170+ elif "CONDARC" in os .environ :
171+ del os .environ ["CONDARC" ]
172+
165173 def create_env (self ):
166174 """Create the xeus-python emscripten-32 env with either mamba, micromamba or conda."""
167175 if MAMBA_PYTHON_AVAILABLE :
@@ -234,22 +242,6 @@ def _create_config(self):
234242 fobj .write (f"subdir: { PLATFORM } " )
235243 os .environ ["CONDARC" ] = str (self .prefix_path / ".condarc" )
236244
237- def post_build (self , manager ):
238- """Cleanup"""
239- # Bail early if there is nothing to do
240- if not self .packages and not self .xeus_python_version :
241- return []
242-
243- shutil .rmtree (self .cwd .name , ignore_errors = True )
244- shutil .rmtree (self .root_prefix , ignore_errors = True )
245-
246- if self .orig_config is not None :
247- os .environ ["CONDARC" ] = self .orig_config
248- elif "CONDARC" in os .environ :
249- del os .environ ["CONDARC" ]
250-
251- return []
252-
253245 def safe_copy_extension (self , pkg_json ):
254246 """Copy a labextension, and overwrite it
255247 if it's already in the output
0 commit comments