Skip to content

Commit c1beb3a

Browse files
committed
Call conda commands directly
This old API was removed. I don't see any valid replacements. Just try calling the conda commands directly. Signed-off-by: Patrick Avery <[email protected]>
1 parent a7f0c35 commit c1beb3a

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

packaging/package.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pathlib import Path
55
import platform
66
import shutil
7+
import subprocess
78
import stat
89
import sys
910
import tarfile
@@ -14,7 +15,6 @@
1415
import coloredlogs
1516

1617
import conda
17-
import conda.cli.python_api as Conda
1818
from conda_build import api as CondaBuild
1919
from conda_build.config import Config
2020
from conda_pack import core as CondaPack
@@ -33,6 +33,10 @@
3333

3434
archive_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+
3640
def 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

Comments
 (0)