Example #1
0
def build_context_from_scratch(package, version, root, source_path=''):
    '''Build the given `package` recursively.

    Note:
        This function assumes that `package` has not been built before.
        "Partial" building is not supported and old files will be overwritten.

    Args:
        package (str):
            The name of the Rez package to build.
        version (str):
            The specific release of `package` to build.
        root (str):
            The absolute path to where all Rez packages can be found.
        source_path (str, optional):
            The absolute path to where the package.py file exists.
            If no path is given, assume that the source_path can be found
            under `root`. Default: "".

    Raises:
        ValueError: If `source_path` was not given and could not be found.

    '''
    from rezzurect.utils import config_helper
    from rezzurect import manager
    from rez import config

    if not source_path:
        source_path = os.path.join(root, package, version)

        if not os.path.isfile(os.path.join(source_path, 'package.py')):
            raise ValueError('source_path could not be found.')

    # TODO : Using `config_package_root` may not work for deployment.
    #        Double-check this! TD117
    #
    config_package_root = config.config.get('local_packages_path')

    version_path = os.path.join(
        config_package_root,
        package,
        version,
    )

    install_path = os.path.join(version_path,
                                config_helper.INSTALL_FOLDER_NAME)

    # TODO : Running makedirs here is not be necessary for every package.
    #        Consider removing.
    #
    if not os.path.isdir(install_path):
        os.makedirs(install_path)

    environment.init(source_path, install_path)
    manager.install(package, root, config_package_root, version=version)
def build(source_path, build_path, install_path, targets):
    # IMPORT THIRD-PARTY LIBRARIES
    from rezzurect.utils import config_helper
    from rezzurect import environment
    from rezzurect import chooser
    from rezzurect import manager

    package_install_path = os.path.join(install_path, config_helper.INSTALL_FOLDER_NAME)
    version = os.environ['REZ_BUILD_PROJECT_VERSION']

    environment.init(source_path, package_install_path)

    adapter = chooser.get_build_adapter('nuke_installation', version)
    adapter.make_install()

    rezzurect_destination = os.path.join(install_path, 'python')
    manager.copy_rezzurect_to(rezzurect_destination)