Skip to content

Commit f3af885

Browse files
committed
Add pypy test runs to eels backend tests; refactor 'test' extra.
- 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.
1 parent 616871d commit f3af885

File tree

5 files changed

+89
-16
lines changed

5 files changed

+89
-16
lines changed

Diff for: .circleci/config.yml

+72-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ parameters:
1414
type: string
1515

1616
common: &common
17+
parameters:
18+
python_exec:
19+
type: string
20+
default: "python"
1721
working_directory: ~/repo
1822
steps:
1923
- checkout
@@ -31,14 +35,46 @@ common: &common
3135
- restore_cache:
3236
keys:
3337
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
38+
- run:
39+
name: install pypy3 if python_exec is pypy3
40+
command: |
41+
if [ "<< parameters.python_exec >>" == "pypy3" ]; then
42+
sudo apt-get update
43+
44+
# If .pyenv already exists, remove and reinstall to get latest version
45+
if [ -d "$HOME/.pyenv" ]; then
46+
echo "Removing existing .pyenv directory..."
47+
rm -rf $HOME/.pyenv
48+
fi
49+
curl https://pyenv.run | bash
50+
export PATH="$HOME/.pyenv/bin:$PATH"
51+
eval "$(pyenv init --path)"
52+
eval "$(pyenv init -)"
53+
eval "$(pyenv virtualenv-init -)"
54+
55+
# Find the latest PyPy version matching the python minor version
56+
latest_pypy_version=$(pyenv install --list | grep -E "pypy3\.<< parameters.python_minor_version >>" | grep -v "\-src" | tail -1 | tr -d ' ')
57+
echo "Latest PyPy version: $latest_pypy_version"
58+
59+
# Install the latest PyPy 3.10 version using pyenv if not already installed
60+
pyenv install "$latest_pypy_version"
61+
pyenv global "$latest_pypy_version"
62+
63+
# Verify the correct PyPy version is being used
64+
pypy3 --version
65+
66+
# Install pip using the newly installed PyPy version
67+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
68+
pypy3 get-pip.py
69+
fi
3470
- run:
3571
name: install dependencies
3672
command: |
37-
python -m pip install --upgrade pip
38-
python -m pip install tox
73+
<< parameters.python_exec >> -m pip install -U pip
74+
<< parameters.python_exec >> -m pip install -U tox
3975
- run:
4076
name: run tox
41-
command: python -m tox run -r
77+
command: << parameters.python_exec >> -m tox -r
4278
- save_cache:
4379
paths:
4480
- .hypothesis
@@ -145,12 +181,30 @@ jobs:
145181
type: string
146182
tox_env:
147183
type: string
184+
python_exec:
185+
type: string
186+
default: "python"
148187
<<: *common
149188
docker:
150189
- image: cimg/python:3.<< parameters.python_minor_version >>
151190
environment:
152191
TOXENV: py3<< parameters.python_minor_version >>-<< parameters.tox_env >>
153192

193+
common-pypy:
194+
parameters:
195+
python_minor_version:
196+
type: string
197+
tox_env:
198+
type: string
199+
python_exec:
200+
type: string
201+
default: "pypy3"
202+
<<: *common
203+
docker:
204+
- image: cimg/python:3.<< parameters.python_minor_version >>
205+
environment:
206+
TOXENV: pypy3-<< parameters.tox_env >>
207+
154208
geth:
155209
parameters:
156210
python_minor_version:
@@ -234,6 +288,7 @@ workflows:
234288
"ensip15",
235289
"wheel"
236290
]
291+
python_exec: "python"
237292
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
238293
- common:
239294
matrix:
@@ -246,7 +301,21 @@ workflows:
246301
"ens-eels",
247302
"integration-ethtester-eels"
248303
]
304+
python_exec: "python"
249305
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
306+
- common-pypy:
307+
matrix:
308+
parameters:
309+
# eels only supports 3.10 and above; pyenv only has pypy3.10 available
310+
python_minor_version: ["10"]
311+
tox_env: [
312+
"core-eels",
313+
"core-eels_async",
314+
"ens-eels",
315+
"integration-ethtester-eels"
316+
]
317+
python_exec: "pypy3"
318+
name: "pypy3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
250319
- geth:
251320
matrix:
252321
parameters:
@@ -272,7 +341,6 @@ workflows:
272341
python_minor_version: ["10", "11", "12"]
273342
name: "py3<< matrix.python_minor_version >>-windows-wheel"
274343

