Esempio n. 1
0
File: rezgui.py Progetto: rvsiy/rez
def bind(path, version_range=None, opts=None, parser=None):
    rez_version = Version(rez.__version__)
    check_version(rez_version, version_range)

    rez_major_version = rez_version.trim(1)
    rez_major_minor_version = rez_version.trim(2)
    next_major = int(str(rez_major_version)) + 1
    rez_req_str = "rez-%s+<%d" % (str(rez_major_minor_version), next_major)

    gui_lib = getattr(opts, "gui_lib", "")

    def make_root(variant, root):
        # copy source
        rez_path = rez.__path__[0]
        site_path = os.path.dirname(rez_path)
        rezgui_path = os.path.join(site_path, "rezgui")
        shutil.copytree(rezgui_path, os.path.join(root, "rezgui"))

        # create rez-gui executable
        binpath = make_dirs(root, "bin")
        filepath = os.path.join(binpath, "rez-gui")
        create_executable_script(filepath, rez_gui_source)

    # create package
    with make_package("rezgui", path, make_root=make_root) as pkg:
        pkg.version = rez_version
        pkg.variants = [system.variant]
        pkg.commands = commands
        pkg.tools = ["rez-gui"]

        pkg.requires = [rez_req_str]
        if gui_lib:
            pkg.requires.append(gui_lib)

    return "rezgui", rez_version
Esempio n. 2
0
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    if opts and opts.exe:
        exepath = find_exe("python", opts.exe)
        code = "import sys; print '.'.join(str(x) for x in sys.version_info)"
        version = extract_version(exepath, ["-c", code])
    else:
        exepath = sys.executable
        strver = '.'.join(str(x) for x in sys.version_info[:3])
        version = Version(strver)

    check_version(version, version_range)

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        link = os.path.join(binpath, "python")
        platform_.symlink(exepath, link)

    with make_package("python", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["python"]
        pkg.commands = commands
        pkg.variants = [system.variant]

    return "python", version
Esempio n. 3
0
def bind(path, version_range=None, opts=None, parser=None):
    rez_version = Version(rez.__version__)
    check_version(rez_version, version_range)

    rez_major_version = rez_version.trim(1)
    rez_major_minor_version = rez_version.trim(2)
    next_major = int(str(rez_major_version)) + 1
    rez_req_str = "rez-%s+<%d" % (str(rez_major_minor_version), next_major)

    gui_lib = getattr(opts, "gui_lib", "")

    def make_root(variant, root):
        # copy source
        rez_path = rez.__path__[0]
        site_path = os.path.dirname(rez_path)
        rezgui_path = os.path.join(site_path, "rezgui")
        shutil.copytree(rezgui_path, os.path.join(root, "rezgui"))

        # create rez-gui executable
        binpath = make_dirs(root, "bin")
        filepath = os.path.join(binpath, "rez-gui")
        create_executable_script(filepath, rez_gui_source)

    # create package
    with make_package("rezgui", path, make_root=make_root) as pkg:
        pkg.version = rez_version
        pkg.variants = [system.variant]
        pkg.commands = commands
        pkg.tools = ["rez-gui"]

        pkg.requires = [rez_req_str]
        if gui_lib:
            pkg.requires.append(gui_lib)

    return "rezgui", rez_version
Esempio n. 4
0
File: python.py Progetto: opcg/rez
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    exepath = find_exe("python", opts.exe)
    code = "import sys;print('.'.join(str(x) for x in sys.version_info))"
    version = extract_version(exepath, ["-c", code])

    check_version(version, version_range)
    log("binding python: %s" % exepath)

    def make_root(variant, root):
        bindir = make_dirs(root, "bin")

        if os.name == "nt":
            fname = os.path.join(bindir, "python.bat")
            with open(fname, "w") as f:
                f.write(bat.format(python=exepath))

        else:
            fname = os.path.join(bindir, "python")
            with open(fname, "w") as f:
                f.write(sh.format(python=exepath))

            # Make executable
            st = os.stat(fname)
            os.chmod(fname, st.st_mode | stat.S_IEXEC)

    with make_package("python", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["python"]
        pkg.commands = commands
        pkg.variants = [system.variant]
        pkg.exe = exepath

    return pkg.installed_variants
Esempio n. 5
0
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    if opts and opts.exe:
        exepath = find_exe("python", opts.exe)
        code = "import sys; print '.'.join(str(x) for x in sys.version_info)"
        version = extract_version(exepath, ["-c", code])
    else:
        exepath = sys.executable
        strver = '.'.join(str(x) for x in sys.version_info[:3])
        version = Version(strver)

    check_version(version, version_range)

    def make_root(variant, root):
        if platform_.name != 'windows':
            binpath = make_dirs(root, "bin")
            link = os.path.join(binpath, "python")
            platform_.symlink(exepath, link)

    with make_package("python", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["python"]
        if platform_.name == 'windows':
            pkg.commands = win_commands(exepath)
        else:
            pkg.commands = nix_commands
        pkg.variants = [system.variant]

    return "python", version
Esempio n. 6
0
File: arch.py Progetto: rvsiy/rez
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.arch)
    check_version(version, version_range)

    with make_package("arch", path) as pkg:
        pkg.version = version

    return ("arch", version)
Esempio n. 7
0
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.platform)
    check_version(version, version_range)

    with make_package("platform", path) as pkg:
        pkg.version = version

    return "platform", version
Esempio n. 8
0
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.arch)
    check_version(version, version_range)

    with make_package("arch", path) as pkg:
        pkg.version = version

    return pkg.installed_variants
Esempio n. 9
0
File: os.py Progetto: sonictk/rez
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.os)
    check_version(version, version_range)

    with make_package("os", path) as pkg:
        pkg.version = version
        pkg.requires = ["platform-%s" % system.platform, "arch-%s" % system.arch]

    return pkg.installed_variants
Esempio n. 10
0
def bind(path, version_range=None, opts=None, parser=None):
    versions = ["AMD64", "AMD86"]
    for version in versions:
        version = Version(version)
        check_version(version, version_range)

        with make_package("target", path) as pkg:
            pkg.version = version

    return ("target", versions)
