Beispiel #1
0
def setup_args(config_path=Path("pyproject.toml")):
    cfg = config.read_flit_config(config_path)
    module = common.Module(cfg.module, config_path.parent)
    metadata = common.make_metadata(module, cfg)
    kwargs = {}
    for st_field, metadata_field in field_map.items():
        val = getattr(metadata, metadata_field, None)
        if val is not None:
            kwargs[st_field] = val
        else:
            msg = f"{metadata_field} not found in {dir(metadata)}"
            assert metadata_field in {"license"}, msg
    kwargs["packages"] = setuptools.find_packages(
        include=[metadata.name + "*"])
    if metadata.requires_dist:
        kwargs["install_requires"] = [
            req for req in metadata.requires_dist if "extra ==" not in req
        ]
    if cfg.reqs_by_extra:
        kwargs["extras_require"] = cfg.reqs_by_extra
    scripts = cfg.entrypoints.get("console_scripts")
    if scripts is not None:
        kwargs["entry_points"] = dict(
            console_scipts=[" = ".join(ep) for ep in scripts.items()])
    kwargs["include_package_data"] = True
    kwargs["package_data"] = {
        module.name:
        [re.escape(f[len(module.name) + 1:]) for f in find_files(module.path)]
    }
    return kwargs
Beispiel #2
0
    def __init__(self,
                 ini_path,
                 user=None,
                 python=sys.executable,
                 symlink=False,
                 deps='all',
                 extras=(),
                 pth=False):
        self.ini_path = ini_path
        self.python = python
        self.symlink = symlink
        self.pth = pth
        self.deps = deps
        self.extras = extras
        if deps != 'none' and os.environ.get('FLIT_NO_NETWORK', ''):
            self.deps = 'none'
            log.warning(
                'Not installing dependencies, because FLIT_NO_NETWORK is set')
        if deps == 'none' and extras:
            raise DependencyError()

        self.ini_info = inifile.read_flit_config(ini_path)
        self.module = common.Module(self.ini_info.module, str(ini_path.parent))

        if (hasattr(os, 'getuid') and (os.getuid() == 0)
                and (not os.environ.get('FLIT_ROOT_INSTALL'))):
            raise RootInstallError

        if user is None:
            self.user = self._auto_user(python)
        else:
            self.user = user
        log.debug('User install? %s', self.user)

        self.installed_files = []