Skip to content

Commit

Permalink
Add pypy test runs to eels backend tests; refactor 'test' extra.
Browse files Browse the repository at this point in the history
- Only need to run 'test' extra for tests, not the full 'dev' extra.
- Add the 'docs' extra along with the 'test' extra for docs builds.
- Add pypy py-evm CI jobs; refactor testenvs in ``tox.ini``.
  • Loading branch information
fselmo committed Aug 22, 2024
1 parent 73d7882 commit d9abd7e
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 20 deletions.
96 changes: 90 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ parameters:
type: string

common: &common
parameters:
python_exec:
type: string
default: "python"
working_directory: ~/repo
steps:
- checkout
Expand All @@ -28,6 +32,38 @@ common: &common
- restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
- run:
name: install pypy3 if python_exec is pypy3
command: |
if [ "<< parameters.python_exec >>" == "pypy3" ]; then
sudo apt-get update
# If .pyenv already exists, remove and reinstall to get latest version
if [ -d "$HOME/.pyenv" ]; then
echo "Removing existing .pyenv directory..."
rm -rf $HOME/.pyenv
fi
curl https://pyenv.run | bash
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# Find the latest PyPy version matching the python minor version
latest_pypy_version=$(pyenv install --list | grep -E "pypy3\.<< parameters.python_minor_version >>" | grep -v "\-src" | tail -1 | tr -d ' ')
echo "Latest PyPy version: $latest_pypy_version"
# Install the latest PyPy 3.10 version using pyenv if not already installed
pyenv install "$latest_pypy_version"
pyenv global "$latest_pypy_version"
# Verify the correct PyPy version is being used
pypy3 --version
# Install pip using the newly installed PyPy version
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
pypy3 get-pip.py
fi
- run:
name: install dependencies
command: |
Expand All @@ -36,7 +72,7 @@ common: &common
python web3/scripts/install_pre_releases.py
- run:
name: run tox
command: python -m tox run -r
command: << parameters.python_exec >> -m tox -r
- save_cache:
paths:
- .hypothesis
Expand Down Expand Up @@ -145,12 +181,30 @@ jobs:
type: string
tox_env:
type: string
python_exec:
type: string
default: "python"
<<: *common
docker:
- image: cimg/python:3.<< parameters.python_minor_version >>
environment:
TOXENV: py3<< parameters.python_minor_version >>-<< parameters.tox_env >>

common-pypy:
parameters:
python_minor_version:
type: string
tox_env:
type: string
python_exec:
type: string
default: "pypy3"
<<: *common
docker:
- image: cimg/python:3.<< parameters.python_minor_version >>
environment:
TOXENV: pypy3<< parameters.python_minor_version >>-<< parameters.tox_env >>

geth:
parameters:
python_minor_version:
Expand Down Expand Up @@ -228,13 +282,44 @@ workflows:
python_minor_version: ["8", "9", "10", "11", "12"]
tox_env: [
"lint",
"core",
"core_async",
"ens",
"core-pyevm",
"core-pyevm_async",
"ens-pyevm",
"ensip15",
"wheel"
]
python_exec: "python"
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- common:
matrix:
parameters:
# eels only supports 3.10 and above
python_minor_version: ["10", "11", "12"]
tox_env: [
"core-eels",
"core-eels_async",
"ens-eels",
"integration-ethtester-eels"
]
python_exec: "python"
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- common-pypy:
matrix:
parameters:
# eels only supports 3.10 and above; pyenv only has pypy3.10 available
python_minor_version: ["10"]
tox_env: [
"core-eels",
"core-eels_async",
"ens-eels",
"integration-ethtester-eels",
"core-pyevm",
"core-pyevm_async",
"ens-pyevm",
"integration-ethtester-pyevm"
]
python_exec: "pypy3"
name: "pypy3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- geth:
matrix:
parameters:
Expand All @@ -246,7 +331,7 @@ workflows:
"integration-goethereum-http_async",
"integration-goethereum-legacy_ws",
"integration-goethereum-ws",
"integration-ethtester"
"integration-ethtester-pyevm"
]
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- docs:
Expand All @@ -260,7 +345,6 @@ workflows:
python_minor_version: ["10", "11", "12"]
name: "py3<< matrix.python_minor_version >>-windows-wheel"


nightly:
triggers:
- schedule:
Expand Down
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,8 @@
"dev": [
"build>=0.9.0",
"bumpversion>=0.5.3",
"flaky>=3.7.0",
"hypothesis>=3.31.2",
"ipython",
"mypy==1.10.0",
"pre-commit>=3.4.0",
"pytest-asyncio>=0.21.2,<0.23",
"pytest-mock>=1.10",
"setuptools>=38.6.0",
"tox>=4.0.0",
"tqdm>4.32",
"twine>=1.13",
"wheel",
Expand All @@ -39,6 +32,11 @@
"pytest-mock>=1.10",
"pytest-xdist>=2.4.0",
"pytest>=7.0.0",
"flaky>=3.7.0",
"hypothesis>=3.31.2",
"tox>=4.0.0",
"mypy==1.10.0",
"pre-commit>=3.4.0",
],
}

Expand Down
4 changes: 2 additions & 2 deletions tests/core/utilities/test_attach_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_attach_modules_multiple_levels_deep(module1):

def test_attach_modules_with_wrong_module_format():
mods = {"eth": (MockEth, MockEth, MockEth)}
w3 = Web3(EthereumTesterProvider, modules={})
w3 = Web3(EthereumTesterProvider(), modules={})
with pytest.raises(
Web3ValidationError, match="Module definitions can only have 1 or 2 elements"
):
Expand All @@ -94,7 +94,7 @@ def test_attach_modules_with_existing_modules():
mods = {
"eth": MockEth,
}
w3 = Web3(EthereumTesterProvider, modules=mods)
w3 = Web3(EthereumTesterProvider(), modules=mods)
with pytest.raises(
Web3AttributeError,
match=("The web3 object already has an attribute with that name"),
Expand Down
11 changes: 7 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tox]
envlist=
py{38,39,310,311,312}-{ens,core,lint,wheel}-pyevm
py{310,311,312}-{ens,core}-eels
py{38,39,310,311,312}-integration-{goethereum,ethtester}
py{py}{38,39,310,311,312}-{ens,core}-pyevm
py{py}{310,311,312}-{ens,core}-eels
py{38,39,310,311,312}-integration-{goethereum,ethtester-pyevm}
py{310,311,312}-integration-ethtester-eels
py{38,39,310,311,312}-{lint,wheel}
docs
benchmark
windows-wheel
Expand Down Expand Up @@ -39,7 +40,9 @@ commands=
integration-ethtester-eels: pytest {posargs:tests/integration/ethereum_tester/test_eels.py}
docs: make check-docs-ci
deps =
.[dev]
.[test]
; install both `docs` and `test` dependencies for the `docs` environment
docs: .[docs]
passenv =
GETH_BINARY
GOROOT
Expand Down
5 changes: 4 additions & 1 deletion web3/_utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
def _validate_init_params_and_return_if_found(module_class: Any) -> List[str]:
init_params_raw = list(inspect.signature(module_class.__init__).parameters)
module_init_params = [
param for param in init_params_raw if param not in ["self", "args", "kwargs"]
param
for param in init_params_raw
# pypy uses `obj` and `keywords` instead of `self` and `kwargs`, respectively
if param not in ["self", "obj", "args", "kwargs", "keywords"]
]

if len(module_init_params) > 1:
Expand Down

0 comments on commit d9abd7e

Please sign in to comment.