Esempio n. 11
0
File: os.py Progetto: skral/rez
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.os)
    check_version(version, version_range)

    with make_package("os", path) as pkg:
        pkg.version = version
        pkg.requires = [
            "platform-%s" % system.platform,
            "arch-%s" % system.arch
        ]

    return "os", version
Esempio n. 12
0
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    exepath = find_exe("python", opts.exe)
    code = "import sys; print '.'.join(str(x) for x in sys.version_info)"
    version = extract_version(exepath, ["-c", code])

    check_version(version, version_range)
    log("binding python: %s" % exepath)

    # find builtin modules
    builtin_paths = {}
    entries = [("lib", "os"),
               ("extra", "setuptools")]

    for dirname, module_name in entries:
        success, out, err = run_python_command([
            "import %s" % module_name,
            "print %s.__file__" % module_name])

        if success:
            pypath = os.path.dirname(out)
            if os.path.basename(pypath) == module_name:
                pypath = os.path.dirname(pypath)

            if pypath not in builtin_paths.values():
                builtin_paths[dirname] = pypath

    # make the package
    #

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        link = os.path.join(binpath, "python")
        platform_.symlink(exepath, link)

        if builtin_paths:
            pypath = make_dirs(root, "python")
            for dirname, srcpath in builtin_paths.iteritems():
                destpath = os.path.join(pypath, dirname)
                log("Copying builtins from %s to %s..." % (srcpath, destpath))
                shutil.copytree(srcpath, destpath)

    with make_package("python", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["python"]
        pkg.commands = commands
        pkg.variants = [system.variant]

        if builtin_paths:
            pkg.post_commands = post_commands

    return pkg.installed_variants
Esempio n. 13
0
File: os.py Progetto: wwfxuk/rez
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.os)
    check_version(version, version_range)

    with make_package("os", path) as pkg:
        pkg.version = version
        pkg.requires = [
            "platform-%s" % system.platform,
            "arch-%s" % system.arch
        ]
        pkg.relocatable = True

    return pkg.installed_variants