275-
276344
nightly:
277345
triggers:
278346
- schedule:

Diff for: setup.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,8 @@
1010
"dev": [
1111
"build>=0.9.0",
1212
"bumpversion>=0.5.3",
13-
"flaky>=3.7.0",
14-
"hypothesis>=3.31.2",
1513
"ipython",
16-
"mypy==1.10.0",
17-
"pre-commit>=3.4.0",
18-
"pytest-asyncio>=0.21.2,<0.23",
19-
"pytest-mock>=1.10",
2014
"setuptools>=38.6.0",
21-
"tox>=4.0.0",
2215
"tqdm>4.32",
2316
"twine>=1.13",
2417
"wheel",
@@ -31,6 +24,7 @@
3124
# web3 will work but emit warnings with eth-account>=0.12.2,
3225
# but doctests fail between 0.12.2 and 0.13.0
3326
"eth-account>=0.13.0",
27+
"hypothesis>=3.31.2",
3428
],
3529
"test": [
3630
f"eth-tester[py-evm]{CUSTOM_ETH_TESTER_BRANCH}",
@@ -41,6 +35,11 @@
4135
"pytest-mock>=1.10",
4236
"pytest-xdist>=2.4.0",
4337
"pytest>=7.0.0",
38+
"flaky>=3.7.0",
39+
"hypothesis>=3.31.2",
40+
"tox>=4.0.0",
41+
"mypy==1.10.0",
42+
"pre-commit>=3.4.0",
4443
],
4544
}
4645

Diff for: tests/core/utilities/test_attach_modules.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_attach_modules_multiple_levels_deep(module1):
8383

8484
def test_attach_modules_with_wrong_module_format():
8585
mods = {"eth": (MockEth, MockEth, MockEth)}
86-
w3 = Web3(EthereumTesterProvider, modules={})
86+
w3 = Web3(EthereumTesterProvider(), modules={})
8787
with pytest.raises(
8888
Web3ValidationError, match="Module definitions can only have 1 or 2 elements"
8989
):
@@ -94,7 +94,7 @@ def test_attach_modules_with_existing_modules():
9494
mods = {
9595
"eth": MockEth,
9696
}
97-
w3 = Web3(EthereumTesterProvider, modules=mods)
97+
w3 = Web3(EthereumTesterProvider(), modules=mods)
9898
with pytest.raises(
9999
Web3AttributeError,
100100
match=("The web3 object already has an attribute with that name"),

Diff for: tox.ini

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
envlist=
33
py{310,311,312}-ens-eels
4+
pypy312-{ens,core,integration-ethtester}-eels
45
py{310,311,312}-core-eels
56
py{38,39,310,311,312}-ens-pyevm
67
py{38,39,310,311,312}-core-pyevm
@@ -24,7 +25,7 @@ max_issue_threshold=1
2425

2526
[testenv]
2627
allowlist_externals=make,pre-commit
27-
install_command=python -m pip install {opts} {packages}
28+
install_command=pip install {opts} {packages}
2829
usedevelop=True
2930
commands=
3031
core-pyevm: pytest {posargs:tests/core -m "not asyncio" --backend=pyevm}
@@ -44,7 +45,9 @@ commands=
4445
integration-ethtester-eels: pytest {posargs:tests/integration/ethereum_tester/test_eels.py}
4546
docs: make check-docs-ci
4647
deps =
47-
.[dev]
48+
.[test]
49+
; install both `docs` and `test` dependencies for the `docs` environment
50+
docs: .[docs]
4851
passenv =
4952
GETH_BINARY
5053
GOROOT

Diff for: web3/_utils/module.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
def _validate_init_params_and_return_if_found(module_class: Any) -> List[str]:
2828
init_params_raw = list(inspect.signature(module_class.__init__).parameters)
2929
module_init_params = [
30-
param for param in init_params_raw if param not in ["self", "args", "kwargs"]
30+
param
31+
for param in init_params_raw
32+
# pypy uses `obj` and `keywords` instead of `self` and `kwargs`, respectively
33+
if param not in ["self", "obj", "args", "kwargs", "keywords"]
3134
]
3235

3336
if len(module_init_params) > 1:

0 commit comments

Comments
 (0)