11import os
22import sys
3+ import compas
34
45from compas ._os import remove
56from compas ._os import remove_symlink
67from compas ._os import rename
78
9+ import compas_blender
10+
811__all__ = ['uninstall' ]
912
1013
11- def uninstall (blender_path ):
14+ def uninstall (blender_path , version = None ):
1215 """Uninstall COMPAS from Blender.
1316
1417 Parameters
1518 ----------
1619 blender_path : str
1720 The path to the folder with the version number of Blender.
18- For example, on Mac: ``'/Applications/blender.app/Contents/Resources/2.80'``.
19- On Windows: ``'%PROGRAMFILES%\\ Blender Foundation\\ Blender\\ 2.80'``.
21+ For example, on Mac: ``'/Applications/Blender.app/Contents/Resources/2.83'``.
22+ On Windows: ``'%PROGRAMFILES%/Blender Foundation/Blender 2.83/2.83'``.
23+ version : {'2.83', '2.93', '3.1'}, optional
24+ The version number of Blender.
25+ Default is ``'2.93'``.
2026
2127 Examples
2228 --------
@@ -29,6 +35,23 @@ def uninstall(blender_path):
2935 print ('Conda environment not found. The installation into Blender requires an active conda environment with a matching Python version to continue.' )
3036 sys .exit (- 1 )
3137
38+ if not version and not blender_path :
39+ version = '2.93'
40+
41+ if version and blender_path :
42+ print ('Both options cannot be provided simultaneously. Provide the full installation path, or the version with flag -v.' )
43+ sys .exit (- 1 )
44+
45+ if version :
46+ if compas .LINUX :
47+ print ('Version-based installs are currently not supported for Linux. Please provide the full installation path with the -p option.' )
48+ sys .exit (- 1 )
49+
50+ blender_path = compas_blender ._get_default_blender_installation_path (version )
51+
52+ if not os .path .exists (blender_path ):
53+ raise FileNotFoundError ('Blender version folder not found.' )
54+
3255 path , version = os .path .split (blender_path )
3356
3457 print ('Uninstalling COMPAS for Blender {}' .format (version ))
@@ -65,7 +88,9 @@ def uninstall(blender_path):
6588
6689 parser = argparse .ArgumentParser ()
6790
68- parser .add_argument ('versionpath' , help = "The path to the folder with the version number of Blender." )
91+ parser .add_argument ('blenderpath' , nargs = '?' , help = "The path to the folder with the version number of Blender." )
92+ parser .add_argument ('-v' , '--version' , choices = ['2.83' , '2.93' , '3.1' ], help = "The version of Blender to install COMPAS in." )
93+
6994 args = parser .parse_args ()
7095
71- uninstall (args .versionpath )
96+ uninstall (args .blenderpath , version = args . version )
0 commit comments