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.
  • Loading branch information
fselmo committed Aug 12, 2024
1 parent 616871d commit f3af885
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 16 deletions.
76 changes: 72 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ parameters:
type: string

common: &common
parameters:
python_exec:
type: string
default: "python"
working_directory: ~/repo
steps:
- checkout
Expand All @@ -31,14 +35,46 @@ 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: |
python -m pip install --upgrade pip
python -m pip install tox
<< parameters.python_exec >> -m pip install -U pip
<< parameters.python_exec >> -m pip install -U tox
- 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.tox_env >>

geth:
parameters:
python_minor_version:
Expand Down Expand Up @@ -234,6 +288,7 @@ workflows:
"ensip15",
"wheel"
]
python_exec: "python"
name: "py3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- common:
matrix:
Expand All @@ -246,7 +301,21 @@ workflows:
"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"
]
python_exec: "pypy3"
name: "pypy3<< matrix.python_minor_version >>-<< matrix.tox_env >>"
- geth:
matrix:
parameters:
Expand All @@ -272,7 +341,6 @@ workflows:
python_minor_version: ["10", "11", "12"]
name: "py3<< matrix.python_minor_version >>-windows-wheel"


nightly:
triggers:
- schedule:
Expand Down
13 changes: 6 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 @@ -31,6 +24,7 @@
# web3 will work but emit warnings with eth-account>=0.12.2,
# but doctests fail between 0.12.2 and 0.13.0
"eth-account>=0.13.0",
"hypothesis>=3.31.2",
],
"test": [
f"eth-tester[py-evm]{CUSTOM_ETH_TESTER_BRANCH}",
Expand All @@ -41,6 +35,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
7 changes: 5 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[tox]
envlist=
py{310,311,312}-ens-eels
pypy312-{ens,core,integration-ethtester}-eels
py{310,311,312}-core-eels
py{38,39,310,311,312}-ens-pyevm
py{38,39,310,311,312}-core-pyevm
Expand All @@ -24,7 +25,7 @@ max_issue_threshold=1

[testenv]
allowlist_externals=make,pre-commit
install_command=python -m pip install {opts} {packages}
install_command=pip install {opts} {packages}
usedevelop=True
commands=
core-pyevm: pytest {posargs:tests/core -m "not asyncio" --backend=pyevm}
Expand All @@ -44,7 +45,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 f3af885

Please sign in to comment.