Skip to content

Commit 2305f1f

Browse files
committed
Install: Use conda to find python executable
1 parent e62ac84 commit 2305f1f

2 files changed

Lines changed: 29 additions & 8 deletions

File tree

mhkit/package/+mhkit/check_health.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,20 @@
3434
logger.info('=== Python Environment Validation ===');
3535
try
3636
pe = pyenv();
37-
logger.info('Python Version: %s', pe.Version);
38-
logger.info('Python Executable: %s', pe.Executable);
39-
logger.info('Python Library: %s', pe.Library);
40-
logger.info('Python Home: %s', pe.Home);
41-
logger.info('Execution Mode: %s', pe.ExecutionMode);
42-
logger.info('Status: %s', pe.Status);
37+
logger.info('Python Version: "%s"', pe.Version);
38+
logger.info('Python Executable: "%s"', pe.Executable);
39+
logger.info('Python Library: "%s"', pe.Library);
40+
logger.info('Python Home: "%s"', pe.Home);
41+
logger.info('Execution Mode: "%s"', pe.ExecutionMode);
42+
logger.info('Status: "%s"', pe.Status);
43+
44+
% Additional debugging for empty fields
45+
if isempty(pe.Version)
46+
logger.warning('⚠ Python Version is empty - pyenv not configured');
47+
end
48+
if isempty(pe.Executable)
49+
logger.warning('⚠ Python Executable is empty - no Python path set');
50+
end
4351

4452
% Validate Python is properly configured
4553
if strcmp(pe.Status, 'NotLoaded')

mhkit/package/+mhkit/install.m

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,28 @@ function initialize_python_integration(env_name, logger)
187187
% Initialize Python integration
188188
try
189189
% Get the Python executable path from the conda environment
190-
[status, python_path] = mhkit.sys(sprintf('conda run -n %s python -c "import sys; print(sys.executable)"', env_name));
190+
conda_command = sprintf('conda run -n %s python -c "import sys; print(sys.executable)"', env_name);
191+
logger.info('Executing command: %s', conda_command);
192+
[status, python_path] = mhkit.sys(conda_command);
193+
194+
logger.info('Command status: %d', status);
195+
logger.info('Raw Python path output: "%s"', python_path);
191196

192197
if status ~= 0
193198
logger.error('Failed to get Python executable path from conda environment');
199+
logger.error('Command output: %s', python_path);
194200
return
195201
end
196202

197203
python_path = strip(python_path);
198-
logger.info('Found Python executable: %s', python_path);
204+
logger.info('Cleaned Python executable: %s', python_path);
205+
206+
% Verify the Python executable exists
207+
if ~exist(python_path, 'file')
208+
logger.error('Python executable does not exist at path: %s', python_path);
209+
return
210+
end
211+
logger.info('✓ Verified Python executable exists');
199212

200213
% Add Python directory to system PATH (like the working Unix tests)
201214
python_dir = fileparts(python_path);

0 commit comments

Comments
 (0)