Skip to content

Commit c86efba

Browse files
authored
Merge pull request #1924 from HEXRD/remove-pinhole-when-disabled
Set pinhole thickness to zero when disabled
2 parents 3908ff0 + c1beb3a commit c86efba

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

hexrdgui/physics_package_manager_dialog.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ def layer_thickness(self, name: str) -> float:
310310
w = getattr(self.ui, f'{name}_thickness')
311311
return w.value()
312312

313+
def layer_density(self, name: str) -> float:
314+
return getattr(self.ui, f'{name}_density').value()
315+
313316
def material_changed(self, index, category):
314317
material = self.material_selectors[category].currentText()
315318

@@ -348,7 +351,10 @@ def accept_changes(self):
348351
kwargs[f'{name}_material'] = materials[name]
349352
for key in ('density', 'thickness'):
350353
attr = f'{name}_{key}'
351-
kwargs[attr] = getattr(self.ui, attr).value()
354+
# We MUST use the getter function, so the thickness will
355+
# be automatically set to zero for disabled layers.
356+
getter = getattr(self, f'layer_{key}')
357+
kwargs[attr] = getter(name)
352358
kwargs[f'{name}_formula'] = self.chemical_formula(name)
353359

354360
HexrdConfig().update_physics_package(**kwargs)

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)