Skip to content
Permalink
Browse files

Add support for alternative 'products' such as houdini-qt4 or houdini…

…-py3.
  • Loading branch information
captainhammy committed Oct 28, 2019
1 parent 310e1cc commit 093781f94bfc61aa9af5e710193245cc4d12e7d3
@@ -105,6 +105,7 @@ def _build_parsers():
download.add_argument("--no-install", action="store_true", help="Download but don't install", dest="no_install")
download.add_argument("--remove", action="store_true", help="Remove archive after install", dest="remove")
download.add_argument("version", nargs="?", help="The version to download")
download.add_argument("--product", nargs="?", default="houdini", help="The version to download")

# Install sub parser
install = subparsers.add_parser("install", help="Install things")
@@ -137,12 +138,12 @@ def _display_versions():
for build in _BUILD_MANAGER.installed:
if build == default_build:
# Run the message through the style function.
msg = colored(str(build), "cyan")
msg = colored(build.display_name, "cyan")

output.append(msg)

else:
output.append(str(build))
output.append(build.display_name)

six.print_('\t' + ' '.join(output))

@@ -157,10 +158,16 @@ def _download_handler(args):
:return:
"""
product = args.product

if args.list_builds:
six.print_("Houdini builds available to download:\n")

ht.machinery.sidefx_web_api.list_builds(version=args.version, only_production=args.only_production)
ht.machinery.sidefx_web_api.list_builds(
version=args.version,
product=product,
only_production=args.only_production
)

return

@@ -169,7 +176,7 @@ def _download_handler(args):

return

downloaded_archives = _BUILD_MANAGER.download_builds([args.version])
downloaded_archives = _BUILD_MANAGER.download_builds([args.version], product=product)

if not args.no_install:
for archive in downloaded_archives:
@@ -257,7 +264,7 @@ def _print_local_build_list(build_list, message):
"""
six.print_(message)

six.print_('\t' + " ".join([str(build) for build in build_list]))
six.print_('\t' + " ".join([build.display_name for build in build_list]))

six.print_()

