How to use the pythonfinder.pythonfinder.Finder function in pythonfinder

To help you get started, we’ve selected a few pythonfinder 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 sarugaku / pythonfinder / tests / test_python.py View on Github external
os_path = os.environ["PATH"].split(os.pathsep)
            env_path = next(
                iter(
                    [
                        p
                        for p in os_path
                        if pythonfinder.utils.is_in_path(p, os.environ["VIRTUAL_ENV"])
                    ]
                ),
                None,
            )
            if env_path is not None:
                os_path.remove(env_path)
                os.environ["PATH"] = os.pathsep.join(os_path)
            del os.environ["VIRTUAL_ENV"]
        f = pythonfinder.pythonfinder.Finder(
            global_search=True, system=False, ignore_unsupported=True
        )
        f.rehash()
        assert pythonfinder.environment.get_shim_paths() == []
        assert os.path.join(pyenv_dir, "shims") in os.environ["PATH"]
        assert not f.system_path.finders
        assert os.path.join(pyenv_dir, "shims") in f.system_path.path_order
        python_versions = f.find_all_python_versions()
        anaconda = f.find_python_version("anaconda3-5.3.0")
        assert anaconda is not None, python_versions
        assert "shims" in anaconda.path.as_posix(), [
            f.system_path.path_order,
            f.system_path.pyenv_finder.roots,
        ]
        assert "shims" in f.which("anaconda3-5.3.0").path.as_posix()
github sarugaku / pythonfinder / tests / test_python.py View on Github external
p
                    for p in os_path
                    if pythonfinder.utils.is_in_path(p, os.environ["VIRTUAL_ENV"])
                ),
                None,
            )
            if env_path is not None:
                os_path.remove(env_path)
                os.environ["PATH"] = os.pathsep.join(os_path)
            del os.environ["VIRTUAL_ENV"]
        m.setattr(
            pythonfinder.environment,
            "SHIM_PATHS",
            pythonfinder.environment.get_shim_paths(),
        )
        f = pythonfinder.pythonfinder.Finder(
            global_search=True, system=False, ignore_unsupported=True
        )
        f.rehash()
        # assert "pyenv" in f.system_path.finders
        python_versions = f.find_all_python_versions()
        assert os.environ["PYENV_ROOT"] == os.path.abspath(
            os.path.join(os.curdir, ".pyenv")
        )
        assert os.environ["PYENV_ROOT"] == pythonfinder.environment.PYENV_ROOT
        assert pythonfinder.environment.PYENV_INSTALLED
        assert f.system_path.pyenv_finder is not None
        # assert len(python_versions) == 0
        python_version_paths = list(
            v.path
            for v in python_versions
            if pythonfinder.utils.is_in_path(str(v.path), os.environ["PYENV_ROOT"])