-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathinstall_shapeworks.bat
More file actions
156 lines (129 loc) · 5.68 KB
/
install_shapeworks.bat
File metadata and controls
156 lines (129 loc) · 5.68 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
REM remove existing shapeworks env if any
set CONDAENV=shapeworks
IF NOT "%1"=="" SET CONDAENV=%1
REM === Check for Smart App Control (Windows 11) ===
REM Smart App Control will block unsigned DLLs (VTK, PyTorch, etc.) that ShapeWorks
REM installs via pip, causing import failures. Warn the user before proceeding.
set SAC_STATE=
for /f "delims=" %%s in ('powershell -NoProfile -Command "(Get-MpComputerStatus).SmartAppControlState" 2^>nul') do set SAC_STATE=%%s
if /i "%SAC_STATE%"=="On" (
echo.
echo ============================================================
echo WARNING: Smart App Control is ENABLED on this computer.
echo ============================================================
echo.
echo ShapeWorks Studio itself will still run, but the Python
echo features ^(use cases, notebooks, DeepSSM^) will fail because
echo Smart App Control blocks the unsigned Python libraries
echo ^(VTK, PyTorch, etc.^) with errors like:
echo.
echo "An Application Control policy has blocked this file"
echo.
echo To use the Python features, turn Smart App Control OFF:
echo.
echo 1. Click the Start button and type "Smart App Control"
echo 2. Click "Smart App Control settings"
echo 3. Select "Off"
echo.
echo IMPORTANT: Turning Smart App Control off is permanent.
echo To turn it back on, you must reset Windows.
echo.
echo See https://sciinstitute.github.io/ShapeWorks/users/install.html
echo for more information.
echo.
echo Press Ctrl+C to cancel, or any key to continue installing
echo ^(install will succeed, but Python features won't work
echo until SAC is off^).
echo ============================================================
echo.
pause
)
echo "creating new conda environment for ShapeWorks called %CONDAENV%..."
REM Accept Anaconda TOS for required channels (must happen before any conda command that touches default channels)
call conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
call conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
call conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/msys2
REM remove any existing environment with this name
call conda env remove -n %CONDAENV% -y
REM update anaconda
call conda config --add channels anaconda
call conda config --add channels conda-forge
REM install shapeworks deps
call conda create --yes --name %CONDAENV% python=3.12.3 pip=24.3.1 openblas=0.3.30 || goto :error
call conda activate %CONDAENV%
REM reactivate shapeworks environment
call conda activate base
call conda activate %CONDAENV%
call python -m pip install -r python_requirements.txt || goto :error
REM install pytorch using light-the-torch
REM Use python -m to ensure we use the conda env's light_the_torch
call python -m light_the_torch install torch==2.8.0 torchaudio==2.8.0 torchvision==0.23.0 || goto :error
REM different versions of open3d for different OSes, so we install it manually here
call pip install open3d==0.19.0 || goto :error
call pip install Python/DataAugmentationUtilsPackage.tar.gz || goto :error
call pip install Python/DatasetUtilsPackage.tar.gz || goto :error
call pip install Python/MONAILabelPackage.tar.gz || goto :error
call pip install Python/DeepSSMUtilsPackage.tar.gz || goto :error
call pip install Python/DocumentationUtilsPackage.tar.gz || goto :error
call pip install Python/ShapeCohortGenPackage.tar.gz || goto :error
call pip install Python/shapeworks.tar.gz || goto :error
REM install the shapeworks python module and conda [de]activate scripts
call .\Installation\install_python_module.bat || goto :error
call .\Installation\conda_env_setup.bat || goto :error
md "%USERPROFILE%\.shapeworks"
python -c "import sys; print('\n'.join(sys.path))" > "%USERPROFILE%\.shapeworks\python_path_6.7.txt"
python -c "import sys; print(sys.prefix)" > "%USERPROFILE%\.shapeworks\python_home_6.7.txt"
echo %PATH% > "%USERPROFILE%\.shapeworks\path_6.7.txt"
call conda info
REM === Validating installation ===
echo.
echo === Validating installation ===
set VALIDATION_FAILED=0
REM Check Python version
for /f "delims=" %%v in ('python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')"') do set PYTHON_VERSION=%%v
if "%PYTHON_VERSION%"=="3.12" (
echo [OK] Python version: %PYTHON_VERSION%
) else (
echo [FAIL] Python version: %PYTHON_VERSION% ^(expected 3.12^)
set VALIDATION_FAILED=1
)
REM Check torch
python -c "import torch; print(f'[OK] torch {torch.__version__} (CUDA: {torch.cuda.is_available()})')"
if errorlevel 1 (
echo [FAIL] torch: failed to import
set VALIDATION_FAILED=1
)
REM Check shapeworks
python -c "import shapeworks; print('[OK] shapeworks package imported successfully')"
if errorlevel 1 (
echo [FAIL] shapeworks: failed to import
set VALIDATION_FAILED=1
)
REM Check DeepSSMUtils
python -c "import DeepSSMUtils; print('[OK] DeepSSMUtils package imported successfully')"
if errorlevel 1 (
echo [FAIL] DeepSSMUtils: failed to import
set VALIDATION_FAILED=1
)
REM Check vtk
python -c "import vtk; print(f'[OK] vtk {vtk.vtkVersion.GetVTKVersion()}')"
if errorlevel 1 (
echo [FAIL] vtk: failed to import
set VALIDATION_FAILED=1
)
REM Check itk
python -c "import itk; print(f'[OK] itk {itk.Version.GetITKVersion()}')"
if errorlevel 1 (
echo [FAIL] itk: failed to import
set VALIDATION_FAILED=1
)
echo ================================
if "%VALIDATION_FAILED%"=="1" (
echo.
echo WARNING: Some validation checks failed. Please review the output above.
)
echo "ShapeWorks environment %CONDAENV% is ready to use."
goto :EOF
:error
echo "Installation failed. Please check the error message above."
exit /b %ERRORLEVEL%