Esempio n. 14
0
def bind(path, version_range=None, opts=None, parser=None):
    version = Version("1.0")
    check_version(version, version_range)

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        filepath = os.path.join(binpath, "hello_world")
        create_executable_script(filepath, hello_world_source)

    with make_package("hello_world", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["hello_world"]
        pkg.commands = commands

    return pkg.installed_variants
Esempio n. 15
0
def bind(path, version_range=None, opts=None, parser=None):
    version = Version("1.0")
    check_version(version, version_range)

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        filepath = os.path.join(binpath, "hello_world")
        create_executable_script(filepath, hello_world_source)

    with make_package("hello_world", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["hello_world"]
        pkg.commands = commands

    return pkg.installed_variants
Esempio n. 16
0
File: cmake.py Progetto: rvsiy/rez
def bind(path, version_range=None, opts=None, parser=None):
    exepath = find_exe("cmake", getattr(opts, "exe", None))
    version = extract_version(exepath, "--version")
    check_version(version, version_range)

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        link = os.path.join(binpath, "cmake")
        platform_.symlink(exepath, link)

    with make_package("cmake", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["cmake"]
        pkg.commands = commands
        pkg.variants = [system.variant]

    return "cmake", version
Esempio n. 17
0
File: cmake.py Progetto: rvsiy/rez
def bind(path, version_range=None, opts=None, parser=None):
    exepath = find_exe("cmake", getattr(opts, "exe", None))
    version = extract_version(exepath, "--version")
    check_version(version, version_range)

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        link = os.path.join(binpath, "cmake")
        platform_.symlink(exepath, link)

    with make_package("cmake", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["cmake"]
        pkg.commands = commands
        pkg.variants = [system.variant]

    return "cmake", version
Esempio n. 18
0
def bind(path, version_range=None, opts=None, parser=None):
    is_win64 = False
    if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86':
        is_win64 = True
    if os.environ.get('PROCESSOR_ARCHITEW6432'):
        is_win64 = True
    if os.environ.get('ProgramW6432'):
        is_win64 = True

    msvcs = enumerate_msvc(is_win64)
    if not msvcs:
        version = getattr(opts, "version", None)
        if not version:
            _msvc_root = getattr(opts, "root", None)
            if not _msvc_root:
                print "can't find msvc root, use --root and pass the directory to find vcvarsall.bat"
                exit(1)
            else:
                vcvarsall = os.path.join(_msvc_root, "vcvarsall.bat")
                if not os.path.isfile(vcvarsall):
                    print "can't find:", vcvarsall
                    exit(1)
                version = os.path.split(_msvc_root)[-2].split()[-1]
                msvcs[version] = _msvc_root

    for variant in ['target-AMD64', 'target-AMD86']:
        variants = system.variant+[variant]
        for version, msvc_root in msvcs.iteritems():
            check_version(version, version_range)

            def make_root(variant, root):
                binpath = make_dirs(root, "bin")
                bat = os.path.join(binpath, "setupmsvc.bat")
                with open(bat, "w") as f:
                    f.write(setupmsvc.format(msvc_root=msvc_root))

            with make_package("msvc", path, make_root=make_root) as pkg:
                pkg.version = version
                pkg.tools = ["setupmsvc"]
                pkg.commands = commands
                pkg.variants = [variants]

    return "msvc", msvcs.keys()
Esempio n. 19
0
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    exepath = find_exe("python", opts.exe)
    code = "import sys;print('.'.join(str(x) for x in sys.version_info))"
    version = extract_version(exepath, ["-c", code])

    check_version(version, version_range)
    log("binding python: %s" % exepath)

    def make_root(variant, root):
        make_dirs(root, "python")

    with make_package("python", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.tools = ["python"]
        pkg.commands = commands
        pkg.variants = [system.variant]
        pkg.exe = exepath

    return pkg.installed_variants
Esempio n. 20
0
def bind(path, version_range=None, opts=None, parser=None):
    version = rez.__version__
    check_version(version, version_range)

    def make_root(variant, root):
        # copy source
        rez_path = rez.__path__[0]
        site_path = os.path.dirname(rez_path)
        rezplugins_path = os.path.join(site_path, "rezplugins")

        shutil.copytree(rez_path, os.path.join(root, "rez"))
        shutil.copytree(rezplugins_path, os.path.join(root, "rezplugins"))

    with make_package("rez", path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.commands = commands
        pkg.requires = ["python-2.6+<3"]
        pkg.variants = [system.variant]

    return "rez", version
Esempio n. 21
0
def bind(path, version_range=None, opts=None, parser=None):
    # find executable, determine version
    if opts and opts.root:
        bin_path = opts.root
    else:
        possible_paths = [r'C:\Program Files (x86)\QuickTime']
        for root_path in possible_paths:
            if os.path.exists(root_path):
                bin_path = root_path
                break
        else:
            raise EnvironmentError(
                'Unable to find Quicktime on this system in the paths; {}'.format(
                    ', '.join(possible_paths)
                )
            )

    if platform_.name == 'windows':
        from win32api import GetFileVersionInfo, LOWORD, HIWORD
        try:
            info = GetFileVersionInfo(os.path.join(bin_path, 'QuickTimePlayer.exe'), "\\")
            ms = info['FileVersionMS']
            ls = info['FileVersionLS']
            version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
        except:
            raise EnvironmentError('Unknown version')
    else:
        raise EnvironmentError('Only binds on windows at the moment')

    check_version(version, version_range)

    with make_package("quicktime", path) as pkg:
        pkg.version = version
        if platform_.name == 'windows':
            pkg.tools = ["QuickTimePlayer.exe"]
            pkg.commands = win_commands(bin_path)
        else:
            raise EnvironmentError('Only binds on windows at the moment')
        pkg.variants = [system.variant]

    return "quicktime", version
Esempio n. 22
0
def bind(path, version_range=None, opts=None, parser=None):
    version = Version(system.platform)
    check_version(version, version_range)

    def post_commands():
        """Setup default XDG_* environment variables.

        https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables
        """
        import os
        xdg_defaults = (
            ('XDG_DATA_HOME', ['$HOME/.local/share']),
            ('XDG_DATA_DIRS', ['/usr/local/share', '/usr/share']),
            ('XDG_CONFIG_HOME', ['$HOME/.config']),
            ('XDG_CONFIG_DIRS', ['/etc/xdg']),
            ('XDG_CACHE_HOME', ['$HOME/.cache']),
        )
        for xdg_var, defaults in xdg_defaults:
            invalid_var = undefined(xdg_var) or not str(env[xdg_var])
            paths = [] if invalid_var else str(env[xdg_var]).split(os.pathsep)
            append = len(defaults) != 1

            for default_path in defaults:
                expanded = expandvars(default_path)
                if not (default_path in paths or expanded in paths):
                    if append:
                        env[xdg_var].append(expanded)
                    else:
                        env[xdg_var] = expanded

    with make_package("platform", path) as pkg:
        pkg.version = version
        pkg.relocatable = True
        if system.platform == 'linux':
            pkg.post_commands = post_commands

    return pkg.installed_variants
Esempio n. 23
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # find executable, determine version
    if opts and opts.root:
        bin_path = opts.root
    else:
        installed_versions = []
        autodesk_root = r'C:\Program Files\Autodesk'
        for app_folder in os.listdir(autodesk_root):
            if app_folder.startswith('3ds Max'):
                installed_versions.append(
                    (app_folder,
                     Version(app_folder.replace('3ds Max', '').strip())))
        if len(installed_versions) < 1:
            raise EnvironmentError(
                'Unable to find any installed version of 3ds Max under "{}"'.
                format(autodesk_root))

        app_folder, version = sorted(installed_versions,
                                     key=lambda v: v[1])[-1]

        bin_path = os.path.join(autodesk_root, app_folder)

    from win32api import GetFileVersionInfo, LOWORD, HIWORD
    try:
        info = GetFileVersionInfo(os.path.join(bin_path, '3dsmax.exe'), "\\")
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms),
                                               HIWORD(ls), LOWORD(ls)))
    except:
        raise EnvironmentError('Unknown version')

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(os.path.join(resources_path, '3dsmax_icon.png'),
                    os.path.join(path, '3dsmax_icon.png'))

    make_root_partial = functools.partial(
        make_root,
        resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("3dsmax", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["3dsmax"]
        pkg.description = '3D DCC application'
        pkg.authors = ['Autodesk']
        pkg.requires = ['roaming_user']
        pkg.nice_name = '3DS Max'

        pkg.tools_info = {
            '3dsmax': {
                'command': [
                    'start', '3DSMax', '/D', '%ADSK_3DSMAX_x64_2015%', '/wait',
                    '/B', '3dsmax.exe'
                ],
                'nice_name':
                '3ds Max',
                'priority':
                89,
                'icon':
                '{root}/3dsmax_icon.png',
                'launch_in_prompt':
                False
            }
        }
        pkg.commands = win_commands(bin_path)
        pkg.variants = [system.variant]

    return "3dsmax", version
Esempio n. 24
0
def bind(path, version_range=None, opts=None, parser=None):
    if opts and opts.pypkg:
        py_package_name = opts.pypkg
        if opts.name:
            package_name = opts.name
        else:
            package_name = py_package_name.replace('-', '_')
    else:
        raise ValueError('A package name needs to be specified')

    # connect to PyPi and get the released package versions
    pypi_client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
    package_versions = sorted(pypi_client.package_releases(py_package_name),
                              key=lambda v: Version(v))
    if len(package_versions) < 1:
        raise ValueError('Invalid package name: {}'.format(package_name))

    # get the version
    if opts.version:
        version = next((v for v in package_versions if v == opts.version),
                       None)
        if version is None:
            raise ValueError('Invalid version: {}, valid versions: {}'.format(
                opts.version, package_versions))
    else:
        version = package_versions[-1]

    check_version(Version(version), version_range)

    # get the source distribution, this could be better and try to install wheels as well
    release_info = next(
        (r for r in pypi_client.release_urls(py_package_name, version)
         if r['packagetype'] == 'sdist'), None)

    if release_info is None:
        raise ValueError(
            'No source distribution (we don\'t support wheels at the moment) for {} {}'
            .format(py_package_name, version))

    # clear the temp dir if it exists
    tmp_dir = os.path.join(platform_.tmpdir, package_name)
    if os.path.exists(tmp_dir):
        shutil.rmtree(tmp_dir)
    os.mkdir(tmp_dir)

    # download file to tmp dir
    handle = urllib2.urlopen(release_info['url'])
    src_archive = os.path.join(tmp_dir, release_info['filename'])
    with open(src_archive, 'wb') as src_archive_fp:
        src_archive_fp.write(handle.read())

    # decompress the file
    package_dir = None
    if release_info['filename'].endswith('.zip'):
        zfile = zipfile.ZipFile(src_archive, 'r')
        zfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.zip', '')
    elif release_info['filename'].endswith('.tar.gz'):
        tfile = tarfile.open(src_archive, 'r:gz')
        tfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.tar.gz', '')
    elif release_info['filename'].endswith('.tgz'):
        tfile = tarfile.open(src_archive, 'r:gz')
        tfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.tgz', '')
    else:
        raise ValueError(
            'Package file downloaded cannot be decompressed: {}'.format(
                src_archive))

    setup_file = os.path.join(package_dir, 'setup.py')

    if not os.path.exists(setup_file):
        raise RuntimeError(
            'Package does not contain a "setup.py" file in the root of the archive: {}'
            .format(py_package_name))

    def setup_dummy(*args, **kwargs):
        global SETUPTOOLS_ARGS
        SETUPTOOLS_ARGS = {}

        if 'scripts' in kwargs:
            SETUPTOOLS_ARGS['scripts'] = kwargs['scripts']

        if 'description' in kwargs:
            SETUPTOOLS_ARGS['description'] = kwargs['description']

        if 'long_description' in kwargs:
            SETUPTOOLS_ARGS['long_description'] = kwargs['long_description']

        if 'author' in kwargs:
            SETUPTOOLS_ARGS['author'] = kwargs['author']

        if 'author_email' in kwargs:
            SETUPTOOLS_ARGS['author_email'] = kwargs['author_email']

        if 'install_requires' in kwargs:
            SETUPTOOLS_ARGS['install_requires'] = kwargs['install_requires']

        if 'setup_requires' in kwargs:
            SETUPTOOLS_ARGS['setup_requires'] = kwargs['setup_requires']

        if 'version' in kwargs:
            SETUPTOOLS_ARGS['version'] = kwargs['version']
        else:
            raise RuntimeError('A package must have a version.')

    # monkey patch the setup function so we can steal the arguments passed to it
    setuptools.setup = setup_dummy
    distutils.core.setup = setup_dummy

    cwd = os.getcwd()
    os.chdir(package_dir)
    sys.path.extend([package_dir])
    old_args = sys.argv[:]
    try:
        _ = imp.load_source('{}_setup'.format(package_name), setup_file)
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e
    sys.argv = old_args[:]
    os.chdir(cwd)
    sys.path.remove(package_dir)

    def parse_setup_requirements(req_str):
        '''
        e.g. "arrow >= 0.4.4, < 1" -> 'arrow-0.4.4+<1
        :param req_str: requirement in the setuptools format
        :return: requirement in the rez format
        '''

        if not any((op in req_str for op in ['<', '>', '='])):
            # even simpler "arrow" req
            return req_str.replace('-', '_').strip()
        if '==' in req_str:
            # just a simple "arrow == 0.4.4" req
            req_pgk_name, req_version = req_str.split('==')
            return '{}-{}'.format(
                req_pgk_name.replace('-', '_').strip(), req_version.strip())

        complex_req_match = re.match(
            r'^(?P<pkg_name>[a-zA-Z0-9\.-_]+) *(?P<reqs>[\.,<>=0-9) ]+)$',
            req_str.strip())
        if not complex_req_match:
            raise RuntimeError(
                'Unable to parse requirement; {}'.format(req_str))

        req_pgk_name = complex_req_match.group('pkg_name')
        req_pgk_req_str = complex_req_match.group('reqs')
        requirements = map(lambda s: s.strip(), req_pgk_req_str.split(','))

        versions_rewrite = []
        for sub_requirement_str in requirements:
            sub_requirement_match = re.match(r'([<>=]+?) ?([0-9a-zA-Z\.]+)',
                                             sub_requirement_str)
            operation = sub_requirement_match.group(1).strip()
            req_version = sub_requirement_match.group(2).strip()
            if operation == '>=':
                versions_rewrite.insert(0, '{}+'.format(req_version))
            elif operation == '<':
                versions_rewrite.append('<{}'.format(req_version))
            else:
                raise RuntimeError(
                    'Unable to translate operation: "{}" in requirement: {}'.
                    format(operation, req_str))
        return '{}-{}'.format(req_pgk_name.replace('-', '_'),
                              ''.join(versions_rewrite))

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        pythonpath = make_dirs(root, "python")
        headerpath = make_dirs(root, "include")
        install_cmd = ' '.join([
            'pip', 'install', '--no-deps', '--ignore-installed', '--verbose',
            '--verbose', '--verbose', '--global-option="--verbose"',
            '--install-option="--install-headers={}"'.format(headerpath),
            '--install-option="--install-purelib={}"'.format(pythonpath),
            '--install-option="--install-platlib={}"'.format(pythonpath),
            '--install-option="--install-scripts={}"'.format(binpath),
            py_package_name
        ])
        try:
            subprocess.check_output(install_cmd, cwd=package_dir)
        except subprocess.CalledProcessError as _:
            raise RuntimeError(
                'Bind failed to install python package with command: {}'.
                format(install_cmd))

    with make_package(package_name, path, make_root=make_root) as pkg:
        pkg.version = version
        if 'description' in SETUPTOOLS_ARGS:
            if len(SETUPTOOLS_ARGS['description']) < 150:
                pkg.nice_name = SETUPTOOLS_ARGS['description']
            else:
                pkg.nice_name = SETUPTOOLS_ARGS['description'][:147] + '...'

        if 'long_description' in SETUPTOOLS_ARGS:
            pkg.description = SETUPTOOLS_ARGS['long_description']

        author_parts = []
        if 'author' in SETUPTOOLS_ARGS:
            author_parts.append(SETUPTOOLS_ARGS['author'])
        if 'author_email' in SETUPTOOLS_ARGS:
            author_parts.append(SETUPTOOLS_ARGS['author_email'])
        if len(author_parts) > 0:
            pkg.authors = [' '.join(author_parts)]
        else:
            pkg.authors = []

        if 'install_requires' in SETUPTOOLS_ARGS:
            pkg.requires = [
                parse_setup_requirements(req)
                for req in SETUPTOOLS_ARGS['install_requires']
            ]
        else:
            pkg.requires = []

        if 'setup_requires' in SETUPTOOLS_ARGS:
            pkg.build_requires = [
                parse_setup_requirements(req)
                for req in SETUPTOOLS_ARGS['setup_requires']
            ]

        if 'scripts' in SETUPTOOLS_ARGS:
            pkg.tools = [
                os.path.split(script)[-1]
                for script in SETUPTOOLS_ARGS['scripts']
            ]
        pkg.commands = commands

    return package_name, Version(version)
Esempio n. 25
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # # find executable, determine version
    # if opts and opts.root:
    #     root_path = opts.root
    #     try:
    #         info = GetFileVersionInfo(os.path.join(root_path, 'bin', 'deadlinecommand.exe'), "\\")
    #         ms = info['FileVersionMS']
    #         ls = info['FileVersionLS']
    #         version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
    #     except:
    #         raise EnvironmentError('Unknown version')
    # else:
    installed_versions = []
    thinkbox_root = r'C:\Program Files\Thinkbox'
    app_folder_prefix = 'Deadline7'  # previous value was 'Deadline' with no number
    for app_folder in os.listdir(thinkbox_root):
        if app_folder.startswith(app_folder_prefix):
            app_exe = os.path.join(thinkbox_root, app_folder, 'bin', 'deadlinecommand.exe')
            if os.path.exists(app_exe):
                try:
                    info = GetFileVersionInfo(app_exe, "\\")
                    ms = info['FileVersionMS']
                    ls = info['FileVersionLS']
                    version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
                except:
                    raise EnvironmentError('Unknown version')
                installed_versions.append(
                    (app_folder, version)
                )

    if len(installed_versions) < 1:
        raise EnvironmentError(
            'Unable to find any installed version of Deadline under "{}"'.format(
                thinkbox_root
            )
        )

    app_folder, version = sorted(installed_versions, key=lambda v: v[1])[-1]

    root_path = os.path.join(thinkbox_root, app_folder, 'bin')

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(
            os.path.join(resources_path, 'deadline_monitor_icon.png'),
            os.path.join(path, 'deadline_monitor_icon.png')
        )

    make_root_partial = functools.partial(make_root, resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("deadline", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["monitor"]
        pkg.description = 'Render Manager'
        pkg.authors = ['Thinkbox']
        pkg.requires = []
        pkg.nice_name = 'Deadline'

        pkg.tools_info = {
            'monitor': {
                'command': ['deadlinemonitor.exe'],
                'nice_name': 'Monitor',
                'priority': 89,
                'icon': '{root}/deadline_monitor_icon.png',
                'launch_in_prompt': False
            }
        }
        pkg.commands = win_commands(root_path, version.major)
        pkg.variants = [system.variant]

    return "deadline", version
Esempio n. 26
0
def bind(name, path, import_name=None, version_range=None, version=None,
         requires=None, pure_python=None, tools=None, extra_module_names=[],
         extra_attrs={}):
    import_name = import_name or name

    if version is None:
        version = get_version_in_python(
            name,
            ["import %s" % import_name,
             "print %s.__version__" % import_name])

    check_version(version, version_range)

    py_major_minor = '.'.join(str(x) for x in sys.version_info[:2])
    py_req = "python-%s" % py_major_minor
    found_tools = {}

    if pure_python is None:
        raise NotImplementedError  # detect
    elif pure_python:
        variant = [py_req]
    else:
        variant = system.variant + [py_req]

    for tool in (tools or []):
        try:
            src = find_exe(tool)
            found_tools[tool] = src
            log("found tool '%s': %s" % (tool, src))
        except RezBindError as e:
            print_warning(str(e))

    def make_root(variant, root):
        pypath = make_dirs(root, "python")
        copy_module(import_name, pypath)

        if found_tools:
            binpath = make_dirs(root, "bin")
            for tool, src in sorted(found_tools.items()):
                dest = os.path.join(binpath, tool)
                shutil.copy2(src, dest)

        for name_ in extra_module_names:
            copy_module(name_, pypath)

    with make_package(name, path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.variants = [variant]

        if requires:
            pkg.requires = requires

        if found_tools:
            pkg.tools = list(found_tools)
            pkg.commands = commands_with_bin
        else:
            pkg.commands = commands

        for key, value in extra_attrs.iteritems():
            pkg[key] = value

    return pkg.installed_variants
Esempio n. 27
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # find executable, determine version
    if opts and opts.root:
        bin_path = opts.root
    else:
        installed_versions = []
        autodesk_root = r'C:\Program Files\Autodesk'
        for app_folder in os.listdir(autodesk_root):
            if app_folder.startswith('Mudbox'):
                installed_versions.append(
                    (app_folder, Version(app_folder.replace('Mudbox', '').strip()))
                )
        if len(installed_versions) < 1:
            raise EnvironmentError(
                'Unable to find any installed version of Mudbox under "{}"'.format(
                    autodesk_root
                )
            )

        app_folder, version = sorted(installed_versions, key=lambda v: v[1])[-1]

        bin_path = os.path.join(autodesk_root, app_folder)

    from win32api import GetFileVersionInfo, LOWORD, HIWORD
    try:
        info = GetFileVersionInfo(os.path.join(bin_path, 'mudbox.exe'), "\\")
        ms = info['FileVersionMS']
        ls = info['FileVersionLS']
        version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
    except:
        raise EnvironmentError('Unknown version')

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(
            os.path.join(resources_path, 'mudbox_icon.png'),
            os.path.join(path, 'mudbox_icon.png')
        )

    make_root_partial = functools.partial(make_root, resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("mudbox", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["mudbox"]
        pkg.description = 'Scupting application'
        pkg.authors = ['Autodesk']
        pkg.requires = ['roaming_user']
        pkg.nice_name = 'Mudbox'

        pkg.tools_info = {
            'mudbox': {
                'command': ['mudbox'],
                'nice_name': 'Mudbox',
                'priority': 89,
                'icon': '{root}/mudbox_icon.png',
                'launch_in_prompt': False
            }
        }
        pkg.commands = win_commands(bin_path)
        pkg.variants = [system.variant]

    return "mudbox", version
Esempio n. 28
0
def bind(path, version_range=None, opts=None, parser=None):
    if opts and opts.pypkg:
        py_package_name = opts.pypkg
        if opts.name:
            package_name = opts.name
        else:
            package_name = py_package_name.replace('-', '_')
    else:
        raise ValueError('A package name needs to be specified')

    # connect to PyPi and get the released package versions
    pypi_client = xmlrpclib.ServerProxy('https://pypi.python.org/pypi')
    package_versions = sorted(pypi_client.package_releases(py_package_name), key=lambda v: Version(v))
    if len(package_versions) < 1:
        raise ValueError('Invalid package name: {}'.format(package_name))

    # get the version
    if opts.version:
        version = next((v for v in package_versions if v == opts.version), None)
        if version is None:
            raise ValueError('Invalid version: {}, valid versions: {}'.format(opts.version, package_versions))
    else:
        version = package_versions[-1]

    check_version(Version(version), version_range)

    # get the source distribution, this could be better and try to install wheels as well
    release_info = next(
        (r for r in pypi_client.release_urls(py_package_name, version) if r['packagetype'] == 'sdist'),
        None
    )

    if release_info is None:
        raise ValueError(
            'No source distribution (we don\'t support wheels at the moment) for {} {}'.format(py_package_name, version)
        )

    # clear the temp dir if it exists
    tmp_dir = os.path.join(platform_.tmpdir, package_name)
    if os.path.exists(tmp_dir):
        shutil.rmtree(tmp_dir)
    os.mkdir(tmp_dir)

    # download file to tmp dir
    handle = urllib2.urlopen(release_info['url'])
    src_archive = os.path.join(tmp_dir, release_info['filename'])
    with open(src_archive, 'wb') as src_archive_fp:
        src_archive_fp.write(handle.read())

    # decompress the file
    package_dir = None
    if release_info['filename'].endswith('.zip'):
        zfile = zipfile.ZipFile(src_archive, 'r')
        zfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.zip', '')
    elif release_info['filename'].endswith('.tar.gz'):
        tfile = tarfile.open(src_archive, 'r:gz')
        tfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.tar.gz', '')
    elif release_info['filename'].endswith('.tgz'):
        tfile = tarfile.open(src_archive, 'r:gz')
        tfile.extractall(tmp_dir)
        package_dir = src_archive.replace('.tgz', '')
    else:
        raise ValueError('Package file downloaded cannot be decompressed: {}'.format(src_archive))

    setup_file = os.path.join(package_dir, 'setup.py')

    if not os.path.exists(setup_file):
        raise RuntimeError(
            'Package does not contain a "setup.py" file in the root of the archive: {}'.format(py_package_name)
        )

    def setup_dummy(*args, **kwargs):
        global SETUPTOOLS_ARGS
        SETUPTOOLS_ARGS = {}

        if 'scripts' in kwargs:
            SETUPTOOLS_ARGS['scripts'] = kwargs['scripts']

        if 'description' in kwargs:
            SETUPTOOLS_ARGS['description'] = kwargs['description']

        if 'long_description' in kwargs:
            SETUPTOOLS_ARGS['long_description'] = kwargs['long_description']

        if 'author' in kwargs:
            SETUPTOOLS_ARGS['author'] = kwargs['author']

        if 'author_email' in kwargs:
            SETUPTOOLS_ARGS['author_email'] = kwargs['author_email']

        if 'install_requires' in kwargs:
            SETUPTOOLS_ARGS['install_requires'] = kwargs['install_requires']

        if 'setup_requires' in kwargs:
            SETUPTOOLS_ARGS['setup_requires'] = kwargs['setup_requires']

        if 'version' in kwargs:
            SETUPTOOLS_ARGS['version'] = kwargs['version']
        else:
            raise RuntimeError('A package must have a version.')

    # monkey patch the setup function so we can steal the arguments passed to it
    setuptools.setup = setup_dummy
    distutils.core.setup = setup_dummy

    cwd = os.getcwd()
    os.chdir(package_dir)
    sys.path.extend([package_dir])
    old_args = sys.argv[:]
    try:
        _ = imp.load_source('{}_setup'.format(package_name), setup_file)
    except Exception as e:
        import traceback
        traceback.print_exc()
        raise e
    sys.argv = old_args[:]
    os.chdir(cwd)
    sys.path.remove(package_dir)

    def parse_setup_requirements(req_str):
        '''
        e.g. "arrow >= 0.4.4, < 1" -> 'arrow-0.4.4+<1
        :param req_str: requirement in the setuptools format
        :return: requirement in the rez format
        '''

        if not any((op in req_str for op in ['<', '>', '='])):
            # even simpler "arrow" req
            return req_str.replace('-', '_').strip()
        if '==' in req_str:
            # just a simple "arrow == 0.4.4" req
            req_pgk_name, req_version = req_str.split('==')
            return '{}-{}'.format(req_pgk_name.replace('-', '_').strip(), req_version.strip())

        complex_req_match = re.match(r'^(?P<pkg_name>[a-zA-Z0-9\.-_]+) *(?P<reqs>[\.,<>=0-9) ]+)$', req_str.strip())
        if not complex_req_match:
            raise RuntimeError('Unable to parse requirement; {}'.format(req_str))

        req_pgk_name = complex_req_match.group('pkg_name')
        req_pgk_req_str = complex_req_match.group('reqs')
        requirements = map(lambda s: s.strip(), req_pgk_req_str.split(','))

        versions_rewrite = []
        for sub_requirement_str in requirements:
            sub_requirement_match = re.match(r'([<>=]+?) ?([0-9a-zA-Z\.]+)', sub_requirement_str)
            operation = sub_requirement_match.group(1).strip()
            req_version = sub_requirement_match.group(2).strip()
            if operation == '>=':
                versions_rewrite.insert(0, '{}+'.format(req_version))
            elif operation == '<':
                versions_rewrite.append('<{}'.format(req_version))
            else:
                raise RuntimeError('Unable to translate operation: "{}" in requirement: {}'.format(operation, req_str))
        return '{}-{}'.format(req_pgk_name.replace('-', '_'), ''.join(versions_rewrite))

    def make_root(variant, root):
        binpath = make_dirs(root, "bin")
        pythonpath = make_dirs(root, "python")
        headerpath = make_dirs(root, "include")
        install_cmd = ' '.join([
            'pip', 'install',
            '--no-deps', '--ignore-installed', '--verbose', '--verbose', '--verbose',
            '--global-option="--verbose"',
            '--install-option="--install-headers={}"'.format(headerpath),
            '--install-option="--install-purelib={}"'.format(pythonpath),
            '--install-option="--install-platlib={}"'.format(pythonpath),
            '--install-option="--install-scripts={}"'.format(binpath),
            py_package_name
        ])
        try:
            subprocess.check_output(
                install_cmd,
                cwd=package_dir
            )
        except subprocess.CalledProcessError as _:
            raise RuntimeError('Bind failed to install python package with command: {}'.format(install_cmd))

    with make_package(package_name, path, make_root=make_root) as pkg:
        pkg.version = version
        if 'description' in SETUPTOOLS_ARGS:
            if len(SETUPTOOLS_ARGS['description']) < 150:
                pkg.nice_name = SETUPTOOLS_ARGS['description']
            else:
                pkg.nice_name = SETUPTOOLS_ARGS['description'][:147] + '...'

        if 'long_description' in SETUPTOOLS_ARGS:
            pkg.description = SETUPTOOLS_ARGS['long_description']

        author_parts = []
        if 'author' in SETUPTOOLS_ARGS:
            author_parts.append(SETUPTOOLS_ARGS['author'])
        if 'author_email' in SETUPTOOLS_ARGS:
            author_parts.append(SETUPTOOLS_ARGS['author_email'])
        if len(author_parts) > 0:
            pkg.authors = [' '.join(author_parts)]
        else:
            pkg.authors = []

        if 'install_requires' in SETUPTOOLS_ARGS:
            pkg.requires = [parse_setup_requirements(req) for req in SETUPTOOLS_ARGS['install_requires']]
        else:
            pkg.requires = []

        if 'setup_requires' in SETUPTOOLS_ARGS:
            pkg.build_requires = [parse_setup_requirements(req) for req in SETUPTOOLS_ARGS['setup_requires']]

        if 'scripts' in SETUPTOOLS_ARGS:
            pkg.tools = [os.path.split(script)[-1] for script in SETUPTOOLS_ARGS['scripts']]
        pkg.commands = commands

    return package_name, Version(version)
Esempio n. 29
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # find executable, determine version
    if opts and opts.root:
        bin_path = opts.root
        try:
            info = GetFileVersionInfo(os.path.join(bin_path, 'Photoshop.exe'),
                                      "\\")
            ms = info['FileVersionMS']
            ls = info['FileVersionLS']
            version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms),
                                                   HIWORD(ls), LOWORD(ls)))
        except:
            raise EnvironmentError('Unknown version')
    else:
        installed_versions = []
        adobe_root = r'C:\Program Files\Adobe'
        app_folder_prefix = 'Adobe Photoshop'
        for app_folder in os.listdir(adobe_root):
            if app_folder.startswith(app_folder_prefix):
                app_exe = os.path.join(adobe_root, app_folder, 'Photoshop.exe')
                if os.path.exists(app_exe):
                    try:
                        info = GetFileVersionInfo(app_exe, "\\")
                        ms = info['FileVersionMS']
                        ls = info['FileVersionLS']
                        version = Version('{}.{}.{}.{}'.format(
                            HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
                    except:
                        raise EnvironmentError('Unknown version')
                    installed_versions.append((app_folder, version))

        if len(installed_versions) < 1:
            raise EnvironmentError(
                'Unable to find any installed version of 3ds Max under "{}"'.
                format(adobe_root))

        app_folder, version = sorted(installed_versions,
                                     key=lambda v: v[1])[-1]

        bin_path = os.path.join(adobe_root, app_folder)

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(os.path.join(resources_path, 'Photoshop_icon.png'),
                    os.path.join(path, 'Photoshop_icon.png'))

    make_root_partial = functools.partial(
        make_root,
        resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("photoshop", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["photoshop"]
        pkg.description = 'Painting Application'
        pkg.authors = ['Adobe']
        pkg.requires = []
        pkg.nice_name = 'Photoshop'

        pkg.tools_info = {
            'photoshop': {
                'command': [
                    'start', 'Photoshop', '/D', '%REZ_PHOTOSHOP_ROOT%',
                    '/wait', '/B', 'Photoshop.exe'
                ],
                'nice_name':
                'Photoshop',
                'priority':
                89,
                'icon':
                '{root}/Photoshop_icon.png',
                'launch_in_prompt':
                False
            }
        }
        pkg.commands = win_commands(bin_path)
        pkg.variants = [system.variant]

    return "photoshop", version
Esempio n. 30
0
def bind(name,
         path,
         import_name=None,
         version_range=None,
         version=None,
         requires=None,
         pure_python=None,
         tools=None,
         extra_module_names=[],
         extra_attrs={}):
    import_name = import_name or name

    if version is None:
        version = get_version_in_python(
            name,
            ["import %s" % import_name,
             "print %s.__version__" % import_name])

    check_version(version, version_range)

    py_major_minor = '.'.join(str(x) for x in sys.version_info[:2])
    py_req = "python-%s" % py_major_minor
    found_tools = {}

    if pure_python is None:
        raise NotImplementedError  # detect
    elif pure_python:
        variant = [py_req]
    else:
        variant = system.variant + [py_req]

    for tool in (tools or []):
        try:
            src = find_exe(tool)
            found_tools[tool] = src
            log("found tool '%s': %s" % (tool, src))
        except RezBindError as e:
            print_warning(str(e))

    def make_root(variant, root):
        pypath = make_dirs(root, "python")
        copy_module(import_name, pypath)

        if found_tools:
            binpath = make_dirs(root, "bin")
            for tool, src in sorted(found_tools.items()):
                dest = os.path.join(binpath, tool)
                shutil.copy2(src, dest)

        for name_ in extra_module_names:
            copy_module(name_, pypath)

    with make_package(name, path, make_root=make_root) as pkg:
        pkg.version = version
        pkg.variants = [variant]

        if requires:
            pkg.requires = requires

        if found_tools:
            pkg.tools = list(found_tools)
            pkg.commands = commands_with_bin
        else:
            pkg.commands = commands

        for key, value in extra_attrs.iteritems():
            pkg[key] = value

    return pkg.installed_variants
Esempio n. 31
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # # find executable, determine version
    # if opts and opts.root:
    #     root_path = opts.root
    #     try:
    #         info = GetFileVersionInfo(os.path.join(root_path, 'bin', 'deadlinecommand.exe'), "\\")
    #         ms = info['FileVersionMS']
    #         ls = info['FileVersionLS']
    #         version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
    #     except:
    #         raise EnvironmentError('Unknown version')
    # else:
    installed_versions = []
    thinkbox_root = r'C:\Program Files\Thinkbox'
    app_folder_prefix = 'Deadline7'  # previous value was 'Deadline' with no number
    for app_folder in os.listdir(thinkbox_root):
        if app_folder.startswith(app_folder_prefix):
            app_exe = os.path.join(thinkbox_root, app_folder, 'bin',
                                   'deadlinecommand.exe')
            if os.path.exists(app_exe):
                try:
                    info = GetFileVersionInfo(app_exe, "\\")
                    ms = info['FileVersionMS']
                    ls = info['FileVersionLS']
                    version = Version('{}.{}.{}.{}'.format(
                        HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
                except:
                    raise EnvironmentError('Unknown version')
                installed_versions.append((app_folder, version))

    if len(installed_versions) < 1:
        raise EnvironmentError(
            'Unable to find any installed version of Deadline under "{}"'.
            format(thinkbox_root))

    app_folder, version = sorted(installed_versions, key=lambda v: v[1])[-1]

    root_path = os.path.join(thinkbox_root, app_folder, 'bin')

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(os.path.join(resources_path, 'deadline_monitor_icon.png'),
                    os.path.join(path, 'deadline_monitor_icon.png'))

    make_root_partial = functools.partial(
        make_root,
        resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("deadline", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["monitor"]
        pkg.description = 'Render Manager'
        pkg.authors = ['Thinkbox']
        pkg.requires = []
        pkg.nice_name = 'Deadline'

        pkg.tools_info = {
            'monitor': {
                'command': ['deadlinemonitor.exe'],
                'nice_name': 'Monitor',
                'priority': 89,
                'icon': '{root}/deadline_monitor_icon.png',
                'launch_in_prompt': False
            }
        }
        pkg.commands = win_commands(root_path, version.major)
        pkg.variants = [system.variant]

    return "deadline", version
Esempio n. 32
0
def bind(path, version_range=None, opts=None, parser=None):
    if platform_.name != 'windows':
        raise EnvironmentError('Only binds on windows at the moment')

    # find executable, determine version
    if opts and opts.root:
        bin_path = opts.root
        try:
            info = GetFileVersionInfo(os.path.join(bin_path, 'Support Files', 'AfterFX.exe'), "\\")
            ms = info['FileVersionMS']
            ls = info['FileVersionLS']
            version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
        except:
            raise EnvironmentError('Unknown version')
    else:
        installed_versions = []
        adobe_root = r'C:\Program Files\Adobe'
        app_folder_prefix = 'Adobe After Effects'
        for app_folder in os.listdir(adobe_root):
            if app_folder.startswith(app_folder_prefix):
                app_exe = os.path.join(adobe_root, app_folder, 'Support Files', 'AfterFX.exe')
                if os.path.exists(app_exe):
                    try:
                        info = GetFileVersionInfo(app_exe, "\\")
                        ms = info['FileVersionMS']
                        ls = info['FileVersionLS']
                        version = Version('{}.{}.{}.{}'.format(HIWORD(ms), LOWORD(ms), HIWORD(ls), LOWORD(ls)))
                    except:
                        raise EnvironmentError('Unknown version')
                    installed_versions.append(
                        (app_folder, version)
                    )

        if len(installed_versions) < 1:
            raise EnvironmentError(
                'Unable to find any installed version of  After Effects under "{}"'.format(
                    adobe_root
                )
            )

        app_folder, version = sorted(installed_versions, key=lambda v: v[1])[-1]

        bin_path = os.path.join(adobe_root, app_folder)

    check_version(version, version_range)

    def make_root(resources_path, variant, path):
        import shutil
        shutil.copy(
            os.path.join(resources_path, 'aftereffects_icon.png'),
            os.path.join(path, 'aftereffects_icon.png')
        )

    make_root_partial = functools.partial(make_root, resource_filename(Requirement.parse('rez'), "rez/bind/resources"))

    with make_package("aftereffects", path, make_root=make_root_partial) as pkg:
        pkg.version = version
        pkg.tools = ["aftereffects"]
        pkg.description = 'Animation and effects application'
        pkg.authors = ['Adobe']
        pkg.requires = []
        pkg.nice_name = 'After Effects'

        pkg.tools_info = {
            'aftereffects': {
                'command': ['start', '^"AfterEffects^"', '/D', '%REZ_PHOTOSHOP_ROOT%', '/wait', '/B', 'AfterFX.exe'],
                'nice_name': 'AfterEffects',
                'priority': 89,
                'icon': '{root}/aftereffects_icon.png',
                'launch_in_prompt': False
            }
        }
        pkg.commands = win_commands(bin_path)
        pkg.variants = [system.variant]

    return "aftereffects", version