@@ -1,5 +1,5 @@
{
"file_template": "houdini-{version}-{arch}.{ext}",
"file_template": "{product}-{version}-{arch}.{ext}",

"types": {
"Linux": {
@@ -2,8 +2,8 @@
"system": {
"installation": {
"target": "/opt",
"folder": "hfs{version}",
"symlink": "hfs{major_minor}"
"folder": "hfs{version}{product}",
"symlink": "hfs{major_minor}{product}"
},

"plugins": {
@@ -46,16 +46,17 @@ class HoudiniBase(object):
"""

def __init__(self, path, version):
def __init__(self, path, version, product=None):
self._path = path

self._major, self._minor, self._build, self._candidate = version

self._product = product
self._plugin_path = None

if _SETTINGS_MANAGER.system.plugins is not None:
plugin_folder = self.format_string(
_SETTINGS_MANAGER.system.plugins.folder
_SETTINGS_MANAGER.system.plugins.folder,
)

# Generate the path to install the build to.
@@ -115,7 +116,7 @@ def __hash__(self):
def __repr__(self):
return "<{} {} @ {}>".format(
self.__class__.__name__,
str(self),
self.display_name,
self.path
)

@@ -148,6 +149,16 @@ def candidate(self):
"""int: The release candidate number for this build. """
return self._candidate

@property
def display_name(self):
"""str: The name to display ({version}{-product})."""
value = str(self)

if self.product is not None:
value = "{}-{}".format(value, self.product)

return value

@property
def major(self):
"""int: The major number for this build. """
@@ -176,6 +187,11 @@ def plugin_path(self):

return os.path.expandvars(self._plugin_path)

@property
def product(self):
"""str: The optional extra product."""
return self._product

@property
def version(self):
"""tuple(int): A tuple containing version information. """
@@ -209,6 +225,12 @@ def format_string(self, value):
"candidate": self.candidate,
}

if self.product is not None:
args["product"] = "-{}".format(self.product)

else:
args["product"] = ""

return value.format(**args)


@@ -341,6 +363,7 @@ def _populate_installable_packages(self):
archive_template = _SETTINGS_MANAGER.build_data.file_template

glob_string = archive_template.format(
product="houdini*",
version="*",
arch="*",
ext=archive_ext
@@ -371,6 +394,7 @@ def _populate_installed_builds(self):

format_args = {
"version": "*",
"product": "*"
}

# Generate the path to glob with.
@@ -434,7 +458,7 @@ def download_and_install(build_numbers, create_symlink=False):
package.install(create_symlink)

@staticmethod
def download_builds(build_numbers):
def download_builds(build_numbers, product="houdini"):
"""Download and a list of builds.
Build numbers can be explicit numbers or major.minor versions.
@@ -453,7 +477,7 @@ def download_builds(build_numbers):
# Get the build file name for the current day
version, build = _get_build_to_download(build_number)

downloaded_path = sidefx_web_api.download_build(download_dir, version, build)
downloaded_path = sidefx_web_api.download_build(download_dir, version, build, product=product)

archive_paths.append(downloaded_path)

@@ -623,14 +647,20 @@ def __init__(self, path):
archive_ext = _SETTINGS_MANAGER.build_data.get_archive_extension()

pattern = archive_template.format(
product="houdini(-[a-z0-9]+)*",
version="([0-9\\.]*)",
arch=".+",
ext=archive_ext
)

result = re.match(pattern, os.path.basename(path))

version_string = result.group(1)
product = result.group(1)

if product is not None:
product = product.lstrip("-")

version_string = result.group(2)

# Get the build number components.
components = [int(val) for val in version_string.split(".")]
@@ -640,7 +670,7 @@ def __init__(self, path):
if len(components) == 3:
components.append(None)

super(HoudiniInstallFile, self).__init__(path, components)
super(HoudiniInstallFile, self).__init__(path, components, product=product)

self._install_target = _SETTINGS_MANAGER.system.installation.target
self._install_folder = _SETTINGS_MANAGER.system.installation.folder
@@ -744,7 +774,7 @@ def install(self, create_symlink=False):
# Check to see if the build is already installed. If it is
# we throw an exception.
if os.path.exists(install_path):
raise BuildAlreadyInstalledError(str(self))
raise BuildAlreadyInstalledError(self.display_name)

system = platform.system()

@@ -758,7 +788,7 @@ def install(self, create_symlink=False):
raise UnsupportedOSError("OS X is not supported")

# Notify that the build installation has completed.
six.print_("Installation of Houdini {} complete.".format(self))
six.print_("Installation of Houdini {} complete.".format(self.display_name))


class HoudiniInstallationSettings(object):
@@ -975,12 +1005,19 @@ def __init__(self, path):
folder_name = _SETTINGS_MANAGER.system.installation.folder

# Replace
pattern = folder_name.format(version="([0-9\\.]*)")
pattern = folder_name.format(
version="([0-9\\.]*)",
product="(-[a-z0-9]*)*"
)

result = re.match(pattern, os.path.basename(path))

# Extract the build version numbers from the directory name.
version_string = result.group(1)
product = result.group(2)

if product is not None:
product = product.lstrip("-")

# Get the build number components.
components = [int(val) for val in version_string.split(".")]
@@ -990,7 +1027,7 @@ def __init__(self, path):
if len(components) == 3:
components.append(None)

super(InstalledHoudiniBuild, self).__init__(path, components)
super(InstalledHoudiniBuild, self).__init__(path, components, product=product)

# -------------------------------------------------------------------------
# METHODS
@@ -1196,10 +1233,16 @@ def find_matching_builds(match_string, builds):
:rtype: InstalledHoudiniBuild or None
"""
version = match_string
product = None

if '-' in match_string:
version, product = match_string.split('-')

# Filter all installed builds that match the build version
# string.
matching = [build for build in builds
if str(build).startswith(match_string)]
if str(build).startswith(version) and build.product == product]

# If there are any that match, use the latest/only one.
if matching:

0 comments on commit 093781f

Please sign in to comment.
You can’t perform that action at this time.