From 3b39eb3886d08c1ea16f495a214ea95deb355237 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Tue, 17 Oct 2017 22:04:45 +0300 Subject: [PATCH] Fix deploy (#2337) * Work on deploy Set strict mode for bash files Drop non-aiohttp wheels from dist * Make tests pass --- .travis.yml | 1 - requirements/ci-wheel.txt | 23 +++++++++++++++++++++++ requirements/ci.txt | 24 +----------------------- tests/test_worker.py | 16 ++++++++++------ tools/build-wheels.sh | 6 ++++++ tools/run_docker.sh | 6 +++++- 6 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 requirements/ci-wheel.txt diff --git a/.travis.yml b/.travis.yml index 5815d09eb43..62080153bd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -77,7 +77,6 @@ jobs: - docker script: - ./tools/run_docker.sh "aiohttp" - - find dist -not -name "*aiohttp*" -delete deploy: provider: pypi # `skip_cleanup: true` is required to preserve binary wheels, built diff --git a/requirements/ci-wheel.txt b/requirements/ci-wheel.txt new file mode 100644 index 00000000000..7bd971fb4b0 --- /dev/null +++ b/requirements/ci-wheel.txt @@ -0,0 +1,23 @@ +pip==9.0.1 +flake8==3.4.1 +pyflakes==1.6.0 +coverage==4.4.1 +cchardet==2.1.1 +cython==0.27.1 +chardet==3.0.4 +isort==4.2.15 +tox==2.9.1 +multidict==3.3.0 +async-timeout==2.0.0 +pytest==3.2.3 +pytest-cov==2.5.1 +pytest-mock==1.6.3 +gunicorn==19.7.1 +twine==1.9.1 +yarl==0.13.0 +brotlipy==0.7.0 + +# Using PEP 508 env markers to control dependency on runtimes: +aiodns==1.1.1; platform_system!="Windows" # required c-ares will not build on windows +codecov==2.0.9; platform_system!="Windows" # We only use it in Travis CI +uvloop==0.8.1; python_version>="3.5" and platform_system!="Windows" # MagicStack/uvloop#14 diff --git a/requirements/ci.txt b/requirements/ci.txt index 016259ed566..71b4d6eb269 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,27 +1,5 @@ setuptools-git==1.2 -r doc.txt -pip==9.0.1 -flake8==3.4.1 -pyflakes==1.6.0 -coverage==4.4.1 -cchardet==2.1.1 -cython==0.27.1 -chardet==3.0.4 -isort==4.2.15 -tox==2.9.1 -multidict==3.3.0 -async-timeout==2.0.0 -pytest==3.2.3 -pytest-cov==2.5.1 -pytest-mock==1.6.3 -gunicorn==19.7.1 -twine==1.9.1 -yarl==0.13.0 -brotlipy==0.7.0 +-r ci-wheel.txt -e . - -# Using PEP 508 env markers to control dependency on runtimes: -aiodns==1.1.1; platform_system!="Windows" # required c-ares will not build on windows -codecov==2.0.9; platform_system!="Windows" # We only use it in Travis CI -uvloop==0.8.1; python_version>="3.5" and platform_system!="Windows" # MagicStack/uvloop#14 diff --git a/tests/test_worker.py b/tests/test_worker.py index 88f0b4a4d85..48b3bc991c7 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -1,5 +1,6 @@ """Tests for aiohttp/worker.py""" import asyncio +import os import pathlib import socket import ssl @@ -217,8 +218,9 @@ def test__run_ok(worker, loop): yield from worker._run() worker.notify.assert_called_with() - worker.log.info.assert_called_with("Parent changed, shutting down: %s", - worker) + if os.getppid() != 1: # not Docker + worker.log.info.assert_called_with("Parent changed, shutting down: %s", + worker) args, kwargs = loop.create_server.call_args assert 'ssl' in kwargs @@ -257,8 +259,9 @@ def test__run_ok_unix_socket(worker, loop): yield from worker._run() worker.notify.assert_called_with() - worker.log.info.assert_called_with("Parent changed, shutting down: %s", - worker) + if os.getppid() != 1: # not Docker + worker.log.info.assert_called_with("Parent changed, shutting down: %s", + worker) args, kwargs = loop.create_unix_server.call_args assert 'ssl' in kwargs @@ -374,8 +377,9 @@ def test__run_ok_no_max_requests(worker, loop): yield from worker._run() worker.notify.assert_called_with() - worker.log.info.assert_called_with("Parent changed, shutting down: %s", - worker) + if os.getppid() != 1: # not Docker + worker.log.info.assert_called_with("Parent changed, shutting down: %s", + worker) args, kwargs = loop.create_server.call_args assert 'ssl' in kwargs diff --git a/tools/build-wheels.sh b/tools/build-wheels.sh index 447a62514f1..f1367f674d2 100755 --- a/tools/build-wheels.sh +++ b/tools/build-wheels.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -e + PYTHON_VERSIONS="cp34-cp34m cp35-cp35m cp36-cp36m" # Avoid creation of __pycache__/*.py[c|o] @@ -42,6 +44,10 @@ for PYTHON in ${PYTHON_VERSIONS}; do echo echo -n "Test $PYTHON: " /opt/python/${PYTHON}/bin/python -c "import platform;print(platform.platform())" + /opt/python/${PYTHON}/bin/pip install -r /io/requirements/ci-wheel.txt /opt/python/${PYTHON}/bin/pip install "$package_name" --no-index -f file:///io/dist /opt/python/${PYTHON}/bin/py.test /io/tests + + # clear python cache + find /io -name __pycache__ | xargs rm -rf done diff --git a/tools/run_docker.sh b/tools/run_docker.sh index bbc505fa766..2ed64053c44 100755 --- a/tools/run_docker.sh +++ b/tools/run_docker.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -e + package_name="$1" if [ -z "$package_name" ] then @@ -17,7 +19,7 @@ do done echo Creating dist folder with privileges of host-machine user -mkdir dist # This is required to be created with host-machine user privileges +mkdir -p dist # This is required to be created with host-machine user privileges for arch in x86_64 i686 do @@ -33,3 +35,5 @@ do dock_ext_args="" # Reset docker args, just in case done + +find dist -type f -not -name "*aiohttp*" | xargs rm -f