11
11
12
12
from empack .file_packager import pack_environment
13
13
from empack .file_patterns import PkgFileFilter , pkg_file_filter_from_yaml
14
+ from empack .filter_env import write_minimal_conda_meta
14
15
15
16
import typer
16
17
@@ -117,6 +118,30 @@ def _create_config(prefix_path):
117
118
os .environ ["CONDARC" ] = str (prefix_path / ".condarc" )
118
119
119
120
121
+ def _install_pip_dependencies (prefix_path , dependencies ):
122
+ # Create a fake conda_meta file for each dependency, this prevents empack from filtering out pip dependencies
123
+ for package in dependencies :
124
+ # TODO Remove the version specifier from the package name if there is one
125
+ write_minimal_conda_meta (
126
+ dict (name = package , version = "" , build = "pip" , build_number = 0 ),
127
+ prefix_path ,
128
+ )
129
+
130
+ run (
131
+ [
132
+ "pip" ,
133
+ "install" ,
134
+ * dependencies ,
135
+ "--prefix" ,
136
+ prefix_path ,
137
+ "--no-input" ,
138
+ "--no-deps" ,
139
+ "--verbose" ,
140
+ ],
141
+ check = True ,
142
+ )
143
+
144
+
120
145
def build_and_pack_emscripten_env (
121
146
python_version : str = PYTHON_VERSION ,
122
147
xeus_python_version : str = "" ,
@@ -144,6 +169,8 @@ def build_and_pack_emscripten_env(
144
169
if packages or xeus_python_version or environment_file :
145
170
bail_early = False
146
171
172
+ pip_dependencies = []
173
+
147
174
# Process environment.yml file
148
175
if environment_file and Path (environment_file ).exists ():
149
176
bail_early = False
@@ -166,10 +193,7 @@ def build_and_pack_emscripten_env(
166
193
if isinstance (dependency , str ) and dependency not in specs :
167
194
specs .append (dependency )
168
195
elif isinstance (dependency , dict ) and dependency .get ("pip" ) is not None :
169
- raise RuntimeError (
170
- """Cannot install pip dependencies in the xeus-python Emscripten environment (yet?).
171
- """
172
- )
196
+ pip_dependencies = dependency ["pip" ]
173
197
174
198
# Bail early if there is nothing to do
175
199
if bail_early and not force :
@@ -190,6 +214,10 @@ def build_and_pack_emscripten_env(
190
214
# Create emscripten env with the given packages
191
215
create_env (env_name , root_prefix , specs , channels )
192
216
217
+ # Install pip dependencies
218
+ if pip_dependencies :
219
+ _install_pip_dependencies (prefix_path , pip_dependencies )
220
+
193
221
pack_kwargs = {}
194
222
195
223
# Download env filter config
0 commit comments