Skip to content

Commit d9abd7e

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. - Add pypy py-evm CI jobs; refactor testenvs in ``tox.ini``.
1 parent 73d7882 commit d9abd7e

File tree

5 files changed

+108
-20
lines changed

5 files changed

+108
-20
lines changed

Diff for: .circleci/config.yml

+90-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ parameters:
1111
type: string
1212

1313
common: &common
14+
parameters:
15+
python_exec:
16+
type: string
17+
default: "python"
1418
working_directory: ~/repo
1519
steps:
1620
- checkout
@@ -28,6 +32,38 @@ common: &common
2832
- restore_cache:
2933
keys:
3034
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
35+
- run:
36+
name: install pypy3 if python_exec is pypy3
37+
command: |
38+
if [ "<< parameters.python_exec >>" == "pypy3" ]; then
39+
sudo apt-get update
40+
41+
# If .pyenv already exists, remove and reinstall to get latest version
42+
if [ -d "$HOME/.pyenv" ]; then
43+
echo "Removing existing .pyenv directory..."
44+
rm -rf $HOME/.pyenv
45+
fi
46+
curl https://pyenv.run | bash
47+
export PATH="$HOME/.pyenv/bin:$PATH"
48+
eval "$(pyenv init --path)"
49+
eval "$(pyenv init -)"
50+
eval "$(pyenv virtualenv-init -)"
51+
52+
# Find the latest PyPy version matching the python minor version
53+
latest_pypy_version=$(pyenv install --list | grep -E "pypy3\.<< parameters.python_minor_version >>" | grep -v "\-src" | tail -1 | tr -d ' ')
54+
echo "Latest PyPy version: $latest_pypy_version"
55+
56+
# Install the latest PyPy 3.10 version using pyenv if not already installed
57+
pyenv install "$latest_pypy_version"
58+
pyenv global "$latest_pypy_version"
59+
60+
# Verify the correct PyPy version is being used
61+
pypy3 --version
62+
63+
# Install pip using the newly installed PyPy version
64+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
65+
pypy3 get-pip.py
66+
fi
3167
- run:
3268
name: install dependencies
3369
command: |
@@ -36,7 +72,7 @@ common: &common
3672
python web3/scripts/install_pre_releases.py
3773
- run:
3874
name: run tox
39-
command: python -m tox run -r
75+
command: << parameters.python_exec >> -m tox -r
4076
- save_cache:
4177
paths:
4278
- .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.python_minor_version >>-<< parameters.tox_env >>
207+
154208
geth:
155209
parameters:
156210
python_minor_version:
@@ -228,13 +282,44 @@ workflows:
228282
python_minor_version: ["8", "9", "10", "11", "12"]
229283
tox_env: [
230284
"lint",
231-
"core",
232-
"core_async",
233-
"ens",
285+
"core-pyevm",
286+
"core-pyevm_async",
287+
"ens-pyevm",
234288
"ensip15",
235289
"wheel"
236290
]
291+
python_exec: "python"
237292
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
293+
- common:
294+
matrix:
295+
parameters:
296+
# eels only supports 3.10 and above
297+
python_minor_version: ["10", "11", "12"]
298+
tox_env: [
299+
"core-eels",
300+
"core-eels_async",
301+
"ens-eels",
302+
"integration-ethtester-eels"
303+
]
304+
python_exec: "python"
305+
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+
"core-pyevm",
317+
"core-pyevm_async",
318+
"ens-pyevm",
319+
"integration-ethtester-pyevm"
320+
]
321+
python_exec: "pypy3"
322+
name: "pypy3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
238323
- geth:
239324
matrix:
240325
parameters:
@@ -246,7 +331,7 @@ workflows:
246331
"integration-goethereum-http_async",
247332
"integration-goethereum-legacy_ws",
248333
"integration-goethereum-ws",
249-
"integration-ethtester"
334+
"integration-ethtester-pyevm"
250335
]
251336
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
252337
- docs:
@@ -260,7 +345,6 @@ workflows:
260345
python_minor_version: ["10", "11", "12"]
261346
name: "py3<< matrix.python_minor_version >>-windows-wheel"
262347

263-
264348
nightly:
265349
triggers:
266350
- schedule:

Diff for: setup.py

+5-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",
@@ -39,6 +32,11 @@
3932
"pytest-mock>=1.10",
4033
"pytest-xdist>=2.4.0",
4134
"pytest>=7.0.0",
35+
"flaky>=3.7.0",
36+
"hypothesis>=3.31.2",
37+
"tox>=4.0.0",
38+
"mypy==1.10.0",
39+
"pre-commit>=3.4.0",
4240
],
4341
}
4442

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[tox]
22
envlist=
3-
py{38,39,310,311,312}-{ens,core,lint,wheel}-pyevm
4-
py{310,311,312}-{ens,core}-eels
5-
py{38,39,310,311,312}-integration-{goethereum,ethtester}
3+
py{py}{38,39,310,311,312}-{ens,core}-pyevm
4+
py{py}{310,311,312}-{ens,core}-eels
5+
py{38,39,310,311,312}-integration-{goethereum,ethtester-pyevm}
66
py{310,311,312}-integration-ethtester-eels
7+
py{38,39,310,311,312}-{lint,wheel}
78
docs
89
benchmark
910
windows-wheel
@@ -39,7 +40,9 @@ commands=
3940
integration-ethtester-eels: pytest {posargs:tests/integration/ethereum_tester/test_eels.py}
4041
docs: make check-docs-ci
4142
deps =
42-
.[dev]
43+
.[test]
44+
; install both `docs` and `test` dependencies for the `docs` environment
45+
docs: .[docs]
4346
passenv =
4447
GETH_BINARY
4548
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)