def _find_vyper_version(file: str) -> str: global _installed_vyper_versions if _installed_vyper_versions is None: _installed_vyper_versions = vvm.get_installed_vyper_versions() _installed_vyper_versions.append(_VYPER_VERSION) pragma_specs = _get_vyper_pragma_spec(file) version = pragma_specs.select(_installed_vyper_versions) if not version: global _available_vyper_versions if _available_vyper_versions is None: _available_vyper_versions = vvm.get_installable_vyper_versions() version = pragma_specs.select(_available_vyper_versions) if not version: raise InvalidVyperException( f"Invalid vyper version pragma: {pragma_specs}") lock = vvm.install.get_process_lock(f"locked${version}") with lock: try: _get_executable(version) except vvm.exceptions.VyperNotInstalled: vvm.install_vyper(version) if version not in _installed_vyper_versions: _installed_vyper_versions.append(version) return version
def pytest_collection(session): global VERSIONS if session.config.getoption("--vyper-versions"): VERSIONS = [ Version(i) for i in session.config.getoption("--vyper-versions").split(",") ] elif session.config.getoption("--no-install"): VERSIONS = vvm.get_installed_vyper_versions() else: try: VERSIONS = vvm.get_installable_vyper_versions() except ConnectionError: raise pytest.UsageError( "ConnectionError while attempting to get vyper versions.\n" "Use the --no-install flag to only run tests against already installed versions." ) for version in VERSIONS: vvm.install_vyper(version)
def install_vyper(*versions: str) -> None: """Installs vyper versions.""" for version in versions: vvm.install_vyper(version, show_progress=True)
def _install_vyper(version: Version): try: vvm.install_vyper(version, show_progress=True) except Exception as err: raise VyperInstallError( f"Unable to install Vyper version: '{version}'.") from err