Set up an overrides dict for WheelFile.install that installs the contents
    of a wheel into its own base in the pex dependencies cache.
167389
def _get_installer_paths(self, base):
    
    return {
      'purelib': base,
      'headers': os.path.join(base, 'headers'),
      'scripts': os.path.join(base, 'bin'),
      'platlib': base,
      'data': base
    }
381128
def make_abstract_dist(req):
    # type: (InstallRequirement) -> DistAbstraction
    
    if req.editable:
        return IsSDist(req)
    elif req.link and req.link.is_wheel:
        return IsWheel(req)
    else:
        return IsSDist(req)
1226197
def _resolve_plugins(plugins):
    
    import os
    from sys import platform

    # Location of __init__.py and the embedded library directory
    basedir = os.path.dirname(__file__)

    if platform in ('win32', 'cygwin'):
        paths_sep = ';'
        ext = '.dll'
        libdir = basedir
    elif platform in ('linux', 'linux2'):
        paths_sep = ':'
        ext = '.so'
        libdir = os.path.join(basedir, '.libs')
    elif platform == 'darwin':
        paths_sep = ':'
        ext = '.dylib'
        libdir = os.path.join(basedir, '.dylibs')
    else:
        # Unknown platform, there are probably no embedded plugins.
        return plugins

    if not os.path.isdir(libdir):
        # No embedded library directory, probably not a wheel installation.
        return plugins

    resolved = []
    for plugin in plugins.split(paths_sep):
        if '/' in plugin or '\\' in plugin:
            # Path specified, leave unchanged
            resolved.append(plugin)
            continue

        # See if the plugin can be found in the wheel's
        # embedded library directory.
        # The user might not have supplied a file extension, so try both.
        good = None
        for file in [plugin, plugin + ext]:
            fpath = os.path.join(libdir, file)
            if os.path.isfile(fpath):
                good = fpath
                break

        if good is not None:
            resolved.append(good)
        else:
            resolved.append(plugin)

    return paths_sep.join(resolved)
1217033
def setup(self, glbls):
        
        if not self.pluginPath() in sys.path:
            log.debug(self.pluginPath())
            sys.path.append(self.pluginPath())
        
        glbls['find'] = self.find
        glbls['listdir'] = self.listdir
        glbls['load'] = self.load
        glbls['read'] = self.read
        glbls['exists'] = self.exists
        glbls['setdefault'] = self.setDefault
        glbls['basePath'] = self.basePath
        glbls['setBasePath'] = self.setBasePath
        glbls['walk'] = self.walk
        glbls['isdir'] = self.isdir
        glbls['isfile'] = self.isfile
        glbls['init'] = self.init
        
        # setup the build system
        if 'python' in sys.executable and not self.useFilepath():
            self.build()
147866
def install(self):
        
        super(SystemD, self).install()

        self.deploy_service_file(self.svc_file_path, self.svc_file_dest)
        self.deploy_service_file(self.env_file_path, self.env_file_dest)
        sh.systemctl.enable(self.name)
        sh.systemctl('daemon-reload')
1144178
def load_dependency(self, module_name, dependencies, recursive, greedy, ismapping = False):
        """"""
        key = module_name.lower()
        if key not in self.modules:
            if key == "fortpy":
                #Manually specify the correct path to the fortpy.f90 that shipped with
                #the distribution
                from fortpy.utility import get_fortpy_templates_dir
                from os import path
                fpy_path = path.join(get_fortpy_templates_dir(), "fortpy.f90")
                self.parse(fpy_path, False, False)
                return
            
            fkey = key + ".f90"
            if fkey in self._pathfiles:
                self.parse(self._pathfiles[fkey], dependencies, recursive)
            elif greedy:
                #The default naming doesn't match for this module
                #we will load all modules until we find the right
                #one
                self._load_greedy(key, dependencies, recursive)
            elif key in self.mappings and self.mappings[key] in self._pathfiles:
                #See if they have a mapping specified to a code file for this module name.
                if self.verbose:
                    msg.info("MAPPING: using {} as the file".format(self.mappings[key]) + 
                             " name for module {}".format(key))
                self.parse(self._pathfiles[self.mappings[key]], dependencies, recursive)
            elif key not in ["mkl_vsl_type", "mkl_vsl", "iso_c_binding"]:
                #The parsing can't continue without the necessary dependency modules.
                msg.err(("could not find module {}. Enable greedy search or"
                       " add a module filename mapping.".format(key)))
                if self.austere:
                    exit(1)
912092
def _load_with_overrides(base) -> Dict[str, str]:
    
    should_write = False
    overrides = _get_environ_overrides()
    try:
        index = json.load((base/_CONFIG_FILENAME).open())
    except (OSError, json.JSONDecodeError) as e:
        sys.stderr.write("Error loading config from {}: {}\nRewriting...\n"
                         .format(str(base), e))
        should_write = True
        index = generate_config_index(overrides)

    for key in CONFIG_ELEMENTS:
        if key.name not in index:
            sys.stderr.write(
                f"New config index key {key.name}={key.default}"
                "\nRewriting...\n")
            if key.kind in (ConfigElementType.DIR, ConfigElementType.FILE):
                index[key.name] = base/key.default
            else:
                index[key.name] = key.default
            should_write = True

    if should_write:
        try:
            write_config(index, path=base)
        except Exception as e:
            sys.stderr.write(
                "Error writing config to {}: {}\nProceeding memory-only\n"
                .format(str(base), e))
    index.update(overrides)
    return index
