refactor: normalize compiler version handling#2149
Open
banteg wants to merge 8 commits into
Open
Conversation
db86ec7 to
05b06b2
Compare
05b06b2 to
00f251a
Compare
00f251a to
278c036
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
feat/fix-pr-ci).feat/fix-pr-ci..feat/compiler-version-normalization.feat/fix-pr-cias this upstream PR's base while that branch only exists in the fork, so the visible PR diff includes the stack until fix: repair pull request ci #2148 lands.Summary
This PR separates Brownie's compiler version value type from pragma range parsing:
packaging.version.Version, matching py-solc-x and vvm.# @versionpragmas continue to use npm-style range grammar throughsemantic_version.NpmSpec.packaging.specifiers.SpecifierSetbehavior.That gives Brownie the same version object type as its compiler-manager dependencies without replacing Solidity/Vyper pragma syntax with PEP 440.
Details
brownie._versioningfor compiler version normalization and language-specific pragma wrappers.v0.8.20and0.8.20+commit...intopackaging.version.Version.pragma soliditydirectives are intersected, andpragma solidityx;is not treated as a Solidity version pragma.NpmSpecfor Solidity-specific input cleanup: operator spacing, quoted range tokens, adjacent operator splitting, rejection ofv-prefixed Solidity literals, rejection of prerelease/build-qualified match expressions, and solc's wider^0.0.patchbehavior.# @versionmatching onNpmSpec, including old prerelease spellings such as0.1.0b16.#pragma version/# @versionmatching onSpecifierSet, including Vyper's leading^to~=compatibility rewrite.#pragma optimizeare ignored.Compatibility Notes
brownie.project.compiler.solidity.get_version()andbrownie.project.compiler.vyper.get_version()now returnpackaging.version.Version.semantic_version.Versionconveniences such as.truncate(),.next_minor(), or.next_patch()on those return values should switch topackaging.Versionproperties/helpers.semantic-versionremains a runtime dependency because Brownie still accepts npm-style Solidity and legacy Vyper pragma syntax.packagingis now a direct runtime dependency because Brownie imports it directly.install_solc("latest")is preserved and still forwards"latest"to py-solc-x.Generated Files
build/.feat/fix-pr-ci..feat/compiler-version-normalization -- . ':!build/__native_eth_brownie.c' ':!build/__native_eth_brownie.h' ':!build/__native_internal_eth_brownie.h'.Validation
uv run --python /opt/homebrew/bin/python3.13 --with-requirements requirements.txt --with pytest-cov==2.10.1 --with eth-retry==0.3.5 python -m pytest tests/project/test_sources.py tests/project/compiler/test_utils.py tests/project/compiler/test_solidity.py -k 'not first_revert' -quv run --python /opt/homebrew/bin/python3.13 --with-requirements requirements.txt --with pytest-cov==2.10.1 --with eth-retry==0.3.5 python -m pytest tests/project/compiler/test_vyper.py -k 'find_vyper_versions_uses_installed_when_available_list_does_not_match or set_vyper_version_normalizes_version_like_objects' -quv run --isolated python -m py_compile brownie/_versioning.py brownie/project/sources.py brownie/project/compiler/solidity.py brownie/project/compiler/vyper.py tests/project/test_sources.py tests/project/compiler/test_solidity.py tests/project/compiler/test_vyper.py tests/project/compiler/test_utils.pyuvx --from black==24.1.1 black --check brownie/_versioning.py brownie/project/sources.py brownie/project/compiler/solidity.py brownie/project/compiler/vyper.py tests/project/test_sources.py tests/project/compiler/test_solidity.py tests/project/compiler/test_vyper.py tests/project/compiler/test_utils.pyuvx --from isort==5.13.2 isort --check-only --diff brownie/_versioning.py brownie/project/sources.py brownie/project/compiler/solidity.py brownie/project/compiler/vyper.py tests/project/test_sources.py tests/project/compiler/test_solidity.py tests/project/compiler/test_vyper.py tests/project/compiler/test_utils.py --skip brownie/__init__.pyuvx --python /opt/homebrew/bin/python3.13 --from build python -m build --wheelgit diff --check feat/fix-pr-ci..feat/compiler-version-normalization -- . ':!build/__native_eth_brownie.c'Note: generated mypyc C output still contains generator-emitted trailing whitespace, so the whitespace check excludes the generated C artifact.