@@ -40,16 +40,22 @@ def uninstall(version=None, packages=None):
40
40
"""
41
41
version = compas_rhino ._check_rhino_version (version )
42
42
43
- if version == "8.0" :
44
- # In Rhino 8 there is no scripts folder
45
- installation_path = compas_rhino ._get_default_rhino_ironpython_sitepackages_path (version )
46
- else :
47
- # We install COMPAS packages in the scripts folder
48
- # instead of directly as IPy module.
49
- installation_path = compas_rhino ._get_rhino_scripts_path (version )
43
+ installation_paths = []
44
+
45
+ # In Rhino <8 We install COMPAS packages in the scripts folder
46
+ # instead of directly as IPy module.
47
+ installation_paths .append (compas_rhino ._get_rhino_scripts_path (version ))
48
+
49
+ # In Rhino 8 there is no scripts folder
50
+ try :
51
+ installation_paths .append (compas_rhino ._get_default_rhino_ironpython_sitepackages_path (version ))
52
+ except NotImplementedError :
53
+ pass
50
54
51
55
# This is for old installs
52
56
ipylib_path = compas_rhino ._get_rhino_ironpython_lib_path (version )
57
+ if ipylib_path :
58
+ installation_paths .append (ipylib_path )
53
59
54
60
# Filter the provided list of packages
55
61
# If no packages are provided
@@ -58,31 +64,26 @@ def uninstall(version=None, packages=None):
58
64
59
65
# Also remove all broken symlinks
60
66
# because ... they're broken!
61
- for name in os .listdir (installation_path ):
62
- path = os .path .join (installation_path , name )
63
- if os .path .islink (path ):
64
- if not os .path .exists (path ):
65
- if name not in packages :
66
- packages .append (name )
67
+ for installation_path in installation_paths :
68
+ for name in os .listdir (installation_path ):
69
+ path = os .path .join (installation_path , name )
70
+ if os .path .islink (path ):
71
+ if not os .path .exists (path ):
72
+ if name not in packages :
73
+ packages .append (name )
67
74
68
75
# Collect paths for removal based on package names
69
76
symlinks_to_uninstall = []
70
77
71
78
for package in packages :
72
- symlink_path = os .path .join (installation_path , package )
73
- symlinks_to_uninstall .append (dict (name = package , link = symlink_path ))
74
-
75
- # Handle legacy install location
76
- # This does not always work,
77
- # and especially not in cases where it is in any case not necessary :)
78
- if ipylib_path :
79
- legacy_path = os .path .join (ipylib_path , package )
80
- if os .path .exists (legacy_path ):
81
- symlinks_to_uninstall .append (dict (name = package , link = legacy_path ))
79
+ for installation_path in installation_paths :
80
+ symlink_path = os .path .join (installation_path , package )
81
+ if os .path .exists (symlink_path ):
82
+ symlinks_to_uninstall .append (dict (name = package , link = symlink_path ))
82
83
83
84
# There is nothing to uninstall
84
85
if not symlinks_to_uninstall :
85
- print ("\n No packages to uninstall from Rhino {0} scripts folder : \n {1}." .format (version , installation_path ))
86
+ print ("\n No packages to uninstall from Rhino {0} scripts folders : \n {1}." .format (version , installation_paths ))
86
87
return
87
88
88
89
# -------------------------
@@ -117,7 +118,12 @@ def uninstall(version=None, packages=None):
117
118
)
118
119
119
120
else :
120
- if compas_rhino ._try_remove_bootstrapper (installation_path ):
121
+ bootstrapper_removed = False
122
+ for installation_path in installation_paths :
123
+ if compas_rhino ._try_remove_bootstrapper (installation_path ):
124
+ bootstrapper_removed = True
125
+
126
+ if bootstrapper_removed :
121
127
results .append (("compas_bootstrapper" , "OK" ))
122
128
else :
123
129
results .append (
@@ -127,22 +133,11 @@ def uninstall(version=None, packages=None):
127
133
)
128
134
)
129
135
130
- # Handle legacy bootstrapper
131
- # Again, only if possible...
132
- if ipylib_path :
133
- if not compas_rhino ._try_remove_bootstrapper (ipylib_path ):
134
- results .append (
135
- (
136
- "compas_bootstrapper" ,
137
- "ERROR: Cannot remove legacy compas_bootstrapper, try to run as administrator." ,
138
- )
139
- )
140
-
141
136
# -------------------------
142
137
# Output results
143
138
# -------------------------
144
139
145
- print ("Uninstalling COMPAS packages from Rhino {0} scripts folder : \n {1}" .format (version , installation_path ))
140
+ print ("Uninstalling COMPAS packages from Rhino {0} scripts folders : \n {1}" .format (version , installation_paths ))
146
141
print ("\n The following packages have been detected and will be uninstalled:\n " )
147
142
148
143
for package , status in results :
0 commit comments