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

Specification of Rhino version during installation #1305

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
40 changes: 40 additions & 0 deletions src/compas_rhino/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
SUPPORTED_VERSIONS = ["5.0", "6.0", "7.0", "8.0"]
DEFAULT_VERSION = "8.0"
INSTALLED_VERSION = None
INSTALLED_RHINO_VERSIONS = []

INSTALLATION_ARGUMENTS = None

Expand All @@ -30,6 +31,7 @@
"SUPPORTED_VERSIONS",
"DEFAULT_VERSION",
"INSTALLED_VERSION",
"INSTALLED_RHINO_VERSIONS",
"IRONPYTHON_PLUGIN_GUID",
"GRASSHOPPER_PLUGIN_GUID",
"RHINOCYCLES_PLUGIN_GUID",
Expand Down Expand Up @@ -202,6 +204,44 @@ def _try_remove_bootstrapper(path):
# =============================================================================


def _get_application_folder():
if compas.WINDOWS:
return os.getenv("ProgramFiles")

if compas.OSX:
return os.path.join("/", "Applications")

raise Exception("Unsupported platform")


def _get_installed_rhino_versions():
global INSTALLED_RHINO_VERSIONS

appfolder = _get_application_folder()
versions = []

if compas.WINDOWS:
for version in ["6", "7", "8", "9"]:
if os.path.exists(os.path.join(appfolder, "Rhino {}".format(version))):
versions.append(version)

elif compas.OSX:
if os.path.exists(os.path.join(appfolder, "Rhinocerso.app")):
versions.append("6")

for version in ["7", "8", "9"]:
if os.path.exists(os.path.join(appfolder, "Rhino {}.app".format(version))):
versions.append(version)

else:
raise Exception("Unsupported platform")

versions = ["{:.1f}".format(float(v)) for v in versions]
INSTALLED_RHINO_VERSIONS = versions

return versions


def _get_rhino_application_folder(version):
version = _check_rhino_version(version)
version = version.split(".")[0] # take the major only
Expand Down
5 changes: 4 additions & 1 deletion src/compas_rhino/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def install(version=None, packages=None, clean=False):
----------
version : {'5.0', '6.0', '7.0', '8.0'}, optional
The version number of Rhino.
Default is ``'7.0'``.
Default is the latest supported version you have installed.
packages : list of str, optional
List of packages to install or None to use default package list.
Default is the result of ``installable_rhino_packages``,
Expand All @@ -41,8 +41,11 @@ def install(version=None, packages=None, clean=False):
python -m compas_rhino.install

"""
version = "{:.1f}".format(float(version))
version = compas_rhino._check_rhino_version(version)

# Check if the

# We install COMPAS packages in the scripts folder
# instead of directly as IPy module.
# scripts_path = compas_rhino._get_rhino_scripts_path(version)
Expand Down
6 changes: 6 additions & 0 deletions src/compas_rhino/print_installed_rhino_versions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import compas_rhino


if __name__ == "__main__":

print(compas_rhino._get_installed_rhino_versions())
Loading