Skip to content

Commit

Permalink
feat: log before installing
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Feb 17, 2025
1 parent 18ff026 commit 141e33c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ repos:
- id: check-yaml

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
rev: 6.0.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
rev: 25.1.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
rev: 7.1.2
hooks:
- id: flake8
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
rev: v1.15.0
hooks:
- id: mypy
additional_dependencies: [types-requests, types-setuptools]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.19
rev: 0.7.22
hooks:
- id: mdformat
additional_dependencies: [mdformat-gfm, mdformat-frontmatter, mdformat-pyproject]
Expand Down
19 changes: 12 additions & 7 deletions ape_solidity/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
DEFAULT_OPTIMIZATION_RUNS = 200


def _install_solc(version: Version) -> Version:
logger.info(f"Installing solc '{version}'.")
return install_solc(version, show_progress=True)


class ImportRemapping(PluginConfig):
"""
A remapped import set in the config.
Expand Down Expand Up @@ -222,7 +227,7 @@ def _get_configured_version(
specified_commit_hash = "+" in version
base_version = strip_commit_hash(version)
if base_version not in installed_versions:
install_solc(base_version, show_progress=True)
_install_solc(base_version)

settings_version = add_commit_hash(base_version)
if specified_commit_hash and settings_version != version:
Expand Down Expand Up @@ -608,15 +613,15 @@ def compile_code(
else:
if selected_version := select_version(pragma, self.available_versions):
version = selected_version
install_solc(version, show_progress=True)
_install_solc(version)
else:
raise SolcInstallError()

elif latest_installed := self.latest_installed_version:
version = latest_installed

elif latest := self.latest_version:
install_solc(latest, show_progress=True)
_install_solc(latest)
version = latest

else:
Expand Down Expand Up @@ -713,7 +718,7 @@ def get_version_map_from_imports(
and not any(pragma_map.values())
and (latest := self.latest_version)
):
install_solc(latest, show_progress=True)
_install_solc(latest)

# Adjust best-versions based on imports.
files_by_solc_version: dict[Version, set[Path]] = {}
Expand Down Expand Up @@ -794,7 +799,7 @@ def _get_pramga_spec_from_str(self, source_str: str) -> Optional["SpecifierSet"]
return pragma_spec

elif compiler_version := select_version(pragma_spec, self.available_versions):
install_solc(compiler_version, show_progress=True)
_install_solc(compiler_version)

else:
# Attempt to use the best-installed version.
Expand Down Expand Up @@ -837,15 +842,15 @@ def _get_best_version(self, path: Path, source_by_pragma_spec: dict) -> Version:
elif selected := select_version(pragma_spec, self.available_versions):
# Install missing version.
# NOTE: Must be installed before adding commit hash.
install_solc(selected, show_progress=True)
_install_solc(selected)
compiler_version = add_commit_hash(selected)

elif latest_installed := self.latest_installed_version:
compiler_version = latest_installed

elif latest := self.latest_version:
# Download latest version.
install_solc(latest, show_progress=True)
_install_solc(latest)
compiler_version = latest

else:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
max-line-length = 100
ignore = E704,W503,PYD002,TC003,TC006
exclude =
*.venv*
venv*
docs
build
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"pytest-benchmark", # For performance tests
],
"lint": [
"black>=24.10.0,<25", # Auto-formatter and linter
"mypy>=1.13.0,<2", # Static type analyzer
"black>=25.1.0,<26", # Auto-formatter and linter
"mypy>=1.15.0,<2", # Static type analyzer
"types-requests", # Needed for mypy type shed
"types-setuptools", # Needed for mypy type shed
"flake8>=7.1.1,<8", # Style linter
"flake8>=7.1.2,<8", # Style linter
"flake8-pydantic", # For detecting issues with Pydantic models
"flake8-type-checking", # Detect imports to move in/out of type-checking blocks
"isort>=5.13.2,<6", # Import sorting linter
"mdformat>=0.7.19", # Auto-formatter for markdown
"mdformat>=0.7.22", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
"mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml
Expand Down

0 comments on commit 141e33c

Please sign in to comment.