-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallPythonEnv.m
More file actions
82 lines (73 loc) · 2.97 KB
/
Copy pathinstallPythonEnv.m
File metadata and controls
82 lines (73 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
% installPythonEnv Install standalone Python 3.13 and Gemini Robotics ER dependencies.
% Downloads a self-contained Python distribution (no system Python needed),
% then installs packages required by geminiClient.py.
%
% Supported architectures: glnxa64 (Linux), win64 (Windows), maca64 (macOS ARM64).
%
% Run once after cloning:
% installPythonEnv
arch = computer('arch');
installLocation = fullfile(fileparts(mfilename('fullpath')), 'dependencies', 'python', arch);
pyVersion = "3.13.1";
releaseTag = "20241206";
switch arch
case 'glnxa64'
pySource = "https://github.com/indygreg/python-build-standalone/releases/download/" + ...
releaseTag + "/cpython-" + pyVersion + "+" + releaseTag + ...
"-x86_64-unknown-linux-gnu-install_only.tar.gz";
case 'win64'
pySource = "https://github.com/indygreg/python-build-standalone/releases/download/" + ...
releaseTag + "/cpython-" + pyVersion + "+" + releaseTag + ...
"-x86_64-pc-windows-msvc-shared-install_only.tar.gz";
case 'maca64'
pySource = "https://github.com/indygreg/python-build-standalone/releases/download/" + ...
releaseTag + "/cpython-" + pyVersion + "+" + releaseTag + ...
"-aarch64-apple-darwin-install_only.tar.gz";
otherwise
error('Unsupported architecture: %s', arch);
end
tic
if ~exist(fullfile(installLocation, "python"), 'dir')
mkdir(installLocation)
disp("Downloading Python " + pyVersion)
pydlLoc = websave(fullfile(installLocation, "pydl"), pySource);
disp("Extracting: " + pydlLoc)
untar(pydlLoc, installLocation);
delete(pydlLoc)
else
disp("Python already installed at: " + fullfile(installLocation, "python"))
end
% Resolve interpreter path
if ispc
pyInterpreter = fullfile(installLocation, "python", "python.exe");
elseif ismac
pyInterpreter = fullfile(installLocation, "python", "bin", "python3.13");
else
pyInterpreter = fullfile(installLocation, "python", "bin", "python3.13");
end
% Persist interpreter path in MATLAB settings
s = settings;
if ~hasGroup(s, 'python')
addGroup(s, 'python');
end
if hasSetting(s.python, "Python")
s.python.Python.PersonalValue = pyInterpreter;
else
addSetting(s.python, "Python", "PersonalValue", pyInterpreter);
end
% Quote pyInterpreter for system() - path may contain spaces (e.g., "00 Project - demo")
pyExe = '"' + pyInterpreter + '"';
disp("Upgrading pip")
[status, cmdout] = system(pyExe + " -m pip install --upgrade pip wheel");
if status ~= 0
error("pip upgrade failed (exit code %d):\n%s", status, cmdout);
end
disp("----------")
disp("Installing Gemini Robotics ER Python dependencies")
[status, cmdout] = system(pyExe + " -m pip install " + ...
"""google-genai==1.73.1"" ""Pillow==12.1.1"" ""numpy==2.4.4""", "-echo");
if status ~= 0
error("pip install failed (exit code %d):\n%s", status, cmdout);
end
toc
disp("Python installed. Run projectstartup to configure the environment.")