How to use the flit.install.Installer function in flit

To help you get started, we’ve selected a few flit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github takluyver / flit / tests / test_install.py View on Github external
def test_install_module(self):
        Installer.from_ini_path(samples_dir / 'module1_toml' / 'pyproject.toml').install_directly()
        assert_isfile(self.tmpdir / 'site-packages' / 'module1.py')
        assert_isdir(self.tmpdir / 'site-packages' / 'module1-0.1.dist-info')
        self._assert_direct_url(
            samples_dir / 'module1_toml', 'module1', '0.1', expected_editable=False
        )
github takluyver / flit / tests / test_install.py View on Github external
"print(True)\n"   # site.ENABLE_USER_SITE
                   "print({purelib!r})"  # sysconfig.get_path('purelib')
                  ).format(python=sys.executable,
                           purelib=str(self.tmpdir / 'site-packages2'))

        # Called by Installer._get_dirs() :
        script2 = ("#!{python}\n"
                   "import json, sys\n"
                   "json.dump({{'purelib': {purelib!r}, 'scripts': {scripts!r} }}, "
                   "sys.stdout)"
                  ).format(python=sys.executable,
                           purelib=str(self.tmpdir / 'site-packages2'),
                           scripts=str(self.tmpdir / 'scripts2'))

        with MockCommand('mock_python', content=script1):
            ins = Installer.from_ini_path(samples_dir / 'package1' / 'pyproject.toml', python='mock_python',
                      symlink=True)
        with MockCommand('mock_python', content=script2):
            ins.install()

        assert_islink(self.tmpdir / 'site-packages2' / 'package1',
                      to=samples_dir / 'package1' / 'package1')
        assert_isfile(self.tmpdir / 'scripts2' / 'pkg_script')
        with (self.tmpdir / 'scripts2' / 'pkg_script').open() as f:
            assert f.readline().strip() == "#!mock_python"
github takluyver / flit / bootstrap_dev.py View on Github external
core_config.metadata = build_thyself.metadata_dict
core_config.reqs_by_extra['.none'] = build_thyself.metadata.requires_dist

install_kwargs = {'symlink': True}
if os.name == 'nt':
    # Use .pth files instead of symlinking on Windows
    install_kwargs = {'symlink': False, 'pth': True}

# Install flit_core
Installer(
    my_dir / 'flit_core', core_config, user=args.user, **install_kwargs
).install()
print("Linked flit_core into site-packages.")

# Install flit
Installer.from_ini_path(
    my_dir / 'pyproject.toml', user=args.user, **install_kwargs
).install()
print("Linked flit into site-packages.")
github takluyver / flit / bootstrap_dev.py View on Github external
logging.basicConfig(level=logging.INFO)

# Construct config for flit_core
core_config = LoadedConfig()
core_config.module = 'flit_core'
core_config.metadata = build_thyself.metadata_dict
core_config.reqs_by_extra['.none'] = build_thyself.metadata.requires_dist

install_kwargs = {'symlink': True}
if os.name == 'nt':
    # Use .pth files instead of symlinking on Windows
    install_kwargs = {'symlink': False, 'pth': True}

# Install flit_core
Installer(
    my_dir / 'flit_core', core_config, user=args.user, **install_kwargs
).install()
print("Linked flit_core into site-packages.")

# Install flit
Installer.from_ini_path(
    my_dir / 'pyproject.toml', user=args.user, **install_kwargs
).install()
print("Linked flit into site-packages.")
github jhamrick / plotchecker / setup.py View on Github external
def install_plotchecker(symlink):
    from pathlib import Path
    from flit.install import Installer
    from flit.log import enable_colourful_output
    import mock

    # Hack to make docs build on RTD
    MOCK_MODULES = ['numpy', 'matplotlib', 'matplotlib.pyplot', 'matplotlib.colors', 'matplotlib.markers']
    for mod_name in MOCK_MODULES:
        sys.modules[mod_name] = mock.Mock()

    enable_colourful_output()
    p = Path('flit.ini')
    Installer(p, symlink=symlink, deps='none').install()
github takluyver / flit / flit / install.py View on Github external
def install_reqs_my_python_if_needed(self):
        """Install requirements to this environment if needed.

        We can normally get the module's docstring and version number without
        importing it, but if we do need to import it, we may need to install
        its requirements for the Python where flit is running.
        """
        try:
            common.get_info_from_module(self.module)
        except ImportError:
            if self.deps == 'none':
                raise  # We were asked not to install deps, so bail out.

            log.warning("Installing requirements to Flit's env to import module.")
            user = self.user if (self.python == sys.executable) else None
            i2 = Installer(self.directory, self.ini_info, user=user, deps='production')
            i2.install_requirements()