@@ -40,16 +40,22 @@ def uninstall(version=None, packages=None):
4040 """
4141 version = compas_rhino ._check_rhino_version (version )
4242
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
5054
5155 # This is for old installs
5256 ipylib_path = compas_rhino ._get_rhino_ironpython_lib_path (version )
57+ if ipylib_path :
58+ installation_paths .append (ipylib_path )
5359
5460 # Filter the provided list of packages
5561 # If no packages are provided
@@ -58,31 +64,26 @@ def uninstall(version=None, packages=None):
5864
5965 # Also remove all broken symlinks
6066 # 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 )
6774
6875 # Collect paths for removal based on package names
6976 symlinks_to_uninstall = []
7077
7178 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 ))
8283
8384 # There is nothing to uninstall
8485 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 ))
8687 return
8788
8889 # -------------------------
@@ -117,7 +118,12 @@ def uninstall(version=None, packages=None):
117118 )
118119
119120 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 :
121127 results .append (("compas_bootstrapper" , "OK" ))
122128 else :
123129 results .append (
@@ -127,22 +133,11 @@ def uninstall(version=None, packages=None):
127133 )
128134 )
129135
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-
141136 # -------------------------
142137 # Output results
143138 # -------------------------
144139
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 ))
146141 print ("\n The following packages have been detected and will be uninstalled:\n " )
147142
148143 for package , status in results :
0 commit comments