예제 #1
0
파일: python.py 프로젝트: 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
예제 #2
0
파일: gcc.py 프로젝트: zclongpop123/rez
def bind(path, version_range=None, opts=None, parser=None):
    exe_path = getattr(opts, 'exe', None)

    # gcc
    gcc_path = find_exe('gcc', filepath=exe_path)
    gcc_version = extract_version(gcc_path, ['-dumpfullversion', '-dumpversion'])
    log("binding gcc: %s" % gcc_path)

    # g++
    gpp_path = find_exe('g++', filepath=exe_path)
    gpp_version = extract_version(gpp_path, ['-dumpfullversion', '-dumpversion'])
    log("binding g++: %s" % gpp_path)

    if gcc_version != gpp_version:
        raise RezBindError("gcc version different than g++ can not continue")

    # create directories and symlink gcc and g++
    def make_root(variant, root):
        bin_path = make_dirs(root, 'bin')

        gcc_link_path = os.path.join(bin_path, 'gcc')
        platform_.symlink(gcc_path, gcc_link_path)

        gpp_link_path = os.path.join(bin_path, 'g++')
        platform_.symlink(gpp_path, gpp_link_path)

    with make_package('gcc', path, make_root=make_root) as pkg:
        pkg.version = gcc_version
        pkg.tools = ['gcc', 'g++']
        pkg.commands = commands
        pkg.variants = [system.variant]

    return pkg.installed_variants
예제 #3
0
    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.items():
                destpath = os.path.join(pypath, dirname)
                log("Copying builtins from %s to %s..." % (srcpath, destpath))
                shutil.copytree(srcpath, destpath)
예제 #4
0
파일: python.py 프로젝트: LumaPictures/rez
    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)
예제 #5
0
파일: python.py 프로젝트: oktomus/rez3
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
예제 #6
0
파일: python.py 프로젝트: mottosso/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):
        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
예제 #7
0
파일: _pymodule.py 프로젝트: oktomus/rez3
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
예제 #8
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