diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..ff22092 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,77 @@ +name: Python package + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + - name: Lint with flake8 + run: | + pip install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: + - "pypy:2.7" + - "pypy:3.5" + - "pypy:3.6" + - "pypy:3.7" + - "pypy:3.8" + - "pypy:3.9" + - "pypy:3.10" + - "python:2.7" + - "python:3.2" + - "python:3.3" + - "python:3.4" + - "python:3.5" + - "python:3.6" + - "python:3.7" + - "python:3.8" + - "python:3.9" + - "python:3.10" + - "python:3.11" + - "python:3.12" + container: ${{ matrix.image }}-slim + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: | + # pip install --upgrade pip + command -v python3.2 && export PYTEST_VERSION='<3' + pip install pytest$PYTEST_VERSION pycountry==1.11 + pip install -e . + - name: Test with pytest + run: | + py.test + test-py26: + runs-on: ubuntu-latest + container: centos:6 + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: | + # sed -i '/^mirrorlist/s/^/#/;/^#baseurl/{s/#//;s/mirror.centos.org/vault.centos.org/}' /etc/yum.repos.d/*B* + # yum clean all + # yum upgrade -y + # yum install -y epel-release + curl https://pylegacy.org/hub/get-pip-pyopenssl.py | python + pip install unittest2 pytest pycountry==1.11 + pip install -e . + - name: Test with pytest + run: | + py.test diff --git a/README.rst b/README.rst index f07c310..8c4db8a 100644 --- a/README.rst +++ b/README.rst @@ -11,7 +11,7 @@ Status License ------- -GNU Affero General Public License version 3 (AGPLv3) +GNU Affero General Public License version 3.0 only (AGPL-3.0-only) Supports -------- diff --git a/examples/logic.py b/examples/logic.py index fc8bb44..5b34f43 100644 --- a/examples/logic.py +++ b/examples/logic.py @@ -1,8 +1,8 @@ """ Python library for ISO 639 standard -Copyright (c) 2014 Mikael Karlsson (CSC - IT Center for Science Ltd.). -Licensed under AGPLv3. +Copyright (c) 2014-2024 Mikael Karlsson (CSC - IT Center for Science Ltd.). +Licensed under AGPL-3.0-only. """ import re diff --git a/iso639/__init__.py b/iso639/__init__.py index e6777c9..b3ec62d 100644 --- a/iso639/__init__.py +++ b/iso639/__init__.py @@ -1,8 +1,8 @@ """ Python library for ISO 639 standard -Copyright (c) 2014-2016 Mikael Karlsson (CSC - IT Center for Science Ltd.). -Licensed under AGPLv3. +Copyright (c) 2014-2024 Mikael Karlsson (CSC - IT Center for Science Ltd.). +Licensed under AGPL-3.0-only. """ from __future__ import absolute_import diff --git a/iso639/iso639.py b/iso639/iso639.py index f66ec1c..bffcd93 100644 --- a/iso639/iso639.py +++ b/iso639/iso639.py @@ -2,8 +2,8 @@ """ Python library for ISO 639 standard -Copyright (c) 2014-2016 Mikael Karlsson (CSC - IT Center for Science Ltd.). -Licensed under AGPLv3. +Copyright (c) 2014-2024 Mikael Karlsson (CSC - IT Center for Science Ltd.). +Licensed under AGPL-3.0-only. """ # Fix for Python 3.0 - 3.2 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..85efa54 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +doctest_optionflags = ALLOW_UNICODE ALLOW_BYTES +testpaths = tests/tests.py README.rst diff --git a/setup.py b/setup.py index 9bf77c4..df9557f 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ """ Python library for ISO 639 standard -Copyright (c) 2014-2017 Mikael Karlsson (CSC - IT Center for Science Ltd.). -Licensed under AGPLv3. +Copyright (c) 2014-2024 Mikael Karlsson (CSC - IT Center for Science Ltd.). +Licensed under AGPL-3.0-only. """ import sys @@ -40,6 +40,12 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', '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', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Text Processing :: Linguistic', diff --git a/tests/tests.py b/tests/tests.py index 1f22e71..e942841 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,18 +2,22 @@ """ Python library for ISO 639 standard -Copyright (c) 2014-2016 Mikael Karlsson (CSC - IT Center for Science Ltd.). -Licensed under AGPLv3. +Copyright (c) 2014-2024 Mikael Karlsson (CSC - IT Center for Science Ltd.). +Licensed under AGPL-3.0-only. """ import sys -import collections if sys.version_info[0:2] == (2, 6): import unittest2 as unittest else: import unittest +if sys.version_info[0] == 3 and sys.version_info[1] > 2: + from collections.abc import Iterable, Iterator +else: + from collections import Iterable, Iterator + from iso639 import Iso639, languages from examples.logic import map_language from pycountry import languages as pclanguages @@ -112,8 +116,8 @@ def test_len(self): self.assertEqual(len(languages), 7981) def test_iter(self): - self.assertIsInstance(languages, collections.Iterable) - self.assertIsInstance(iter(languages), collections.Iterator) + self.assertIsInstance(languages, Iterable) + self.assertIsInstance(iter(languages), Iterator) def test_exceptions(self): self.assertRaises(KeyError, languages.get, part1='En') # Wrong value