Skip to content

Commit c8c3b60

Browse files
committed
add (un)install support for 3.1
1 parent 2c98fbe commit c8c3b60

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

src/compas_blender/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def redraw():
5555

5656

5757
def _check_blender_version(version):
58-
supported_versions = ['2.83', '2.93']
58+
supported_versions = ['2.83', '2.93', '3.1']
5959

6060
if not version:
6161
return '2.93'

src/compas_blender/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def install(blender_path, version=None):
5353
The path to the folder with the version number of Blender.
5454
For example, on Mac: ``'/Applications/Blender.app/Contents/Resources/2.83'``.
5555
On Windows: ``'%PROGRAMFILES%/Blender Foundation/Blender 2.83/2.83'``.
56-
version : {'2.83', '2.93'}, optional
56+
version : {'2.83', '2.93', '3.1'}, optional
5757
The version number of Blender.
5858
Default is ``'2.93'``.
5959
@@ -151,7 +151,7 @@ def install(blender_path, version=None):
151151
parser = argparse.ArgumentParser()
152152

153153
parser.add_argument('blenderpath', nargs='?', help="The path to the folder with the version number of Blender.")
154-
parser.add_argument('-v', '--version', choices=['2.83', '2.93'], help="The version of Blender to install COMPAS in.")
154+
parser.add_argument('-v', '--version', choices=['2.83', '2.93', '3.1'], help="The version of Blender to install COMPAS in.")
155155

156156
args = parser.parse_args()
157157

src/compas_blender/uninstall.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
import os
22
import sys
3+
import compas
34

45
from compas._os import remove
56
from compas._os import remove_symlink
67
from 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

Comments
 (0)