@@ -40,12 +40,22 @@ def uninstall(version=None, packages=None):
4040 """
4141 version = compas_rhino ._check_rhino_version (version )
4242
43- # We install COMPAS packages in the scripts folder
43+ installation_paths = []
44+
45+ # In Rhino <8 We install COMPAS packages in the scripts folder
4446 # instead of directly as IPy module.
45- scripts_path = compas_rhino ._get_rhino_scripts_path (version )
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
4654
4755 # This is for old installs
4856 ipylib_path = compas_rhino ._get_rhino_ironpython_lib_path (version )
57+ if ipylib_path :
58+ installation_paths .append (ipylib_path )
4959
5060 # Filter the provided list of packages
5161 # If no packages are provided
@@ -54,31 +64,26 @@ def uninstall(version=None, packages=None):
5464
5565 # Also remove all broken symlinks
5666 # because ... they're broken!
57- for name in os .listdir (scripts_path ):
58- path = os .path .join (scripts_path , name )
59- if os .path .islink (path ):
60- if not os .path .exists (path ):
61- if name not in packages :
62- 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 )
6374
6475 # Collect paths for removal based on package names
6576 symlinks_to_uninstall = []
6677
6778 for package in packages :
68- symlink_path = os .path .join (scripts_path , package )
69- symlinks_to_uninstall .append (dict (name = package , link = symlink_path ))
70-
71- # Handle legacy install location
72- # This does not always work,
73- # and especially not in cases where it is in any case not necessary :)
74- if ipylib_path :
75- legacy_path = os .path .join (ipylib_path , package )
76- if os .path .exists (legacy_path ):
77- 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 ))
7883
7984 # There is nothing to uninstall
8085 if not symlinks_to_uninstall :
81- print ("\n No packages to uninstall from Rhino {0} scripts folder : \n {1}." .format (version , scripts_path ))
86+ print ("\n No packages to uninstall from Rhino {0} scripts folders : \n {1}." .format (version , installation_paths ))
8287 return
8388
8489 # -------------------------
@@ -113,7 +118,12 @@ def uninstall(version=None, packages=None):
113118 )
114119
115120 else :
116- if compas_rhino ._try_remove_bootstrapper (scripts_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 :
117127 results .append (("compas_bootstrapper" , "OK" ))
118128 else :
119129 results .append (
@@ -123,22 +133,11 @@ def uninstall(version=None, packages=None):
123133 )
124134 )
125135
126- # Handle legacy bootstrapper
127- # Again, only if possible...
128- if ipylib_path :
129- if not compas_rhino ._try_remove_bootstrapper (ipylib_path ):
130- results .append (
131- (
132- "compas_bootstrapper" ,
133- "ERROR: Cannot remove legacy compas_bootstrapper, try to run as administrator." ,
134- )
135- )
136-
137136 # -------------------------
138137 # Output results
139138 # -------------------------
140139
141- print ("Uninstalling COMPAS packages from Rhino {0} scripts folder : \n {1}" .format (version , scripts_path ))
140+ print ("Uninstalling COMPAS packages from Rhino {0} scripts folders : \n {1}" .format (version , installation_paths ))
142141 print ("\n The following packages have been detected and will be uninstalled:\n " )
143142
144143 for package , status in results :
0 commit comments