-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallPythonEnv.m
More file actions
94 lines (83 loc) · 3.42 KB
/
Copy pathinstallPythonEnv.m
File metadata and controls
94 lines (83 loc) · 3.42 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
83
84
85
86
87
88
89
90
91
92
93
94
% installPythonEnv - Install standalone Python 3.10 and VLA model dependencies.
% Downloads a self-contained Python distribution (no system Python needed),
% then installs packages required by the Octo and RT1-X model wrappers.
%
% Supported architectures: glnxa64 (Linux), win64 (Windows).
% macOS ARM64 (maca64) is not yet supported.
arch = computer('arch');
installLocation = fullfile(pwd, arch);
pyVersion = "3.10.4";
switch arch
case 'glnxa64'
% Using install_only variant (no zstd dependency required for extraction)
pySource = 'https://github.com/indygreg/python-build-standalone/releases/download/20220528/cpython-3.10.4+20220528-x86_64-unknown-linux-gnu-install_only.tar.gz';
case 'win64'
pySource = "https://github.com/indygreg/python-build-standalone/releases/download/20220528/cpython-3.10.4+20220528-x86_64-pc-windows-msvc-shared-install_only.tar.gz";
case 'maca64'
Error('Installation not supported');
end
tic
if ~exist(fullfile(installLocation, "python"), 'dir')
mkdir(installLocation)
disp("Downloading Python: " + pyVersion)
pydlLoc = websave(fullfile(installLocation, "pydl"), pySource);
tic
disp("Extracting Python: " + pydlLoc)
untar(pydlLoc, installLocation);
delete(pydlLoc)
toc
else
disp("Python already installed at: " + installLocation + filesep + "python")
end
% Persist interpreter path in MATLAB settings for use by configurePyenv
if ispc
pyInterpreter = fullfile(installLocation, "python", "python");
else
pyInterpreter = fullfile(installLocation, "python", "bin", "python3.10");
end
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 and setuptools")
[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("Downloading and installing VLA Python dependencies")
[status, cmdout] = system(pyExe + " -m pip install -r vlapy/requirements.txt -c vlapy/constraints.txt", "-echo");
if status~=0
error("pip install failed (exit code %d):\n%s", status, cmdout)
end
% Octo installed from pinned commit with --no-deps to avoid conflicting transitive deps
disp("----------")
disp("Installing Octo")
[status, cmdout] = system(pyExe + " -m pip install git+https://github.com/octo-models/octo.git@241fb3514b7c40957a86d869fecb7c7fc353f540 --no-deps", "-echo");
if status~=0
error("pip install failed (exit code %d):\n%s", status, cmdout)
end
toc
% Download Octo model weights from MathWorks support files
% (avoids Windows symlink permission errors with huggingface_hub)
disp("----------")
disp("Downloading Octo model weights")
modelsDir = fullfile(fileparts(mfilename('fullpath')), "vlapy", "octo-base");
if ~exist(modelsDir, 'dir')
filename = matlab.internal.examples.downloadSupportFile("robotics/data", "octoBaseModel.zip");
disp("Extracting: " + filename)
unzip(filename, fullfile(fileparts(mfilename('fullpath')), "vlapy"));
else
disp("Octo model already downloaded at: " + modelsDir)
end
toc
% Setup the python interpreter
terminate(pyenv);
pyenv(Version=pyInterpreter, ExecutionMode="OutOfProcess");