diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ca76b3632..2def3efa4c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,6 +11,10 @@ parameters: type: string common: &common + parameters: + python_exec: + type: string + default: "python" working_directory: ~/repo steps: - checkout @@ -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: | @@ -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 @@ -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: @@ -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: @@ -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: @@ -260,7 +345,6 @@ workflows: python_minor_version: ["10", "11", "12"] name: "py3<< matrix.python_minor_version >>-windows-wheel" - nightly: triggers: - schedule: diff --git a/setup.py b/setup.py index 3225ab2ad1..242a7dd5b7 100644 --- a/setup.py +++ b/setup.py @@ -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", @@ -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", ], } diff --git a/tests/core/utilities/test_attach_modules.py b/tests/core/utilities/test_attach_modules.py index f836eb8777..bce820576a 100644 --- a/tests/core/utilities/test_attach_modules.py +++ b/tests/core/utilities/test_attach_modules.py @@ -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" ): @@ -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"), diff --git a/tox.ini b/tox.ini index c68fc0ac76..e8af27fe42 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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 diff --git a/web3/_utils/module.py b/web3/_utils/module.py index 63fc151232..bf32e0cdfa 100644 --- a/web3/_utils/module.py +++ b/web3/_utils/module.py @@ -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: