Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the check for python package and install #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions toolbox/internal/getUserDirectory.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
function directory = getUserDirectory()
%GETUSERDIRECTORY Get the current user directory
%GETUSERDIRECTORY Get the current user directory, works on Windows, macOS, and Linux

% Copyright 2021 The MathWorks, Inc.
[status, directory] = system("echo %HOMEPATH%");
if ispc
% For Windows, use HOMEPATH
[status, directory] = system("echo %HOMEDRIVE%%HOMEPATH%");
else
% For macOS/Linux, use HOME
[status, directory] = system("echo $HOME");
end

if status ~= 0
error("userDirectory:couldNotGetUserDirectory","Could not retrieve user directory")
error("userDirectory:couldNotGetUserDirectory", "Could not retrieve user directory");
end

% Trim any whitespace and convert to string
directory = strtrim(string(directory));
end

4 changes: 2 additions & 2 deletions toolbox/internal/setupCDSAPIIfNeeded.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ function setupCDSAPIIfNeeded(promptForCredentials)
end

% Call PIP to see if cdsapi is installed
[result, ~] = system(fullfile(pythonInfo.Home,"Scripts","pip3")+" show cdsapi");
[result, ~] = system(pythonInfo.Executable+" -m pip show cdsapi");
if result ~= 0
% it's not installed
[result, ~] = system(fullfile(pythonInfo.Home,"Scripts","pip3")+" install cdsapi");
[result, ~] = system(pythonInfo.Executable+" -m pip install cdsapi");
if result ~= 0
error("climateDataStore:unableToInstallCSAPI","Could not use PIP3 to install CDSAPI")
end
Expand Down