From ea36c7782ca03960f13e010b958a5eba56b01705 Mon Sep 17 00:00:00 2001 From: David Minarsch <david.minarsch@googlemail.com> Date: Sun, 31 Jul 2022 15:40:14 +0100 Subject: [PATCH 1/2] chore: cleans up remnants of py3.6, fixes #242 --- CONTRIBUTING.md | 2 +- README.md | 8 ++--- aea/cli/launch.py | 2 +- aea/helpers/async_utils.py | 9 ------ aea/helpers/pipe.py | 5 +--- docs/quickstart.md | 10 +++---- plugins/aea-cli-benchmark/setup.py | 2 +- plugins/aea-cli-ipfs/setup.py | 2 +- plugins/aea-ledger-cosmos/setup.py | 2 +- plugins/aea-ledger-ethereum/setup.py | 2 +- plugins/aea-ledger-fetchai/setup.py | 2 +- scripts/install.sh | 4 +-- tests/test_cli/test_run.py | 3 -- .../test_protocols/test_dialogue/test_base.py | 29 ++----------------- tox.ini | 2 +- 15 files changed, 22 insertions(+), 62 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ba894ad51..4835c39bca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ If you want to contribute, start working through the codebase, navigate to the G First, setup your environment by either using the `develop-image` or by following these steps: -- The simplest way to get setup for development on the framework is to install Python `>=3.6` and `pipenv`, then run the following: +- The simplest way to get setup for development on the framework is to install Python `>=3.7` and `pipenv`, then run the following: make new_env pipenv shell diff --git a/README.md b/README.md index e8d9a6d68a..e734f8648d 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,9 @@ This is a fork of <a href="https://github.com/fetchai/agents-aea">the original A ## Get started developing AEAs -1. Create and launch a clean virtual environment with Python 3.7 (any Python `>=` 3.6 works): +1. Create and launch a clean virtual environment with Python 3.10 (any Python `>=` 3.7 works): - pipenv --python 3.7 && pipenv shell + pipenv --python 3.10 && pipenv shell 2. Install the package from [PyPI](https://pypi.org/project/open-aea/): @@ -96,9 +96,9 @@ You can have more control on the installed dependencies by leveraging the setupt ### Preliminaries -- Create and launch a virtual environment with Python 3.7 (any Python `>=` 3.6 works): +- Create and launch a virtual environment with Python 3.10 (any Python `>=` 3.7 works): - pipenv --python 3.7 && pipenv shell + pipenv --python 3.10 && pipenv shell - Install the package from source: diff --git a/aea/cli/launch.py b/aea/cli/launch.py index 96d4b5a12b..120d246b98 100644 --- a/aea/cli/launch.py +++ b/aea/cli/launch.py @@ -76,7 +76,7 @@ def _launch_agents( try: """ - run in threaded mode and wait for thread finished cause issue with python 3.6/3.7 on windows + run in threaded mode and wait for thread finished cause issue with python 3.7 on windows probably keyboard interrupt exception gets lost in executor pool or in asyncio module """ launcher.start(threaded=True) diff --git a/aea/helpers/async_utils.py b/aea/helpers/async_utils.py index 4856f54d0c..5f04fe8753 100644 --- a/aea/helpers/async_utils.py +++ b/aea/helpers/async_utils.py @@ -44,15 +44,6 @@ ) -try: - from asyncio import create_task # pylint: disable=ungrouped-imports,unused-import -except ImportError: # pragma: no cover - # for python3.6! - from asyncio import ( # type: ignore # noqa: F401 # pylint: disable=ungrouped-imports,unused-import - ensure_future as create_task, - ) - - _default_logger = logging.getLogger(__file__) diff --git a/aea/helpers/pipe.py b/aea/helpers/pipe.py index 6e4bb4b617..0716a77168 100644 --- a/aea/helpers/pipe.py +++ b/aea/helpers/pipe.py @@ -325,10 +325,7 @@ async def close(self) -> None: self._writer.write_eof() await self._writer.drain() self._writer.close() - wait_closed = getattr(self._writer, "wait_closed", None) - if wait_closed: - # in py3.6 writer does not have the coroutine - await wait_closed() # pragma: nocover + self._writer.wait_closed() class TCPSocketChannel(IPCChannel): diff --git a/docs/quickstart.md b/docs/quickstart.md index cf4d5c2373..572cfc058a 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -3,7 +3,7 @@ The AEA framework can be used on `Windows`, `Ubuntu/Debian` and `MacOS`. There are a number of base requirements to be installed prior to usage. -You need <a href="https://www.python.org/downloads/" target="_blank">Python 3.6</a> or higher as well as <a href="https://go.dev/dl/" target="_blank">Go 1.14.2</a> or higher installed. +You need <a href="https://www.python.org/downloads/" target="_blank">Python 3.7</a> or higher as well as <a href="https://go.dev/dl/" target="_blank">Go 1.14.2</a> or higher installed. GCC installation is required: @@ -35,9 +35,9 @@ python3 --version <li>Ubuntu/Debian systems only: install Python headers, depending on the Python version you have installed on your machine. - E.g. for Python 3.8: + E.g. for Python 3.10: ``` bash -sudo apt-get install python3.8-dev +sudo apt-get install python3.10-dev ``` </li> @@ -113,10 +113,10 @@ which pipenv If you don't have it, install it. Instructions are <a href="https://pypi.org/project/pipenv/" target="_blank">here</a>. -Once installed, create a new environment and open it (here we use Python 3.8 but the AEA framework supports any Python >= 3.6). +Once installed, create a new environment and open it (here we use Python 3.10 but the AEA framework supports any Python >= 3.7). ``` bash -touch Pipfile && pipenv --python 3.8 && pipenv shell +touch Pipfile && pipenv --python 3.10 && pipenv shell ``` diff --git a/plugins/aea-cli-benchmark/setup.py b/plugins/aea-cli-benchmark/setup.py index d4eda6f9eb..24111d9c36 100755 --- a/plugins/aea-cli-benchmark/setup.py +++ b/plugins/aea-cli-benchmark/setup.py @@ -45,10 +45,10 @@ "Operating System :: MacOS", "Operating System :: Microsoft", "Operating System :: Unix", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development", diff --git a/plugins/aea-cli-ipfs/setup.py b/plugins/aea-cli-ipfs/setup.py index 58f1a17491..60f0b99a84 100755 --- a/plugins/aea-cli-ipfs/setup.py +++ b/plugins/aea-cli-ipfs/setup.py @@ -45,10 +45,10 @@ "Operating System :: MacOS", "Operating System :: Microsoft", "Operating System :: Unix", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development", diff --git a/plugins/aea-ledger-cosmos/setup.py b/plugins/aea-ledger-cosmos/setup.py index 2f2231aae3..7f402d10f6 100644 --- a/plugins/aea-ledger-cosmos/setup.py +++ b/plugins/aea-ledger-cosmos/setup.py @@ -54,10 +54,10 @@ "Operating System :: MacOS", "Operating System :: Microsoft", "Operating System :: Unix", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development", diff --git a/plugins/aea-ledger-ethereum/setup.py b/plugins/aea-ledger-ethereum/setup.py index 30bef26f86..4875ef6de1 100644 --- a/plugins/aea-ledger-ethereum/setup.py +++ b/plugins/aea-ledger-ethereum/setup.py @@ -53,10 +53,10 @@ "Operating System :: MacOS", "Operating System :: Microsoft", "Operating System :: Unix", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development", diff --git a/plugins/aea-ledger-fetchai/setup.py b/plugins/aea-ledger-fetchai/setup.py index b032dee975..baf167e0c9 100644 --- a/plugins/aea-ledger-fetchai/setup.py +++ b/plugins/aea-ledger-fetchai/setup.py @@ -59,10 +59,10 @@ "Operating System :: MacOS", "Operating System :: Microsoft", "Operating System :: Unix", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", "Topic :: Communications", "Topic :: Internet", "Topic :: Software Development", diff --git a/scripts/install.sh b/scripts/install.sh index a8263b19d4..ba806ee255 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -27,9 +27,9 @@ function is_python_version_ok() { if which python3 2>&1 >/dev/null; then version=`python3 -V 2>/dev/null` - if [[ -z `echo $version|grep -E 'Python 3\.[(6789]\.[0-9]+'` ]]; + if [[ -z `echo $version|grep -E 'Python 3\.[(78910]\.[0-9]+'` ]]; then - echo "Python3 version: ${version} is not supported. Supported versions are 3.6, 3.7, 3.8." + echo "Python3 version: ${version} is not supported. Supported versions are 3.7, 3.8, 3.9, 3.10." return 1 fi return 0 diff --git a/tests/test_cli/test_run.py b/tests/test_cli/test_run.py index 5cdeee3e49..5e1b4c1e39 100644 --- a/tests/test_cli/test_run.py +++ b/tests/test_cli/test_run.py @@ -176,9 +176,6 @@ def test_run(password_or_none): @pytest.mark.flaky(reruns=MAX_FLAKY_RERUNS) # flaky on Windows -@pytest.mark.skip( - reason="cannot run on 3.6 as AttributeError: 'functools._lru_list_elem' object has no attribute '__class__'", -) def test_run_with_profiling(): """Test profiling data showed.""" runner = CliRunner() diff --git a/tests/test_protocols/test_dialogue/test_base.py b/tests/test_protocols/test_dialogue/test_base.py index fadcae5563..72f2a674de 100644 --- a/tests/test_protocols/test_dialogue/test_base.py +++ b/tests/test_protocols/test_dialogue/test_base.py @@ -19,14 +19,11 @@ # ------------------------------------------------------------------------------ """This module contains the tests for the dialogue/base.py module.""" import re -import sys from typing import FrozenSet, Tuple, Type, cast -from unittest import mock from unittest.mock import Mock, patch import pytest -import aea from aea.common import Address from aea.configurations.base import PublicId from aea.exceptions import AEAEnforceError @@ -142,12 +139,8 @@ def role_from_first_message( # pylint: disable=unused-argument ) -@pytest.mark.skipif( - sys.version_info < (3, 7), - reason="This part of code is only defined for python version >= 3.7", -) -def test_dialogue_message_python_3_7(): - """Test DiallogueMessage if python is 3.7""" +def test_dialogue_message_python(): + """Test DiallogueMessage.""" dialogue_message = DialogueMessage(DefaultMessage.Performative.BYTES) assert isinstance(dialogue_message.performative, Message.Performative) @@ -157,24 +150,6 @@ def test_dialogue_message_python_3_7(): assert dialogue_message.target is None -@pytest.mark.skipif( - sys.version_info >= (3, 7), - reason="This part of code is only defined for python version < 3.7", -) -def test_dialogue_message_python_3_6(): - """Test DiallogueMessage if python is 3.6""" - with mock.patch.object( - aea.protocols.dialogue.base.sys, "version_info", return_value=(3, 6) - ): - dialogue_message = DialogueMessage(DefaultMessage.Performative.BYTES) - assert isinstance(dialogue_message.performative, Message.Performative) - - assert dialogue_message.performative == DefaultMessage.Performative.BYTES - assert dialogue_message.contents == {} - assert dialogue_message.is_incoming is None - assert dialogue_message.target is None - - class TestDialogueLabel: """Test for DialogueLabel.""" diff --git a/tox.ini b/tox.ini index 1900b98599..bb04eeb0a6 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ ; we set the associated flag (e.g. for linting we don't need ; the package installation). [tox] -envlist = bandit, black, black-check, isort, isort-check, copyright_check, docs, flake8, liccheck, mypy, py{3.6,3.7,3.8,3.9}, dependencies_check, plugins_deps +envlist = bandit, black, black-check, isort, isort-check, copyright_check, docs, flake8, liccheck, mypy, py{3.7,3.8,3.9}, dependencies_check, plugins_deps [testenv] From c7bd0041c35accea8be9dc4cc0bd8043aee21673 Mon Sep 17 00:00:00 2001 From: David Minarsch <david.minarsch@googlemail.com> Date: Sun, 31 Jul 2022 16:36:56 +0100 Subject: [PATCH 2/2] fix: various failures --- scripts/install.sh | 2 +- tests/test_docs/test_bash_yaml/md_files/bash-quickstart.md | 4 ++-- tox.ini | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index ba806ee255..de3671fc6b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -27,7 +27,7 @@ function is_python_version_ok() { if which python3 2>&1 >/dev/null; then version=`python3 -V 2>/dev/null` - if [[ -z `echo $version|grep -E 'Python 3\.[(78910]\.[0-9]+'` ]]; + if [[ -z `echo $version|grep -E 'Python 3\.(7|8|9|10)\.[0-9]+'` ]]; then echo "Python3 version: ${version} is not supported. Supported versions are 3.7, 3.8, 3.9, 3.10." return 1 diff --git a/tests/test_docs/test_bash_yaml/md_files/bash-quickstart.md b/tests/test_docs/test_bash_yaml/md_files/bash-quickstart.md index 418e5524ce..16a30bb208 100644 --- a/tests/test_docs/test_bash_yaml/md_files/bash-quickstart.md +++ b/tests/test_docs/test_bash_yaml/md_files/bash-quickstart.md @@ -29,7 +29,7 @@ mkdir my_aea_projects/ && cd my_aea_projects/ which pipenv ``` ``` bash -touch Pipfile && pipenv --python 3.8 && pipenv shell +touch Pipfile && pipenv --python 3.10 && pipenv shell ``` ``` bash svn export https://github.com/valory-xyz/open-aea.git/trunk/examples @@ -48,7 +48,7 @@ svn checkout https://github.com/valory-xyz/open-aea/tags/v1.14.0/packages packag ``` ``` bash -sudo apt-get install python3.7-dev +sudo apt-get install python3.10-dev ``` ``` bash aea init --remote diff --git a/tox.ini b/tox.ini index bb04eeb0a6..bb43896dce 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ ; we set the associated flag (e.g. for linting we don't need ; the package installation). [tox] -envlist = bandit, black, black-check, isort, isort-check, copyright_check, docs, flake8, liccheck, mypy, py{3.7,3.8,3.9}, dependencies_check, plugins_deps +envlist = bandit, black, black-check, isort, isort-check, copyright_check, docs, flake8, liccheck, mypy, py{3.7,3.8,3.9,3.10}, dependencies_check, plugins_deps [testenv]