44from pathlib import Path
55import platform
66import shutil
7+ import subprocess
78import stat
89import sys
910import tarfile
1415import coloredlogs
1516
1617import conda
17- import conda .cli .python_api as Conda
1818from conda_build import api as CondaBuild
1919from conda_build .config import Config
2020from conda_pack import core as CondaPack
3333
3434archive_format = 'zip' if platform .system () == 'Windows' else 'tar'
3535
36+ def run_command (cmd : list [str ]) -> str :
37+ result = subprocess .run (cmd , capture_output = True , text = True , check = True )
38+ return result .stdout
39+
3640def patch_qt_config (base_path ):
3741 # We could use "qt.conf" instead, but Qt is automatically producing a
3842 # "qt6.conf" file that overrides ours. Instead of deleting this one,
@@ -116,15 +120,16 @@ def build_conda_pack(base_path, tmp, hexrd_package_channel, hexrdgui_output_fold
116120
117121 # Determine the latest hexrd version in the hexrd_package_channel
118122 # (release or pre-release), and force that hexrd version to be used.
119- params = [
120- Conda .Commands .SEARCH ,
123+ cmd = [
124+ 'conda' ,
125+ 'search' ,
121126 '--override-channels' ,
122127 '--channel' , hexrd_package_channel ,
123128 '--json' ,
124129 'hexrd' ,
125130 ]
126- output = Conda . run_command (* params )
127- results = json .loads (output [ 0 ] )
131+ output = run_command (cmd )
132+ results = json .loads (output )
128133 hexrd_version = results ['hexrd' ][- 1 ]['version' ]
129134 config .variant ['hexrd_version' ] = hexrd_version
130135
@@ -144,27 +149,30 @@ def build_conda_pack(base_path, tmp, hexrd_package_channel, hexrdgui_output_fold
144149 if platform .system () == 'Darwin' :
145150 channels = ['--channel' , 'HEXRD' ] + channels
146151
147- Conda .run_command (
148- Conda .Commands .CREATE ,
149- '--prefix' , env_prefix
150- )
152+ run_command ([
153+ 'conda' ,
154+ 'create' ,
155+ '-y' ,
156+ '--prefix' , env_prefix ,
157+ ])
151158
152159 hexrdgui_output_folder_uri = Path (hexrdgui_output_folder ).absolute ().as_uri ()
153160
154161 logger .info ('Installing hexrdgui into new environment.' )
155162 # Install hexrdgui into new environment
156- params = [
157- Conda .Commands .INSTALL ,
163+ cmd = [
164+ 'conda' ,
165+ 'install' ,
158166 '--prefix' , env_prefix ,
159167 '--solver' , 'libmamba' ,
160168 '--override-channels' ,
161169 '--channel' , hexrdgui_output_folder_uri ,
162170 '--channel' , hexrd_package_channel ,
163171 '--channel' , 'conda-forge' ,
164172 f'hexrd=={ hexrd_version } ' ,
165- 'hexrdgui'
173+ 'hexrdgui' ,
166174 ]
167- Conda . run_command (* params )
175+ run_command (cmd )
168176
169177 logger .info ('Generating tar from environment using conda-pack.' )
170178 # Now use conda-pack to create relocatable archive
0 commit comments