256352
def installedDependents(self, target):
    
    for dc in self.store.query(_DependencyConnector,
                               _DependencyConnector.target == target):
        depends = dependentsOf(dc.installee.__class__)
        if self.__class__ in depends:
            yield dc.installee
1247357
def load():
    
    if 'Windows' == platform.system():
        # Possible scenarios here
        #   1. Run from source, DLLs are in pyzbar directory
        #       cdll.LoadLibrary() imports DLLs in repo root directory
        #   2. Wheel install into CPython installation
        #       cdll.LoadLibrary() imports DLLs in package directory
        #   3. Wheel install into virtualenv
        #       cdll.LoadLibrary() imports DLLs in package directory
        #   4. Frozen
        #       cdll.LoadLibrary() imports DLLs alongside executable
        fname, dependencies = _windows_fnames()

        def load_objects(directory):
            # Load dependencies before loading libzbar dll
            deps = [
                cdll.LoadLibrary(str(directory.joinpath(dep)))
                for dep in dependencies
            ]
            libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
            return deps, libzbar

        try:
            dependencies, libzbar = load_objects(Path(''))
        except OSError:
            dependencies, libzbar = load_objects(Path(__file__).parent)
    else:
        # Assume a shared library on the path
        path = find_library('zbar')
        if not path:
            raise ImportError('Unable to find zbar shared library')
        libzbar = cdll.LoadLibrary(path)
        dependencies = []

    return libzbar, dependencies
939002
def setup(self, app):
        
        self.app = app
        for name, ptype in self.dependencies.items():
            if name not in app.ps or not isinstance(app.ps[name], ptype):
                raise PluginException(
                    'Plugin `%s` requires for plugin `%s` to be installed to the application.' % (
                        self.name, ptype))

        for oname, dvalue in self.defaults.items():
            aname = ('%s_%s' % (self.name, oname)).upper()
            self.cfg.setdefault(oname, app.cfg.get(aname, dvalue))
            app.cfg.setdefault(aname, self.cfg[oname])
595303
def register_by_twine(self):
        
        check_call_no_output([
            '{}'.format(self.python),
            'setup.py',
            'bdist_wheel',
        ])

        # at this point there should be only one file in the 'dist' folder
        filename = self.get_package_filename()
        check_call_no_output([
            'twine',
            'register',
            filename,
        ])
124381
def setupTxns(self, key, force: bool = False):
        
        import data
        dataDir = os.path.dirname(data.__file__)

        # TODO: Need to get "test" and "live" from ENVS property in config.py
        # but that gives error due to some dependency issue
        allEnvs = {
            "local": Environment("pool_transactions_local",
                                 "domain_transactions_local"),
            "test": Environment("pool_transactions_sandbox",
                                "domain_transactions_sandbox"),
            "live": Environment("pool_transactions_live",
                                "domain_transactions_live")
        }
        for env in allEnvs.values():
            fileName = getattr(env, key, None)
            if not fileName:
                continue
            sourceFilePath = os.path.join(dataDir, fileName)
            if not os.path.exists(sourceFilePath):
                continue
            destFilePath = os.path.join(
                self.base_dir, genesis_txn_file(fileName))
            if os.path.exists(destFilePath) and not force:
                continue
            copyfile(sourceFilePath, destFilePath)

        return self
761474
protected function installFromFile()
    {
        if (!file_exists($path = base_path('components.json'))) {
            $this->error("File 'components.json' does not exist in your project root.");

            return;
        }

        $components = Json::make($path);

        $dependencies = $components->get('require', []);

        foreach ($dependencies as $component) {
            $component = collect($component);

            $this->install(
                $component->get('name'),
                $component->get('version'),
                $component->get('type')
            );
        }
    }
923157
def ci_macos():
    
    run_command("brew install $PYTHON pipenv || echo \"Installed PipEnv\"")
    command_string = "sudo -H $PIP install "
    for element in DEPENDENCIES + REQUIREMENTS + ["-U"]:
        command_string += element + " "
    run_command(command_string)
    # Build a wheel
    run_command("sudo -H $PYTHON setup.py bdist_wheel")
    assert check_wheel_existence()
    exit(0)
847690
def install(client, force):
    """"""
    import pkg_resources
    from git.index.fun import hook_path as get_hook_path

    for hook in HOOKS:
        hook_path = Path(get_hook_path(hook, client.repo.git_dir))
        if hook_path.exists():
            if not force:
                click.echo(
                    'Hook already exists. Skipping {0}'.format(str(hook_path)),
                    err=True
                )
                continue
            else:
                hook_path.unlink()

        # Make sure the hooks directory exists.
        hook_path.parent.mkdir(parents=True, exist_ok=True)

        Path(hook_path).write_bytes(
            pkg_resources.resource_string(
                'renku.data', '{hook}.sh'.format(hook=hook)
            )
        )
        hook_path.chmod(hook_path.stat().st_mode | stat.S_IEXEC)
470403
def publish(build):
    
    build.packages.install("wheel")
    build.packages.install("twine")
    build.executables.run([
        "python", "setup.py",
        "sdist", "bdist_wheel", "--universal", "--release"
    ])
    build.executables.run([
        "twine", "upload", "dist/*"
    ])
1248288
def make_wheel_filename_generic(wheel):
    
    name, version, python, abi, platform = wheel.split("-")

    # our binary handles multiple abi/versions of python
    python, abi = "py2.py3", "none"

    # hack, lets pretend to be manylinux1 so we can do a binary distribution
    if platform == "linux_x86_64.whl":
        platform = "manylinux1_x86_64.whl"
    elif platform == "linux_i686.whl":
        platform = "manylinux1_i686.whl"

    return "-".join((name, version, python, abi, platform))