diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 093600d09f..badeabf3de 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -17,6 +17,6 @@ values = [bumpversion:part:devnum] -[bumpversion:file:setup.py] -search = version="{current_version}", -replace = version="{new_version}", +[bumpversion:file:web3/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" diff --git a/.circleci/config.yml b/.circleci/config.yml index bd6cb28de4..9eb92dee2f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,7 +8,7 @@ common: &common - checkout - restore_cache: keys: - - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: checkout ethpm-spec submodule command: git submodule update --init --recursive @@ -26,7 +26,7 @@ common: &common - ./eggs - ~/.ethash - ~/.py-geth - key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} resource_class: xlarge docs_steps: &docs_steps @@ -35,7 +35,7 @@ docs_steps: &docs_steps - checkout - restore_cache: keys: - - cache-docs-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - cache-docs-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: checkout ethpm-spec submodule command: git submodule update --init --recursive @@ -56,7 +56,7 @@ docs_steps: &docs_steps - ./eggs - ~/.ethash - ~/.py-geth - key: cache-docs-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: cache-docs-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} resource_class: xlarge geth_steps: &geth_steps @@ -66,7 +66,7 @@ geth_steps: &geth_steps - checkout - restore_cache: keys: - - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: install dependencies command: pip install --user tox @@ -102,7 +102,7 @@ geth_steps: &geth_steps - ./eggs - ~/.ethash - ~/.py-geth - key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} geth_custom_steps: &geth_custom_steps working_directory: ~/repo @@ -110,7 +110,7 @@ geth_custom_steps: &geth_custom_steps - checkout - restore_cache: keys: - - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: install dependencies command: pip install --user tox @@ -141,7 +141,7 @@ geth_custom_steps: &geth_custom_steps - ~/.local - ./eggs - ~/.ethash - key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} ethpm_steps: ðpm_steps working_directory: ~/repo @@ -150,7 +150,7 @@ ethpm_steps: ðpm_steps - checkout - restore_cache: keys: - - ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: install ipfs command: @@ -176,7 +176,7 @@ ethpm_steps: ðpm_steps - .tox - ~/.cache/pip - ~/.local - key: ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: ethpm-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} orbs: win: circleci/windows@2.2.0 @@ -190,7 +190,7 @@ windows_steps: &windows_steps - checkout - restore_cache: keys: - - windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + - windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} - run: name: checkout ethpm-spec submodule command: git submodule update --init --recursive @@ -203,7 +203,7 @@ windows_steps: &windows_steps - save_cache: paths: - .tox - key: windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }} + key: windows-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "pyproject.toml" }}-{{ checksum "tox.ini" }} jobs: diff --git a/Dockerfile b/Dockerfile index 8fe1aabb26..3d4dc3dd2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ COPY tests ./tests/ COPY ens ./ens/ COPY ethpm ./ethpm/ -COPY setup.py . +COPY pyproject.toml . COPY README.md . RUN pip install -e .[dev] diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 7375aea935..0000000000 --- a/MANIFEST.in +++ /dev/null @@ -1,11 +0,0 @@ -include LICENSE -include VERSION -include README.md -include requirements.txt - -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] - -recursive-include ethpm/assets/ * -recursive-include ethpm/ethpm-spec/examples * -recursive-include ethpm/ethpm-spec/spec * diff --git a/Makefile b/Makefile index b9329423d9..004f57518a 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ benchmark: tox -e benchmark build-docs: - sphinx-apidoc -o docs/ . setup.py "*conftest*" "tests" "ethpm" "web3/tools/*" + sphinx-apidoc -o docs/ . "*conftest*" "tests" "ethpm" "web3/tools/*" $(MAKE) -C docs clean $(MAKE) -C docs html $(MAKE) -C docs doctest @@ -72,14 +72,14 @@ release: clean git config commit.gpgSign true bumpversion $(bump) git push upstream && git push upstream --tags - python setup.py sdist bdist_wheel + python -m build twine upload dist/* git config commit.gpgSign "$(CURRENT_SIGN_SETTING)" dist: clean - python setup.py sdist bdist_wheel + python -m build ls -l dist package: clean - python setup.py sdist bdist_wheel + python -m build python web3/scripts/release/test_package.py diff --git a/docs/conf.py b/docs/conf.py index f40b54384d..4628073b57 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,11 +18,11 @@ import os -DIR = os.path.dirname("__file__") -with open(os.path.join(DIR, "../setup.py"), "r") as f: +DIR = os.path.dirname(os.path.abspath(__file__)) +with open(os.path.join(DIR, "..", "web3", "__init__.py"), "r") as f: for line in f: - if "version=" in line: - setup_version = line.split('"')[1] + if line.startswith("__version__"): + setup_version = line.strip().split(" = ")[1].strip('"') break # -- General configuration ------------------------------------------------ diff --git a/pyproject.toml b/pyproject.toml index e408dc0320..e29716353d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,132 @@ +[build-system] +requires = ["hatchling>=1.8.0"] +build-backend = "hatchling.build" + +[project] +name = "web3" +dynamic = ["version"] +description = "Web3.py" +readme = "README.md" +license = "MIT" +requires-python = ">=3.7.2,<3.11" +authors = [ + { name = "Piper Merriam", email = "pipermerriam@gmail.com" }, +] +keywords = [ + "ethereum", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", +] +dependencies = [ + "aiohttp>=3.7.4.post0,<4", + "eth-abi>=3.0.0,<4.0.0", + "eth-account>=0.7.0,<0.8.0", + "eth-hash[pycryptodome]>=0.2.0,<1.0.0", + "eth-typing>=3.0.0,<4.0.0", + "eth-utils>=2.0.0,<3.0.0", + "hexbytes>=0.1.0,<1.0.0", + "ipfshttpclient==0.8.0a2", + "jsonschema>=4.0.0,<5", + "lru-dict>=1.1.6,<2.0.0", + "protobuf>=4.21.6", + "pywin32>=223;platform_system=='Windows'", + "requests>=2.16.0,<3.0.0", + # remove typing_extensions after python_requires>=3.8, see web3._utils.compat + "typing-extensions>=3.7.4.1,<5;python_version<'3.8'", + "websockets>=10.0.0,<11", +] + +[project.optional-dependencies] +dev = [ + "bumpversion", + "build", + "flaky>=3.7.0,<4", + "hypothesis>=3.31.2,<6", + "importlib-metadata<5.0;python_version<'3.8'", + "pytest>=6.2.5,<7", + "pytest-asyncio>=0.18.1,<0.19", + "pytest-mock>=1.10,<2", + "pytest-pythonpath>=0.3", + "pytest-watch>=4.2,<5", + "pytest-xdist>=1.29,<2", + "setuptools>=38.6.0", + "tox>=1.8.0", + "tqdm>4.32,<5", + "twine>=1.13,<2", + "pluggy==0.13.1", + "when-changed>=0.3.0,<0.4", + # pip now supports self references https://github.com/pypa/pip/issues/11296 + "web3[docs,linter,tester]", +] +docs = [ + "click>=5.1", + "configparser==3.5.0", + "contextlib2>=0.5.4", + "mock", + "py-geth>=3.9.1,<4", + "py-solc>=0.4.0", + "pytest>=6.2.5,<7", + "sphinx-better-theme>=0.1.4", + "sphinx>=4.2.0,<5", + "sphinx_rtd_theme>=0.1.9", + "toposort>=1.4", + "towncrier==18.5.0", + "urllib3", + "wheel", +] +linter = [ + "black>=22.1.0,<23.0", + "flake8==3.8.3", + "isort>=4.2.15,<4.3.5", + "mypy==0.910", + "types-protobuf==3.19.13", + "types-requests>=2.26.1,<3", + "types-setuptools>=57.4.4,<58", +] +tester = [ + "eth-tester[py-evm]==v0.7.0-beta.1", + "py-geth>=3.9.1,<4", +] + +[project.entry-points.pytest11] +pytest_ethereum = "web3.tools.pytest_ethereum.plugins" + +[project.urls] +Homepage = "https://github.com/ethereum/web3.py" + +[tool.hatch.version] +path = "web3/__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/ens", + "/ethpm", + "/web3", + "/requirements*.txt", +] + +[tool.hatch.build.targets.wheel] +include = [ + "/ens", + "/ethpm", + "/web3", +] +exclude = [ + "/ethpm/ethpm-spec/*", + "/ethpm/ethpm-spec/bin", + "/ethpm/ethpm-spec/docs", + "/ethpm/ethpm-spec/tests", +] + [tool.towncrier] package="web3" filename = "docs/releases.rst" diff --git a/setup.py b/setup.py deleted file mode 100644 index 2c39474716..0000000000 --- a/setup.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -from setuptools import ( - find_packages, - setup, -) - -extras_require = { - "tester": [ - "eth-tester[py-evm]==v0.7.0-beta.1", - "py-geth>=3.9.1,<4", - ], - "linter": [ - "black>=22.1.0,<23.0", - "flake8==3.8.3", - "isort>=4.2.15,<4.3.5", - "mypy==0.910", - "types-setuptools>=57.4.4,<58", - "types-requests>=2.26.1,<3", - "types-protobuf==3.19.13", - ], - "docs": [ - "mock", - "sphinx-better-theme>=0.1.4", - "click>=5.1", - "configparser==3.5.0", - "contextlib2>=0.5.4", - "py-geth>=3.9.1,<4", - "py-solc>=0.4.0", - "pytest>=6.2.5,<7", - "sphinx>=4.2.0,<5", - "sphinx_rtd_theme>=0.1.9", - "toposort>=1.4", - "towncrier==18.5.0", - "urllib3", - "wheel", - ], - "dev": [ - "bumpversion", - "flaky>=3.7.0,<4", - "hypothesis>=3.31.2,<6", - "importlib-metadata<5.0;python_version<'3.8'", - "pytest>=6.2.5,<7", - "pytest-asyncio>=0.18.1,<0.19", - "pytest-mock>=1.10,<2", - "pytest-pythonpath>=0.3", - "pytest-watch>=4.2,<5", - "pytest-xdist>=1.29,<2", - "setuptools>=38.6.0", - "tox>=1.8.0", - "tqdm>4.32,<5", - "twine>=1.13,<2", - "pluggy==0.13.1", - "when-changed>=0.3.0,<0.4", - ], -} - -extras_require["dev"] = ( - extras_require["tester"] - + extras_require["linter"] - + extras_require["docs"] - + extras_require["dev"] -) - -with open("./README.md") as readme: - long_description = readme.read() - -setup( - name="web3", - # *IMPORTANT*: Don't manually change the version here. Use the 'bumpversion' utility. - version="6.0.0-beta.6", - description="""Web3.py""", - long_description_content_type="text/markdown", - long_description=long_description, - author="Piper Merriam", - author_email="pipermerriam@gmail.com", - url="https://github.com/ethereum/web3.py", - include_package_data=True, - install_requires=[ - "aiohttp>=3.7.4.post0,<4", - "eth-abi>=3.0.0,<4.0.0", - "eth-account>=0.7.0,<0.8.0", - "eth-hash[pycryptodome]>=0.2.0,<1.0.0", - "eth-typing>=3.0.0,<4.0.0", - "eth-utils>=2.0.0,<3.0.0", - "hexbytes>=0.1.0,<1.0.0", - "ipfshttpclient==0.8.0a2", - "jsonschema>=4.0.0,<5", - "lru-dict>=1.1.6,<2.0.0", - "protobuf>=4.21.6", - "pywin32>=223;platform_system=='Windows'", - "requests>=2.16.0,<3.0.0", - # remove typing_extensions after python_requires>=3.8, see web3._utils.compat - "typing-extensions>=3.7.4.1,<5;python_version<'3.8'", - "websockets>=10.0.0,<11", - ], - python_requires=">=3.7.2", - extras_require=extras_require, - py_modules=["web3", "ens", "ethpm"], - entry_points={"pytest11": ["pytest_ethereum = web3.tools.pytest_ethereum.plugins"]}, - license="MIT", - zip_safe=False, - keywords="ethereum", - packages=find_packages(exclude=["tests", "tests.*"]), - package_data={"web3": ["py.typed"]}, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], -) diff --git a/tox.ini b/tox.ini index c49ad89d8c..4905b86022 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist= py{37,38,39,310}-ens py{37,38,39,310}-ethpm @@ -28,7 +29,7 @@ extend-ignore=E203,W503 [testenv] whitelist_externals=/usr/bin/make -install_command=python -m pip install --no-use-pep517 {opts} {packages} +install_command=python -m pip install {opts} {packages} usedevelop=True commands= core: pytest {posargs:tests/core} @@ -64,7 +65,7 @@ basepython=python extras=linter commands= flake8 {toxinidir}/web3 {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/tests --exclude {toxinidir}/ethpm/ethpm-spec,{toxinidir}/**/*_pb2.py - black {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/web3 {toxinidir}/tests {toxinidir}/setup.py --exclude {toxinidir}/ethpm/ethpm-spec --extend-exclude {toxinidir}/ethpm/_utils/protobuf/ipfs_file_pb2.py --check + black {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/web3 {toxinidir}/tests --exclude {toxinidir}/ethpm/ethpm-spec --extend-exclude {toxinidir}/ethpm/_utils/protobuf/ipfs_file_pb2.py --check isort --recursive --skip {toxinidir}/ethpm/_utils/protobuf/ipfs_file_pb2.py --skip {toxinidir}/ethpm/ethpm-spec --check-only --diff {toxinidir}/web3/ {toxinidir}/ens/ {toxinidir}/ethpm/ {toxinidir}/tests/ mypy -p web3 -p ethpm -p ens --exclude {toxinidir}/ethpm/_utils/protobuf/ipfs_file_pb2.py --config-file {toxinidir}/mypy.ini @@ -76,13 +77,14 @@ commands= python {toxinidir}/web3/tools/benchmark/main.py --num-calls 100 [common-wheel-cli] -deps=wheel +# Conda issue https://github.com/pypa/build/issues/253 +deps=build[virtualenv] whitelist_externals= /bin/rm /bin/bash commands= /bin/rm -rf build dist - python setup.py sdist bdist_wheel + python -m build /bin/bash -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off' python -c "from web3.auto import w3" @@ -111,12 +113,13 @@ commands={[common-wheel-cli]commands} skip_install=true [common-wheel-cli-windows] -deps=wheel +# Conda issue https://github.com/pypa/build/issues/253 +deps=build[virtualenv] whitelist_externals= bash.exe commands= bash.exe -c "rm -rf build dist" - python setup.py sdist bdist_wheel + python -m build bash.exe -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off' python -c "from web3.auto import w3" diff --git a/web3/__init__.py b/web3/__init__.py index 3f88359a4b..eb12b8fa8b 100644 --- a/web3/__init__.py +++ b/web3/__init__.py @@ -1,5 +1,3 @@ -import pkg_resources - from eth_account import Account # noqa: E402, from web3.main import Web3 # noqa: E402, from web3.providers.eth_tester import ( # noqa: E402 @@ -18,7 +16,7 @@ WebsocketProvider, ) -__version__ = pkg_resources.get_distribution("web3").version +__version__ = "6.0.0-beta.6" __all__ = [ "__version__",