16
16
ENV_EXTENSIONS ,
17
17
)
18
18
19
+ JUPYTERLITE_XEUS_PYTHON_DEBUG = 'JUPYTERLITE_XEUS_PYTHON_DEBUG'
20
+
19
21
JUPYTERLITE_XEUS_PYTHON = "@jupyterlite/xeus-python-kernel"
20
22
21
23
# TODO Make this configurable
@@ -62,7 +64,7 @@ def from_string(self, s):
62
64
63
65
class XeusPythonEnv (FederatedExtensionAddon ):
64
66
65
- __all__ = ["pre_build" , " post_build" ]
67
+ __all__ = ["post_build" ]
66
68
67
69
xeus_python_version = Unicode ().tag (
68
70
config = True , description = "The xeus-python version to use"
@@ -102,7 +104,7 @@ def __init__(self, *args, **kwargs):
102
104
103
105
self .orig_config = os .environ .get ("CONDARC" )
104
106
105
- def pre_build (self , manager ):
107
+ def post_build (self , manager ):
106
108
"""yield a doit task to create the emscripten-32 env and grab anything we need from it"""
107
109
# Install the jupyterlite-xeus-python ourselves
108
110
for pkg_json in self .env_extensions (ENV_EXTENSIONS ):
@@ -138,18 +140,14 @@ def pre_build(self, manager):
138
140
# (make jupyterlite-xeus-python extension somewhat configurable?)
139
141
dest = self .output_extensions / "@jupyterlite" / "xeus-python-kernel" / "static"
140
142
141
- task_dep = ["pre_build:federated_extensions:*" ]
142
-
143
143
for file in ["python_data.js" , "python_data.data" ]:
144
144
yield dict (
145
- task_dep = task_dep ,
146
145
name = f"xeus:copy:{ file } " ,
147
146
actions = [(self .copy_one , [Path (self .cwd .name ) / file , dest / file ])],
148
147
)
149
148
150
149
for file in ["xpython_wasm.js" , "xpython_wasm.wasm" ]:
151
150
yield dict (
152
- task_dep = task_dep ,
153
151
name = f"xeus:copy:{ file } " ,
154
152
actions = [
155
153
(
@@ -162,6 +160,16 @@ def pre_build(self, manager):
162
160
],
163
161
)
164
162
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
+
165
173
def create_env (self ):
166
174
"""Create the xeus-python emscripten-32 env with either mamba, micromamba or conda."""
167
175
if MAMBA_PYTHON_AVAILABLE :
@@ -234,22 +242,6 @@ def _create_config(self):
234
242
fobj .write (f"subdir: { PLATFORM } " )
235
243
os .environ ["CONDARC" ] = str (self .prefix_path / ".condarc" )
236
244
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
-
253
245
def safe_copy_extension (self , pkg_json ):
254
246
"""Copy a labextension, and overwrite it
255
247
if it's already in the output
0 commit comments