From 31f77c0c29868ca2de21bbc0c3ab24f7fbd2f37d Mon Sep 17 00:00:00 2001 From: Keri Date: Fri, 6 Dec 2019 15:36:05 -0700 Subject: [PATCH 1/2] Add script to test packaging --- .circleci/config.yml | 30 ++++++++++++-- Makefile | 4 ++ README.md | 29 ++++++++++++- docs/conf.py | 1 + newsfragments/1545.misc.rst | 1 + tox.ini | 31 ++++++++++++++ web3/scripts/__init__.py | 0 web3/scripts/release/__init__.py | 0 web3/scripts/release/test_package.py | 61 ++++++++++++++++++++++++++++ 9 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 newsfragments/1545.misc.rst create mode 100644 web3/scripts/__init__.py create mode 100644 web3/scripts/release/__init__.py create mode 100644 web3/scripts/release/test_package.py diff --git a/.circleci/config.yml b/.circleci/config.yml index 950c4df199..4523622ac4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -264,6 +264,12 @@ jobs: environment: TOXENV: py36-integration-ethtester ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + py36-wheel-cli: + <<: *common + docker: + - image: circleci/python:3.6 + environment: + TOXENV: py36-wheel-cli # # Python 3.7 # @@ -372,6 +378,12 @@ jobs: environment: TOXENV: py37-integration-ethtester ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + py37-wheel-cli: + <<: *common + docker: + - image: circleci/python:3.7 + environment: + TOXENV: py37-wheel-cli # # Python 3.8 # @@ -481,13 +493,24 @@ jobs: TOXENV: py38-integration-ethtester ETHEREUM_TESTER_CHAIN_BACKEND: eth_tester.backends.PyEVMBackend + py38-wheel-cli: + <<: *common + docker: + - image: circleci/python:3.8 + environment: + TOXENV: py38-wheel-cli + workflows: version: 2 test: jobs: + # These are the longest running tests, start them first + - py36-core + - py37-core + - py38-core + - lint - docs - - py36-core - py36-ens - py36-ethpm - py36-integration-goethereum-ipc-1.7.2 @@ -500,7 +523,7 @@ workflows: - py36-integration-parity-http - py36-integration-parity-ws - py36-integration-ethtester-pyevm - - py37-core + - py36-wheel-cli - py37-ens - py37-ethpm - py37-integration-goethereum-ipc-1.7.2 @@ -513,7 +536,7 @@ workflows: - py37-integration-parity-http - py37-integration-parity-ws - py37-integration-ethtester-pyevm - - py38-core + - py37-wheel-cli - py38-ens - py38-ethpm - py38-integration-goethereum-ipc-1.7.2 @@ -526,3 +549,4 @@ workflows: - py38-integration-parity-http - py38-integration-parity-ws - py38-integration-ethtester-pyevm + - py38-wheel-cli diff --git a/Makefile b/Makefile index e7d05f83c1..7622bc8c65 100644 --- a/Makefile +++ b/Makefile @@ -69,3 +69,7 @@ release: clean dist: clean python setup.py sdist bdist_wheel ls -l dist + +package: clean + python setup.py sdist bdist_wheel + python web3/scripts/release/test_package.py diff --git a/README.md b/README.md index 0139db1038..07eaecd57e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ To start up the test environment, run: docker-compose up -d ``` -This will build a Docker container set up with an environment to run the Python test code. +This will build a Docker container set up with an environment to run the Python test code. **Note: This container does not have `go-ethereum` installed, so you cannot run the go-ethereum test suite.** @@ -134,6 +134,33 @@ For Debian-like systems: apt install pandoc ``` +The final step before releasing is to build and test the code that will be released. +There is a test script that will build and install the wheel locally, +then generate a temporary virtualenv where you can do some smoke testing: + +``` +# Branch name could be either master or a version branch - ex. v5 + +$ git checkout && git pull + +$ make package + +# in another shell, navigate to the virtualenv mentioned in output of ^ + +# load the virtualenv with the packaged trinity release +$ source package-smoke-test/bin/activate + +# smoke test the release +$ pip install ipython +$ ipython +>>> from web3.auto import w3 +>>> w3.isConnected() +>>> ... + +# Preview the upcoming release notes +$ towncrier --draft +``` + To release a new version: ```sh diff --git a/docs/conf.py b/docs/conf.py index a2b590a92a..ac51ca7688 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -88,6 +88,7 @@ 'web3.middleware.rst', 'web3.providers.rst', 'web3.providers.eth_tester.rst', + 'web3.scripts.*', 'web3.testing.rst', 'web3.tools.*', ] diff --git a/newsfragments/1545.misc.rst b/newsfragments/1545.misc.rst new file mode 100644 index 0000000000..0b1a2e351b --- /dev/null +++ b/newsfragments/1545.misc.rst @@ -0,0 +1 @@ +Add script to test release install diff --git a/tox.ini b/tox.ini index 02435d1430..96104648df 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ envlist= py{36,37,38}-integration-{goethereum,ethtester,parity} lint docs + py{36,37,38}-wheel-cli [isort] combine_as_imports=True @@ -24,6 +25,7 @@ max-line-length= 100 exclude= venv*,.tox,docs,build ignore= [testenv] +whitelist_externals=/usr/bin/make install_command=python -m pip install --no-use-pep517 {opts} {packages} usedevelop=True commands= @@ -64,3 +66,32 @@ commands= flake8 {toxinidir}/web3 {toxinidir}/ens {toxinidir}/ethpm {toxinidir}/tests isort --recursive --check-only --diff {toxinidir}/web3/ {toxinidir}/ens/ {toxinidir}/ethpm/ {toxinidir}/tests/ mypy -p web3 -p ethpm -p ens --config-file {toxinidir}/mypy.ini + +[common-wheel-cli] +deps=wheel +whitelist_externals= + /bin/rm + /bin/bash +commands= + /bin/rm -rf build dist + python setup.py sdist bdist_wheel + /bin/bash -c 'pip install --upgrade "$(ls dist/web3-*-py3-none-any.whl)" --progress-bar off' + python -c "from web3.auto import w3" + +[testenv:py36-wheel-cli] +deps={[common-wheel-cli]deps} +whitelist_externals={[common-wheel-cli]whitelist_externals} +commands={[common-wheel-cli]commands} +skip_install=true + +[testenv:py37-wheel-cli] +deps={[common-wheel-cli]deps} +whitelist_externals={[common-wheel-cli]whitelist_externals} +commands={[common-wheel-cli]commands} +skip_install=true + +[testenv:py38-wheel-cli] +deps={[common-wheel-cli]deps} +whitelist_externals={[common-wheel-cli]whitelist_externals} +commands={[common-wheel-cli]commands} +skip_install=true diff --git a/web3/scripts/__init__.py b/web3/scripts/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web3/scripts/release/__init__.py b/web3/scripts/release/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/web3/scripts/release/test_package.py b/web3/scripts/release/test_package.py new file mode 100644 index 0000000000..cd3d6dc6ee --- /dev/null +++ b/web3/scripts/release/test_package.py @@ -0,0 +1,61 @@ +from pathlib import ( + Path, +) +import subprocess +from tempfile import ( + TemporaryDirectory, +) +from typing import ( + Tuple, +) +import venv + + +def create_venv(parent_path: Path) -> Path: + venv_path = parent_path / 'package-smoke-test' + venv.create(venv_path, with_pip=True) + subprocess.run([venv_path / 'bin' / 'pip', 'install', '-U', 'pip', 'setuptools'], check=True) + return venv_path + + +def find_wheel(project_path: Path) -> Path: + wheels = list(project_path.glob('dist/*.whl')) + + if len(wheels) != 1: + raise Exception( + f"Expected one wheel. Instead found: {wheels} in project {project_path.absolute()}" + ) + + return wheels[0] + + +def install_wheel( + venv_path: Path, wheel_path: Path, extras: Tuple[str, ...] = () +) -> None: + if extras: + extra_suffix = f"[{','.join(extras)}]" + else: + extra_suffix = "" + + subprocess.run( + [ + venv_path / 'bin' / 'pip', + 'install', + f"{wheel_path}{extra_suffix}" + ], + check=True, + ) + + +def test_install_local_wheel() -> None: + with TemporaryDirectory() as tmpdir: + venv_path = create_venv(Path(tmpdir)) + wheel_path = find_wheel(Path('.')) + install_wheel(venv_path, wheel_path) + print("Installed", wheel_path.absolute(), "to", venv_path) + print(f"Activate with `source {venv_path}/bin/activate`") + input("Press enter when the test has completed. The directory will be deleted.") + + +if __name__ == '__main__': + test_install_local_wheel() From c09b4176733e2da40264bbbe72e35c95fdfcb0c6 Mon Sep 17 00:00:00 2001 From: Keri Date: Mon, 13 Apr 2020 11:38:33 -0600 Subject: [PATCH 2/2] Pin sphinx version to less than v3 --- setup.py | 2 +- tox.ini | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b01144d669..f8d29d9e88 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ "py-geth>=1.4.0", "py-solc>=0.4.0", "pytest>=4.4.0,<5.0.0", - "sphinx", + "sphinx>=2.4.4,<3", "sphinx_rtd_theme>=0.1.9", "toposort>=1.4", "towncrier>=19.2.0,<20", diff --git a/tox.ini b/tox.ini index 96104648df..ca818978a4 100644 --- a/tox.ini +++ b/tox.ini @@ -42,7 +42,6 @@ commands= docs: make -C {toxinidir} validate-docs deps = .[dev] - docs: sphinx passenv = GETH_BINARY GETH_VERSION