Skip to content

Commit

Permalink
add the option to specify the appdata location
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Oct 5, 2022
1 parent 15e73fb commit 5799251
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/compas_rhino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
GRASSHOPPER_PLUGIN_GUID = "b45a29b1-4343-4035-989e-044e8580d9cf"
RHINOCYCLES_PLUGIN_GUID = "9bc28e9e-7a6c-4b8f-a0c6-3d05e02d1b97"

RHINO_APPDATA = None


__all__ = [
"PURGE_ON_DELETE",
Expand Down Expand Up @@ -177,12 +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")
Expand Down
20 changes: 18 additions & 2 deletions src/compas_rhino/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
--------
Expand All @@ -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
Expand Down Expand Up @@ -387,7 +393,17 @@ def _filter_installable_packages(version, packages):
)
parser.add_argument("-p", "--packages", nargs="+", help="The packages to install.")
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()

install(version=args.version, packages=args.packages, clean=args.clean)
install(
version=args.version,
packages=args.packages,
clean=args.clean,
location=args.location,
)

0 comments on commit 5799251

Please sign in to comment.