Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add location option to Rhino installer #1083

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/compas_rhino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")
Expand Down
22 changes: 19 additions & 3 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 @@ -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,
)