From 7e41b3e6cffcb2a8499378c556dedcc7fa22203d Mon Sep 17 00:00:00 2001 From: brgcode Date: Wed, 5 Oct 2022 17:00:50 +0200 Subject: [PATCH 1/2] add the option to specify the appdata location --- src/compas_rhino/__init__.py | 10 ++++++++-- src/compas_rhino/install.py | 22 +++++++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/compas_rhino/__init__.py b/src/compas_rhino/__init__.py index 02aa9081d39..d80cb78449b 100644 --- a/src/compas_rhino/__init__.py +++ b/src/compas_rhino/__init__.py @@ -44,6 +44,8 @@ GRASSHOPPER_PLUGIN_GUID = "b45a29b1-4343-4035-989e-044e8580d9cf" RHINOCYCLES_PLUGIN_GUID = "9bc28e9e-7a6c-4b8f-a0c6-3d05e02d1b97" +RHINO_APPDATA = None + __all__ = [ "PURGE_ON_DELETE", @@ -177,10 +179,14 @@ def _get_rhino_application_folder(version): def _get_rhino_appdata_folder(): if compas.WINDOWS: - app = os.path.join(os.getenv("APPDATA"), "McNeel", "Rhinoceros") + root = RHINO_APPDATA or os.getenv("APPDATA") + app = os.path.join(root, "McNeel", "Rhinoceros") elif compas.OSX: - app = os.path.join(os.getenv("HOME"), "Library", "Application Support", "McNeel", "Rhinoceros") + root = RHINO_APPDATA or os.path.join( + os.getenv("HOME"), "Library", "Application Support" + ) + app = os.path.join(root, "McNeel", "Rhinoceros") else: raise Exception("Unsupported platform") diff --git a/src/compas_rhino/install.py b/src/compas_rhino/install.py index b500a353927..ee548135e4d 100644 --- a/src/compas_rhino/install.py +++ b/src/compas_rhino/install.py @@ -17,7 +17,7 @@ INSTALLED_VERSION = None -def install(version=None, packages=None, clean=False): +def install(version=None, packages=None, clean=False, location=None): """Install COMPAS for Rhino. Parameters @@ -32,6 +32,10 @@ def install(version=None, packages=None, clean=False): clean : bool, optional If True, this will clean up the entire scripts folder and remove also existing symlinks that are not importable in the current environment. + location : str, optional + The location of the Rhino installation. + This optional argument could be used to install in a different location than the standard one. + The value of this argument should be the full path of the folder containing Examples -------- @@ -45,6 +49,8 @@ def install(version=None, packages=None, clean=False): python -m compas_rhino.install """ + compas_rhino.RHINO_APPDATA = location + version = compas_rhino._check_rhino_version(version) # We install COMPAS packages in the scripts folder @@ -372,9 +378,19 @@ def _filter_installable_packages(version, packages): help="The version of Rhino to install the packages in.", ) parser.add_argument("-p", "--packages", nargs="+", help="The packages to install.") - parser.add_argument("-c", "--clean", default=False, action="store_true", help="Clean up the installation directory") + parser.add_argument("--clean", dest="clean", default=False, action="store_true") + parser.add_argument( + "--location", + dest="location", + help="The location of the folder containing the top level 'McNeel' folder, if not APPDATA (Windows) or Application Support (OSX).", + ) args = parser.parse_args() compas_rhino.INSTALLATION_ARGUMENTS = args - install(version=args.version, packages=args.packages, clean=args.clean) + install( + version=args.version, + packages=args.packages, + clean=args.clean, + location=args.location, + ) From 3020191b3489fc3ad39213af4f62cd526e49f7f5 Mon Sep 17 00:00:00 2001 From: brgcode Date: Wed, 5 Oct 2022 17:10:52 +0200 Subject: [PATCH 2/2] log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 687a8035231..50973318c0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added split operation to `compas_rhino.geometry.Brep`. * Added a `RhinoArtist` in `compas_rhino`. * Added a `RhinoArtist` in `compas_ghpython`. +* Added option to provide alternative location for the parent folder "McNeel", which is usually in `APPDATA` or `Application Support`. ### Changed