From e6ebea70e6fc45170ba09a030ecbd454c75a78a4 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Tue, 5 Mar 2024 22:04:29 -0500 Subject: [PATCH 1/5] Updated test libraries --- pyof/foundation/base.py | 12 ++--- pyof/foundation/basic_types.py | 1 + pyof/v0x01/common/flow_match.py | 2 +- requirements/dev.txt | 94 +++++++++++++-------------------- setup.py | 26 ++++----- 5 files changed, 56 insertions(+), 79 deletions(-) diff --git a/pyof/foundation/base.py b/pyof/foundation/base.py index 6692b7c52..b52fb83b8 100644 --- a/pyof/foundation/base.py +++ b/pyof/foundation/base.py @@ -281,10 +281,10 @@ class MetaStruct(type): # pylint: disable=unused-argument @classmethod - def __prepare__(cls, name, bases, **kwargs): + def __prepare__(mcs, name, bases, **kwargs): return OrderedDict() - def __new__(cls, name, bases, classdict, **kwargs): + def __new__(mcs, name, bases, classdict, **kwargs): """Inherit attributes from parent class and update their versions. Here is the moment that the new class is going to be created. During @@ -330,7 +330,7 @@ class and place them as class attributes on the class being created. curr_version) if attr_name == 'header': - attr = cls._header_message_type_update(obj, attr) + attr = mcs._header_message_type_update(obj, attr) inherited_attributes.update([attr]) #: We are going to inherit just from the 'closest parent' @@ -350,7 +350,7 @@ class and place them as class attributes on the class being created. inherited_attributes.update(classdict) classdict = inherited_attributes - return super().__new__(cls, name, bases, classdict, **kwargs) + return super().__new__(mcs, name, bases, classdict, **kwargs) @staticmethod def _header_message_type_update(obj, attr): @@ -864,7 +864,7 @@ class MetaBitMask(type): access object.ELEMENT and recover either values or names). """ - def __new__(cls, name, bases, classdict): + def __new__(mcs, name, bases, classdict): """Convert class attributes into enum elements.""" _enum = OrderedDict([(key, value) for key, value in classdict.items() if key[0] != '_' and not @@ -875,7 +875,7 @@ def __new__(cls, name, bases, classdict): if key[0] == '_' or hasattr(value, '__call__') or isinstance(value, property)} classdict['_enum'] = _enum - return type.__new__(cls, name, bases, classdict) + return type.__new__(mcs, name, bases, classdict) def __getattr__(cls, name): return cls._enum[name] diff --git a/pyof/foundation/basic_types.py b/pyof/foundation/basic_types.py index ca760b66f..dc7d6892b 100644 --- a/pyof/foundation/basic_types.py +++ b/pyof/foundation/basic_types.py @@ -248,6 +248,7 @@ def unpack(self, buff, offset=0): end = begin + self.length unpacked_data = struct.unpack(self._fmt, buff[begin:end])[0] except struct.error: + # pylint: disable=broad-exception-raised raise Exception("%s: %s" % (offset, buff)) self._value = unpacked_data.decode('ascii').rstrip('\0') diff --git a/pyof/v0x01/common/flow_match.py b/pyof/v0x01/common/flow_match.py index c5ecf87b8..fff59ee56 100644 --- a/pyof/v0x01/common/flow_match.py +++ b/pyof/v0x01/common/flow_match.py @@ -57,7 +57,7 @@ class FlowWildCards(GenericBitMask): OFPFW_NW_TOS = 1 << 21 #: Wildcard all fields. - OFPFW_ALL = ((1 << 22) - 1) + OFPFW_ALL = (1 << 22) - 1 # Classes diff --git a/requirements/dev.txt b/requirements/dev.txt index 55864d251..eb047acef 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,8 +1,8 @@ # -# This file is autogenerated by pip-compile with Python 3.9 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --output-file=requirements/dev.txt --resolver=backtracking requirements/dev.in +# pip-compile --output-file=requirements/dev.txt requirements/dev.in # -e git+https://github.com/kytos/sphinx-theme.git#egg=kytos-sphinx-theme # via -r requirements/dev.in @@ -10,71 +10,70 @@ # via -r requirements/dev.in alabaster==0.7.13 # via sphinx -astroid==2.13.5 +astroid==3.1.0 # via pylint -attrs==23.1.0 - # via pytest babel==2.12.1 # via sphinx -black==23.3.0 +black==24.2.0 # via python-openflow build==0.10.0 # via pip-tools -certifi==2022.12.7 +cachetools==5.3.3 + # via tox +certifi==2024.2.2 # via requests -charset-normalizer==3.1.0 +chardet==5.2.0 + # via tox +charset-normalizer==3.3.2 # via requests -click==8.1.3 +click==8.1.7 # via # black # pip-tools colorama==0.4.6 - # via sphinx-autobuild + # via + # sphinx-autobuild + # tox coverage[toml]==7.2.5 # via pytest-cov dill==0.3.6 # via pylint -distlib==0.3.6 +distlib==0.3.8 # via virtualenv docopt==0.6.2 # via yala docutils==0.19 # via sphinx -exceptiongroup==1.1.1 - # via pytest -filelock==3.12.0 +filelock==3.13.1 # via # tox # virtualenv -idna==3.4 +idna==3.6 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.6.0 - # via sphinx iniconfig==2.0.0 # via pytest -isort==5.12.0 +isort==5.13.2 # via # pylint # python-openflow # yala -jinja2==3.1.2 +jinja2==3.1.3 # via sphinx -lazy-object-proxy==1.9.0 - # via astroid livereload==2.6.3 # via sphinx-autobuild -markupsafe==2.1.2 +markupsafe==2.1.5 # via jinja2 mccabe==0.7.0 # via pylint mypy-extensions==1.0.0 # via black -packaging==23.1 +packaging==23.2 # via # black # build + # pyproject-api # pytest # sphinx # tox @@ -82,44 +81,43 @@ pathspec==0.11.1 # via black pip-tools==6.13.0 # via python-openflow -platformdirs==3.5.0 +platformdirs==4.2.0 # via # black # pylint + # tox # virtualenv -pluggy==1.0.0 +pluggy==1.4.0 # via # pytest # tox -py==1.11.0 - # via tox -pycodestyle==2.10.0 +pycodestyle==2.11.1 # via # python-openflow # yala pygments==2.15.1 # via sphinx -pylint==2.15.0 +pylint==3.1.0 # via # python-openflow # yala +pyproject-api==1.6.1 + # via tox pyproject-hooks==1.0.0 # via build -pytest==7.2.1 +pytest==8.0.1 # via # pytest-asyncio # pytest-cov # python-openflow -pytest-asyncio==0.20.3 +pytest-asyncio==0.23.5 # via python-openflow -pytest-cov==4.0.0 +pytest-cov==4.1.0 # via python-openflow -requests==2.29.0 +requests==2.31.0 # via sphinx six==1.16.0 - # via - # livereload - # tox + # via livereload snowballstemmer==2.2.0 # via sphinx sphinx==7.0.0 @@ -140,40 +138,22 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -tomli==2.0.1 - # via - # black - # build - # coverage - # pylint - # pyproject-hooks - # pytest - # tox tomlkit==0.11.8 # via pylint tornado==6.3.1 # via livereload -tox==3.28.0 +tox==4.13.0 # via python-openflow -typing-extensions==4.5.0 - # via - # astroid - # black - # pylint -urllib3==1.26.15 +urllib3==1.26.18 # via requests -virtualenv==20.21.0 +virtualenv==20.25.1 # via # python-openflow # tox wheel==0.40.0 # via pip-tools -wrapt==1.15.0 - # via astroid yala==3.2.0 # via python-openflow -zipp==3.15.0 - # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/setup.py b/setup.py index 1bd713a3b..f8cd86c8a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ # Disabling checks due to https://github.com/PyCQA/pylint/issues/73 # pylint: disable=import-error,no-name-in-module,unspecified-encoding # pylint: disable=consider-using-with -from distutils.command.clean import clean # pylint: enable=import-error,no-name-in-module from subprocess import CalledProcessError, call, check_call @@ -69,17 +68,14 @@ def finalize_options(self): pass -class Cleaner(clean): +class Cleaner(SimpleCommand): """Custom clean command to tidy up the project root.""" description = 'clean build, dist, pyc and egg from package and docs' def run(self): """Clean build, dist, pyc and egg from package and docs.""" - super().run() - call('rm -vrf ./build ./dist ./*.pyc ./*.egg-info', shell=True) - call('find . -name __pycache__ -type d | xargs rm -rf', shell=True) - call('test -d docs && make -C docs/ clean', shell=True) + call('make clean', shell=True) class Test(TestCommand): @@ -153,16 +149,16 @@ def run(self): include_package_data=True, extras_require={'dev': [ 'pip-tools >= 2.0', - 'pytest==7.2.1', - 'pytest-cov==4.0.0', - 'pytest-asyncio==0.20.3', - 'black==23.3.0', - 'isort==5.12.0', - 'pylint==2.15.0', - 'pycodestyle==2.10.0', + 'pytest==8.0.1', + 'pytest-cov==4.1.0', + 'pytest-asyncio==0.23.5', + 'black==24.2.0', + 'isort==5.13.2', + 'pylint==3.1.0', + 'pycodestyle==2.11.1', 'yala==3.2.0', - 'tox==3.28.0', - 'virtualenv==20.21.0' + 'tox==4.13.0', + 'virtualenv==20.25.1', ]}, packages=find_packages(exclude=['tests']), cmdclass={ From a1490a23eab15b7b0bafc4050501c6811b9d9035 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Tue, 5 Mar 2024 22:41:52 -0500 Subject: [PATCH 2/5] Updated python --- .github/workflows/pythonpublish.yml | 2 +- .github/workflows/unittest.yml | 2 +- .scrutinizer.yml | 4 ++-- CHANGELOG.rst | 5 +++++ README.rst | 2 +- setup.py | 2 +- tox.ini | 4 ++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 467bf5a58..2aefacc1d 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -12,7 +12,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: '3.6' + python-version: '3.11' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index 3258d9126..29af7bec8 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9] + python-version: [3.11] steps: - uses: actions/checkout@v1 diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 26976caa5..dd57adfa2 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -6,7 +6,7 @@ filter: paths: ["pyof/*", "tests/*"] build: environment: - python: 3.9.12 + python: 3.11.8 postgresql: false redis: false dependencies: @@ -18,7 +18,7 @@ build: override: - command: 'tox' - only_if: 'tox -a | grep -q py39' + only_if: 'tox -a | grep -q py311' idle_timeout: 300 coverage: file: '.coverage' diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ff02d81d..460e56a78 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,11 @@ All notable changes to the `python-openflow` project are documented in this file [UNRELEASED] - Under development ******************************** +Changed +======= +- Updated python environment installation from 3.9 to 3.11 +- Updated test dependencies + [2023.1.0] - 2023-06-05 *********************** diff --git a/README.rst b/README.rst index 0df51c8ff..121efc317 100644 --- a/README.rst +++ b/README.rst @@ -29,7 +29,7 @@ Quick Start Installing ========== -In order to use this software please install python3.9 into your +In order to use this software please install python3.11 into your environment beforehand. We are doing a huge effort to make Kytos and its components available on all diff --git a/setup.py b/setup.py index f8cd86c8a..5c456af84 100644 --- a/setup.py +++ b/setup.py @@ -172,7 +172,7 @@ def run(self): classifiers=[ 'License :: OSI Approved :: MIT License', 'Operating System :: POSIX :: Linux', - 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.11', 'Topic :: System :: Networking', 'Topic :: Software Development :: Libraries' ]) diff --git a/tox.ini b/tox.ini index 78d67b2c6..6aabae8a4 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,9 @@ [tox] -envlist = py39,coverage,lint +envlist = py311,coverage,lint [gh-actions] python = - 3.9: py39 + 3.11: py311 [testenv] whitelist_externals= From 2e46c574e4dd0ac56be259da00e245bba7540768 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Wed, 6 Mar 2024 01:32:52 -0500 Subject: [PATCH 3/5] Updated tox --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 6aabae8a4..f845a0ea4 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ python = 3.11: py311 [testenv] -whitelist_externals= +allowlist_externals= rm make From ade8771c63495804af00111ff7a34f7ac559679f Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Tue, 19 Mar 2024 14:56:56 -0400 Subject: [PATCH 4/5] Delete scrutinizer.yml --- .scrutinizer.yml | 27 --------------------------- CHANGELOG.rst | 5 +++++ 2 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index dd57adfa2..000000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,27 +0,0 @@ -checks: - python: - code_rating: true - duplicate_code: true -filter: - paths: ["pyof/*", "tests/*"] -build: - environment: - python: 3.11.8 - postgresql: false - redis: false - dependencies: - override: - - true - tests: - before: - - pip install coverage - override: - - - command: 'tox' - only_if: 'tox -a | grep -q py311' - idle_timeout: 300 - coverage: - file: '.coverage' - config_file: '.coveragerc' - format: 'py-cc' - - py-scrutinizer-run diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 460e56a78..a512f8316 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,11 @@ Changed - Updated python environment installation from 3.9 to 3.11 - Updated test dependencies +[2023.2.0] - 2024-02-16 +*********************** + +No major changes since the last release. + [2023.1.0] - 2023-06-05 *********************** From 0d0600cf8fd2f6277fc976a5b9b5d3766c586d28 Mon Sep 17 00:00:00 2001 From: Aldo Ortega Date: Thu, 28 Mar 2024 10:15:26 -0400 Subject: [PATCH 5/5] Updated readme --- README.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 121efc317..fce1ecb2c 100644 --- a/README.rst +++ b/README.rst @@ -51,15 +51,17 @@ procedure: .. code-block:: shell $ cd python-openflow - $ sudo python3 setup.py install + $ sudo python3 -m pip install . Alternatively, if you are a developer and want to install in develop mode: .. code-block:: shell $ cd python-openflow - $ pip3 install -r requirements/dev.txt + $ python3 -m pip install --editable . +To install the kytos environment, please follow our +`development environment setup `_. Basic Usage Example ===================