@@ -70,36 +70,42 @@ Conda.rm_channel("foo", env)
70
70
Conda. add (" zlib" , env; channel= alt_channel)
71
71
72
72
@testset " Batch install and uninstall" begin
73
- Conda. add ([" affine" , " ansi2html" ], env)
74
- installed = Conda. _installed_packages (env)
75
- @test " affine" ∈ installed
76
- @test " ansi2html" ∈ installed
77
-
78
- Conda. rm ([" affine" , " ansi2html" ], env)
79
- installed = Conda. _installed_packages (env)
80
- @test " affine" ∉ installed
81
- @test " ansi2html" ∉ installed
73
+ mktempdir () do env
74
+ Conda. create (env)
75
+ Conda. add ([" affine" , " ansi2html" ], env)
76
+ installed = Conda. _installed_packages (env)
77
+ @test " affine" ∈ installed
78
+ @test " ansi2html" ∈ installed
79
+
80
+ Conda. rm ([" affine" , " ansi2html" ], env)
81
+ installed = Conda. _installed_packages (env)
82
+ @test " affine" ∉ installed
83
+ @test " ansi2html" ∉ installed
84
+ end
82
85
end
83
86
84
87
# Run conda clean
85
88
Conda. clean (; debug= true )
86
89
87
90
@testset " Exporting and creating environments" begin
88
- new_env = :test_conda_jl_2
89
- Conda. add (" curl" , env)
90
- Conda. export_list (" conda-pkg.txt" , env)
91
-
92
- # Create a new environment
93
- rm (Conda. prefix (new_env); force= true , recursive= true )
94
- Conda. import_list (
95
- IOBuffer (read (" conda-pkg.txt" )), new_env; channels= [" foo" , alt_channel, default_channel]
96
- )
97
-
98
- # Ensure that our new environment has our channels and package installed.
99
- @test Conda. channels (new_env) == [" foo" , alt_channel, default_channel]
100
- installed = Conda. _installed_packages (new_env)
101
- @test " curl" ∈ installed
102
- rm (" conda-pkg.txt" )
91
+ mktempdir () do env
92
+ new_env = :test_conda_jl_2
93
+ Conda. create (env)
94
+ Conda. add (" curl" , env)
95
+ Conda. export_list (" conda-pkg.txt" , env)
96
+
97
+ # Create a new environment
98
+ rm (Conda. prefix (new_env); force= true , recursive= true )
99
+ Conda. import_list (
100
+ IOBuffer (read (" conda-pkg.txt" )), new_env; channels= [" foo" , alt_channel, default_channel]
101
+ )
102
+
103
+ # Ensure that our new environment has our channels and package installed.
104
+ @test Conda. channels (new_env) == [" foo" , alt_channel, default_channel]
105
+ installed = Conda. _installed_packages (new_env)
106
+ @test " curl" ∈ installed
107
+ rm (" conda-pkg.txt" )
108
+ end
103
109
end
104
110
105
111
@testset " Conda.pip_interop" begin
150
156
end
151
157
end
152
158
159
+ function default_conda_exe (ROOTENV)
160
+ @static if Sys. iswindows ()
161
+ p = joinpath (ROOTENV, " Scripts" )
162
+ conda_bat = joinpath (p, " conda.bat" )
163
+ isfile (conda_bat) ? conda_bat : joinpath (p, " conda.exe" )
164
+ else
165
+ joinpath (ROOTENV, " bin" , " conda" )
166
+ end
167
+ end
168
+
169
+
153
170
if Sys. ARCH in [:x86 , :i686 ]
154
171
CONDA_JL_USE_MINIFORGE_DEFAULT = " false"
155
172
else
@@ -162,12 +179,15 @@ end
162
179
@test ! isfile (depsfile)
163
180
@test ! isfile (joinpath (condadir, " deps.jl" ))
164
181
165
- withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing ) do
182
+ withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing , " CONDA_JL_CONDA_EXE " => nothing ) do
166
183
Pkg. build (" Conda" )
184
+ local ROOTENV= joinpath (condadir, " 3" )
185
+ local CONDA_EXE= default_conda_exe (ROOTENV)
167
186
@test read (depsfile, String) == """
168
- const ROOTENV = "$(escape_string (joinpath (condadir, " 3 " ) )) "
187
+ const ROOTENV = "$(escape_string (ROOTENV )) "
169
188
const MINICONDA_VERSION = "3"
170
189
const USE_MINIFORGE = $(CONDA_JL_USE_MINIFORGE_DEFAULT)
190
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
171
191
"""
172
192
end
173
193
end
@@ -179,12 +199,15 @@ end
179
199
@test ! isfile (depsfile)
180
200
@test ! isfile (joinpath (condadir, " deps.jl" ))
181
201
182
- withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => " 1" ) do
202
+ withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => " 1" , " CONDA_JL_CONDA_EXE " => nothing ) do
183
203
Pkg. build (" Conda" )
204
+ local ROOTENV= joinpath (condadir, " 3" )
205
+ local CONDA_EXE= default_conda_exe (ROOTENV)
184
206
@test read (depsfile, String) == """
185
207
const ROOTENV = "$(escape_string (joinpath (condadir, " 3" ))) "
186
208
const MINICONDA_VERSION = "3"
187
209
const USE_MINIFORGE = true
210
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
188
211
"""
189
212
end
190
213
end
@@ -193,12 +216,15 @@ end
193
216
@test ! isfile (depsfile)
194
217
@test ! isfile (joinpath (condadir, " deps.jl" ))
195
218
196
- withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => " 0" ) do
219
+ withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => " 0" , " CONDA_JL_CONDA_EXE " => nothing ) do
197
220
Pkg. build (" Conda" )
221
+ local ROOTENV= joinpath (condadir, " 3" )
222
+ local CONDA_EXE= default_conda_exe (ROOTENV)
198
223
@test read (depsfile, String) == """
199
- const ROOTENV = "$(escape_string (joinpath (condadir, " 3 " ) )) "
224
+ const ROOTENV = "$(escape_string (ROOTENV )) "
200
225
const MINICONDA_VERSION = "3"
201
226
const USE_MINIFORGE = false
227
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
202
228
"""
203
229
end
204
230
end
@@ -207,12 +233,14 @@ end
207
233
@testset " custom home" begin
208
234
preserve_build () do
209
235
mktempdir () do dir
210
- withenv (" CONDA_JL_VERSION" => " 3" , " CONDA_JL_HOME" => dir, " CONDA_JL_USE_MINIFORGE" => nothing ) do
236
+ withenv (" CONDA_JL_VERSION" => " 3" , " CONDA_JL_HOME" => dir, " CONDA_JL_USE_MINIFORGE" => nothing , " CONDA_JL_CONDA_EXE " => nothing ) do
211
237
Pkg. build (" Conda" )
238
+ local CONDA_EXE= default_conda_exe (dir)
212
239
@test read (depsfile, String) == """
213
240
const ROOTENV = "$(escape_string (dir)) "
214
241
const MINICONDA_VERSION = "3"
215
242
const USE_MINIFORGE = $(CONDA_JL_USE_MINIFORGE_DEFAULT)
243
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
216
244
"""
217
245
end
218
246
end
@@ -222,28 +250,37 @@ end
222
250
@testset " version mismatch" begin
223
251
preserve_build () do
224
252
# Mismatch in written file
253
+ local ROOTENV= joinpath (condadir, " 3" )
254
+ local CONDA_EXE= default_conda_exe (ROOTENV)
225
255
write (depsfile, """
226
- const ROOTENV = "$(escape_string (joinpath (condadir, " 3 " ) )) "
256
+ const ROOTENV = "$(escape_string (ROOTENV )) "
227
257
const MINICONDA_VERSION = "2"
228
258
const USE_MINIFORGE = $(CONDA_JL_USE_MINIFORGE_DEFAULT)
259
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
229
260
""" )
230
261
231
- withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing ) do
262
+ withenv (" CONDA_JL_VERSION" => nothing , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing , " CONDA_JL_CONDA_EXE " => nothing ) do
232
263
Pkg. build (" Conda" )
264
+ local ROOTENV= joinpath (condadir, " 2" )
265
+ local CONDA_EXE= default_conda_exe (ROOTENV)
233
266
@test read (depsfile, String) == """
234
- const ROOTENV = "$(escape_string (joinpath (condadir, " 2 " ) )) "
267
+ const ROOTENV = "$(escape_string (ROOTENV )) "
235
268
const MINICONDA_VERSION = "2"
236
269
const USE_MINIFORGE = $(CONDA_JL_USE_MINIFORGE_DEFAULT)
270
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
237
271
"""
238
272
end
239
273
240
274
# ROOTENV should be replaced since CONDA_JL_HOME wasn't explicitly set
241
- withenv (" CONDA_JL_VERSION" => " 3" , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing ) do
275
+ withenv (" CONDA_JL_VERSION" => " 3" , " CONDA_JL_HOME" => nothing , " CONDA_JL_USE_MINIFORGE" => nothing , " CONDA_JL_CONDA_EXE " => nothing ) do
242
276
Pkg. build (" Conda" )
277
+ local ROOTENV= joinpath (condadir, " 3" )
278
+ local CONDA_EXE= default_conda_exe (ROOTENV)
243
279
@test read (depsfile, String) == """
244
- const ROOTENV = "$(escape_string (joinpath (condadir, " 3 " ) )) "
280
+ const ROOTENV = "$(escape_string (ROOTENV )) "
245
281
const MINICONDA_VERSION = "3"
246
282
const USE_MINIFORGE = $(CONDA_JL_USE_MINIFORGE_DEFAULT)
283
+ const CONDA_EXE = "$(escape_string (CONDA_EXE)) "
247
284
"""
248
285
end
249
286
end
0 commit comments