From ff8f46a57a5d5ac9228d31c3286f50f94196363b Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 00:25:01 +0100 Subject: [PATCH 01/21] migrate package config to setup.cfg --- setup.cfg | 43 ++++++++++++++++++++++ setup.py | 70 ++---------------------------------- src/flightplandb/VERSION | 1 + src/flightplandb/__init__.py | 4 ++- 4 files changed, 50 insertions(+), 68 deletions(-) create mode 100644 setup.cfg create mode 100644 src/flightplandb/VERSION diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..0a5c00f --- /dev/null +++ b/setup.cfg @@ -0,0 +1,43 @@ +[metadata] +name = flightplandb +version=file: src/flightplandb/VERSION +author = PH-KDX +url = https://github.com/PH-KDX/flightplandb-py/ +project_urls = + Documentation = https://flightplandb-py.readthedocs.io/ + Issue tracker = https://github.com/PH-KDX/flightplandb-py/issues + +description = Python wrapper for the Flight Plan Database API +long_description=file: README.md +long_description_content_type = text/markdown +classifiers = + License :: OSI Approved :: GNU General Public License v3 (GPLv3) + Intended Audience :: Developers + Natural Language :: English + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.10 + Operating System :: OS Independent + Topic :: Internet + Topic :: Software Development :: Libraries + Topic :: Software Development :: Libraries :: Python Modules + Topic :: Utilities + Topic :: Games/Entertainment :: Simulation + +[options] +include_package_data=True +package_dir= + =src +packages=find: +python_requires = >=3.8 +install_requires = + aiohttp~=3.8.1 + python-dateutil~=2.8.2 + +[options.packages.find] +where=src + +[options.extras_require] +dev = Sphinx==5.1.1; sphinx-rtd-theme==1.0.0 +test = pytest~=7.1.3; pytest-socket~=0.5.1; pytest-asyncio~=0.19.0 \ No newline at end of file diff --git a/setup.py b/setup.py index e460106..374f6ae 100644 --- a/setup.py +++ b/setup.py @@ -1,69 +1,5 @@ #!/usr/bin/env python -from setuptools import setup, find_packages -import codecs -import os.path +from setuptools import setup -with open("README.md", "r") as fh: - long_description = fh.read() - - -def read(rel_path): - here = os.path.abspath(os.path.dirname(__file__)) - with codecs.open(os.path.join(here, rel_path), 'r') as fp: - return fp.read() - - -def get_version(rel_path): - for line in read(rel_path).splitlines(): - if line.startswith('__version__'): - delim = '"' if '"' in line else "'" - return line.split(delim)[1] - raise RuntimeError("Unable to find version string.") - - -setup( - name="flightplandb", - version=get_version("src/flightplandb/__init__.py"), - author="PH-KDX", - url="https://github.com/PH-KDX/flightplandb-py/", - project_urls={ - "Documentation": "https://flightplandb-py.readthedocs.io/", - "Issue tracker": "https://github.com/PH-KDX/flightplandb-py/issues", - }, - description="Python wrapper for the Flight Plan Database API", - long_description=long_description, - long_description_content_type="text/markdown", - package_dir={"": "src"}, - packages=find_packages(where="src"), - include_package_data=True, - install_requires=[ - "aiohttp~=3.8.1", - "python-dateutil~=2.8.2" - ], - extras_require={ - "dev": [ - "Sphinx==5.1.1", - "sphinx-rtd-theme==1.0.0" - ], - "test": [ - "pytest~=7.1.3", - "pytest-socket~=0.5.1", - "pytest-asyncio~=0.19.0" - ] - }, - python_requires='>=3.8.0', - classifiers=[ - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Intended Audience :: Developers", - "Natural Language :: English", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Operating System :: OS Independent", - "Topic :: Internet", - "Topic :: Software Development :: Libraries", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Utilities", - "Topic :: Games/Entertainment :: Simulation" - ] -) +if __name__ == "__main__": + setup() diff --git a/src/flightplandb/VERSION b/src/flightplandb/VERSION new file mode 100644 index 0000000..5c4511c --- /dev/null +++ b/src/flightplandb/VERSION @@ -0,0 +1 @@ +0.0.7 \ No newline at end of file diff --git a/src/flightplandb/__init__.py b/src/flightplandb/__init__.py index 3415d61..25a44bb 100644 --- a/src/flightplandb/__init__.py +++ b/src/flightplandb/__init__.py @@ -10,7 +10,9 @@ # Version of the flightplandb package -__version__ = "0.7.0" +version_filepath = "src/flightplandb/VERSION" +with open(version_filepath) as version_file: + __version__ = version_file.readline() from . import ( internal, exceptions, datatypes, From 6360435cde3b022618719ee6565d3266bc005c28 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 00:43:14 +0100 Subject: [PATCH 02/21] move version location --- setup.cfg | 4 ++-- src/flightplandb/VERSION | 1 - src/flightplandb/__init__.py | 4 +--- 3 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 src/flightplandb/VERSION diff --git a/setup.cfg b/setup.cfg index 0a5c00f..1f6c4c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = flightplandb -version=file: src/flightplandb/VERSION +version=attr: flightplandb.__version__ author = PH-KDX url = https://github.com/PH-KDX/flightplandb-py/ project_urls = @@ -39,5 +39,5 @@ install_requires = where=src [options.extras_require] -dev = Sphinx==5.1.1; sphinx-rtd-theme==1.0.0 +dev = Sphinx==6.1.3; sphinx-rtd-theme==1.2.0 test = pytest~=7.1.3; pytest-socket~=0.5.1; pytest-asyncio~=0.19.0 \ No newline at end of file diff --git a/src/flightplandb/VERSION b/src/flightplandb/VERSION deleted file mode 100644 index 5c4511c..0000000 --- a/src/flightplandb/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.0.7 \ No newline at end of file diff --git a/src/flightplandb/__init__.py b/src/flightplandb/__init__.py index 25a44bb..accc7d3 100644 --- a/src/flightplandb/__init__.py +++ b/src/flightplandb/__init__.py @@ -10,9 +10,7 @@ # Version of the flightplandb package -version_filepath = "src/flightplandb/VERSION" -with open(version_filepath) as version_file: - __version__ = version_file.readline() +__version__ = "0.0.7" from . import ( internal, exceptions, datatypes, From 0aa3833fb3219ebc48d15f3e5cce1cef3d87ef4b Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 00:57:12 +0100 Subject: [PATCH 03/21] update dark colour scheme for docs --- docs/source/_static/css/colourscheme.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/_static/css/colourscheme.css b/docs/source/_static/css/colourscheme.css index a866666..33087d5 100644 --- a/docs/source/_static/css/colourscheme.css +++ b/docs/source/_static/css/colourscheme.css @@ -3049,10 +3049,10 @@ } html.writer-html4 .rst-content dl:not(.docutils) > dt, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) > dt { - background-color: rgb(32, 35, 36); + background-color: rgb(32, 35, 36) !important; background-image: none; - color: rgb(84, 164, 217); - border-top-color: rgb(28, 89, 128); + color: rgb(84, 164, 217) !important; + border-top-color: rgb(28, 89, 128) !important; } html.writer-html4 .rst-content dl:not(.docutils) > dt::before, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) > dt::before { @@ -3104,7 +3104,7 @@ background-color: rgb(32, 35, 36); background-image: none; } html.writer-html4 .rst-content dl:not(.docutils) .descclassname, html.writer-html4 .rst-content dl:not(.docutils) .descname, html.writer-html4 .rst-content dl:not(.docutils) .sig-name, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descclassname, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .descname, html.writer-html5 .rst-content dl[class]:not(.option-list):not(.field-list):not(.footnote):not(.glossary):not(.simple) .sig-name { - color: rgb(255, 255, 255); + color: rgb(255, 255, 255) !important; } span[id*="MathJax-Span"] { color: rgb(192, 186, 178); From 3634ea4305c996298d3fc283dee888dbc7854d93 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:11:12 +0100 Subject: [PATCH 04/21] bump dependency versions, add 3.11 test workflow --- .github/workflows/test_and_lint.yml | 2 +- setup.cfg | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test_and_lint.yml b/.github/workflows/test_and_lint.yml index 8450661..1f05d12 100644 --- a/.github/workflows/test_and_lint.yml +++ b/.github/workflows/test_and_lint.yml @@ -21,7 +21,7 @@ jobs: unittests: strategy: matrix: - python-version: [ '3.8', '3.9', '3.10'] + python-version: [ '3.8', '3.9', '3.10', '3.11'] runs-on: ubuntu-latest name: Unit tests, Python ${{ matrix.python-version }} diff --git a/setup.cfg b/setup.cfg index 1f6c4c2..e78afc6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,8 @@ package_dir= packages=find: python_requires = >=3.8 install_requires = - aiohttp~=3.8.1 + aiohttp >= 3.8.4;python_version >= '3.11' + aiohttp python-dateutil~=2.8.2 [options.packages.find] @@ -40,4 +41,4 @@ where=src [options.extras_require] dev = Sphinx==6.1.3; sphinx-rtd-theme==1.2.0 -test = pytest~=7.1.3; pytest-socket~=0.5.1; pytest-asyncio~=0.19.0 \ No newline at end of file +test = pytest~=7.2.1; pytest-socket~=0.6.0; pytest-asyncio~=0.20.3 \ No newline at end of file From 936fcf0598f10d29727621f5dca0696bb38a1d84 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:30:12 +0100 Subject: [PATCH 05/21] pin aiohttp minimum version --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index e78afc6..f9699fd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,7 +33,7 @@ packages=find: python_requires = >=3.8 install_requires = aiohttp >= 3.8.4;python_version >= '3.11' - aiohttp + aiohttp >= 3.5.2;python_version < '3.11' python-dateutil~=2.8.2 [options.packages.find] From 6a2578a3d0ecba7a078b27d62f316d3c77e49810 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:30:51 +0100 Subject: [PATCH 06/21] fix artwork path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f13b4c6..a13a4f3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- FlightPlanDB-py logo + FlightPlanDB-py logo

# FlightplanDB-py From 9e9d95cd1bb0b32a7ccafbebfb31b6013b4235fe Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:31:46 +0100 Subject: [PATCH 07/21] bump package version --- src/flightplandb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flightplandb/__init__.py b/src/flightplandb/__init__.py index accc7d3..892e9c0 100644 --- a/src/flightplandb/__init__.py +++ b/src/flightplandb/__init__.py @@ -10,7 +10,7 @@ # Version of the flightplandb package -__version__ = "0.0.7" +__version__ = "0.0.8" from . import ( internal, exceptions, datatypes, From eaa846933930d4d984188732c1203a2b456d39ee Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:37:01 +0100 Subject: [PATCH 08/21] dynamically link documented package version --- docs/source/conf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 8275bdf..f53936e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -11,6 +11,7 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. import os import sys +from flightplandb import __version__ sys.path.insert(0, os.path.abspath('../../')) @@ -21,7 +22,7 @@ author = 'PH-KDX' # The full version, including alpha/beta/rc tags -release = '0.7.0' +release = __version__ # readthedocs.io insists on the version field being filled for epub builds version = release From 0cd0314e8e74fc20dfab8b55d346f01fcce62598 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:58:47 +0100 Subject: [PATCH 09/21] move changelog to root project directory, update changelog --- CHANGELOG.rst | 21 +++++++++++++++++++++ docs/source/user/changelog.rst | 19 +++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 CHANGELOG.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..4194e34 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,21 @@ +Changelog +-------------------- + +0.7.1 +^^^^^^^^^^^^^^^^^^^^ +This is a minor update, which adds support for Python 3.11 and changes a few things with +regard to the package configuration. No breaking changes have been introduced. + +0.7.0 +^^^^^^^^^^^^^^^^^^^^ +This is another complete rewrite of the library, in which it is entirely converted to async. +This should mean faster execution of parallel requests, and no blocking when called from +another async library. Support for Python 3.7 has been dropped in this release. Python 3.11 +is not yet supported as aiohttp does not yet support Python 3.11 at the time of release. + +0.6.0 +^^^^^^^^^^^^^^^^^^^^ +This is a complete rewrite of the library, which moves functions out of classes. +This does have the side effect of requiring a key to be passed into every authenticated request, +instead of being passed into a class once on initialisation. The rewrite also incorporates +several small bugfixes, and changes the test environment from unittest to pytest. \ No newline at end of file diff --git a/docs/source/user/changelog.rst b/docs/source/user/changelog.rst index bd02e1b..a9428b5 100644 --- a/docs/source/user/changelog.rst +++ b/docs/source/user/changelog.rst @@ -1,16 +1,3 @@ -Changelog --------------------- - -0.7.0 -^^^^^^^^^^^^^^^^^^^^ -This is another complete rewrite of the library, in which it is entirely converted to async. -This should mean faster execution of parallel requests, and no blocking when called from -another async library. Support for Python 3.7 has been dropped in this release. Python 3.11 -is not yet supported as aiohttp does not yet support Python 3.11 at the time of release. - -0.6.0 -^^^^^^^^^^^^^^^^^^^^ -This is a complete rewrite of the library, which moves functions out of classes. -This does have the side effect of requiring a key to be passed into every authenticated request, -instead of being passed into a class once on initialisation. The rewrite also incorporates -several small bugfixes, and changes the test environment from unittest to pytest. \ No newline at end of file +.. include:: ../../../CHANGELOG.rst +.. + reference to changelog outside of docs directory, with thanks to https://stackoverflow.com/a/17217041 \ No newline at end of file From 8f69789c85a017589fdffa44063ec88996b222d4 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 01:59:17 +0100 Subject: [PATCH 10/21] fix package version --- src/flightplandb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flightplandb/__init__.py b/src/flightplandb/__init__.py index 892e9c0..fb1ad3a 100644 --- a/src/flightplandb/__init__.py +++ b/src/flightplandb/__init__.py @@ -10,7 +10,7 @@ # Version of the flightplandb package -__version__ = "0.0.8" +__version__ = "0.7.1" from . import ( internal, exceptions, datatypes, From 50b8e55845486ff245191bf6eddbe4427b07ae44 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 20:33:36 +0100 Subject: [PATCH 11/21] rename extra requirements for docs --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f9699fd..54dc421 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,5 +40,5 @@ install_requires = where=src [options.extras_require] -dev = Sphinx==6.1.3; sphinx-rtd-theme==1.2.0 +docs = Sphinx==6.1.3; sphinx-rtd-theme==1.2.0 test = pytest~=7.2.1; pytest-socket~=0.6.0; pytest-asyncio~=0.20.3 \ No newline at end of file From 2ce5c3c5cb7a02a51d2f1aaa6c5db489eb1583df Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 21:33:19 +0100 Subject: [PATCH 12/21] setup readthedocs config --- .readthedocs.yaml | 30 ++++++++++++++++++++++++++++++ requirements.txt | 2 -- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 .readthedocs.yaml delete mode 100644 requirements.txt diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..264bf16 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,30 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python +build: + os: ubuntu-22.04 + tools: + python: "3.11" + +# Declare the Python requirements required to build docs +python: + install: + - method: pip + path: . + extra_requirements: + - docs + +# Build documentation in the docs/ directory with Sphinx +sphinx: + builder: html + configuration: docs/conf.py + +# Build PDF & ePub +formats: + - epub + - pdf \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a259d38..0000000 --- a/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests==2.24.0 -python-dateutil==2.8.1 From 2c464dc3707f2b059650839626d45ea15045879f Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 21:39:12 +0100 Subject: [PATCH 13/21] update sphinx conf path for readthedocs --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 264bf16..4cc31c2 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -22,7 +22,7 @@ python: # Build documentation in the docs/ directory with Sphinx sphinx: builder: html - configuration: docs/conf.py + configuration: docs/source/conf.py # Build PDF & ePub formats: From 31117315834d4c2cdc0f3e828be25995e858b5a0 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 22:43:54 +0100 Subject: [PATCH 14/21] migrate to pyproject.toml --- .gitignore | 2 ++ pyproject.toml | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 44 ------------------------------------------- setup.py | 5 ----- 4 files changed, 53 insertions(+), 49 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/.gitignore b/.gitignore index d04b30e..c023e29 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,8 @@ dist docs/build +build/ + ignore/ venv diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3349dab --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,51 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "flightplandb" +authors = [ + {name = "PH-KDX", email = "smtp.python.email.sender@gmail.com"}, +] +description = "Python wrapper for the Flight Plan Database API" +readme = "README.md" +requires-python = ">=3.8" +license = {text = "GPL v3"} + +classifiers = [ + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Intended Audience :: Developers", + "Natural Language :: English", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.10", + "Operating System :: OS Independent", + "Topic :: Internet", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Utilities", + "Topic :: Games/Entertainment :: Simulation", +] +dependencies = [ + "aiohttp >= 3.8.4; python_version >= '3.11'", + "aiohttp >= 3.5.2; python_version < '3.11'", + "python-dateutil~=2.8.2", +] +dynamic = ["version"] + +[project.optional-dependencies] +docs = ["Sphinx==6.1.3", "sphinx-rtd-theme==1.2.0"] +test = ["pytest~=7.2.1", "pytest-socket~=0.6.0", "pytest-asyncio~=0.20.3"] + +[project.urls] +"Homepage" = "https://github.com/PH-KDX/flightplandb-py/" +"Documentation" = "https://flightplandb-py.readthedocs.io/" +"Issue tracker" = "https://github.com/PH-KDX/flightplandb-py/issues" +"Changelog" = "https://github.com/PH-KDX/flightplandb-py/blob/main/CHANGELOG.rst" + +[tool.setuptools.dynamic] +version = {attr = "flightplandb.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 54dc421..0000000 --- a/setup.cfg +++ /dev/null @@ -1,44 +0,0 @@ -[metadata] -name = flightplandb -version=attr: flightplandb.__version__ -author = PH-KDX -url = https://github.com/PH-KDX/flightplandb-py/ -project_urls = - Documentation = https://flightplandb-py.readthedocs.io/ - Issue tracker = https://github.com/PH-KDX/flightplandb-py/issues - -description = Python wrapper for the Flight Plan Database API -long_description=file: README.md -long_description_content_type = text/markdown -classifiers = - License :: OSI Approved :: GNU General Public License v3 (GPLv3) - Intended Audience :: Developers - Natural Language :: English - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.10 - Operating System :: OS Independent - Topic :: Internet - Topic :: Software Development :: Libraries - Topic :: Software Development :: Libraries :: Python Modules - Topic :: Utilities - Topic :: Games/Entertainment :: Simulation - -[options] -include_package_data=True -package_dir= - =src -packages=find: -python_requires = >=3.8 -install_requires = - aiohttp >= 3.8.4;python_version >= '3.11' - aiohttp >= 3.5.2;python_version < '3.11' - python-dateutil~=2.8.2 - -[options.packages.find] -where=src - -[options.extras_require] -docs = Sphinx==6.1.3; sphinx-rtd-theme==1.2.0 -test = pytest~=7.2.1; pytest-socket~=0.6.0; pytest-asyncio~=0.20.3 \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 374f6ae..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -from setuptools import setup - -if __name__ == "__main__": - setup() From 3e3834ee828f5ead33c873bcc47628657d62d536 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 23:42:40 +0100 Subject: [PATCH 15/21] remove null parameters to fix aiohttp crash --- src/flightplandb/internal.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/flightplandb/internal.py b/src/flightplandb/internal.py index 804e2f3..f2a33e3 100644 --- a/src/flightplandb/internal.py +++ b/src/flightplandb/internal.py @@ -125,9 +125,18 @@ async def request( params = {} # the API only takes "true" or "false", not True or False + # additionally, aiohttp refuses to pass in a boolean or nonetype in the params + _null_keys = [] for _key, _value in params.items(): if _value in (True, False): params[_key] = json.dumps(_value) + elif _value == None: + _null_keys.append(_key) + + # popping null keys directly when iterating over the dictionary would cause + # the dictionary to change size while iterating, which would crash + for _key in _null_keys: + params.pop(_key) # convert the API content return_format to an HTTP Accept type try: @@ -417,11 +426,6 @@ async def getiter( if not params: params = {} - # the API only takes "true" or "false", not True or False - for key, value in params.items(): - if value in (True, False): - params[key] = json.dumps(value) - valid_sort_orders = ["created", "updated", "popularity", "distance"] if sort not in valid_sort_orders: raise ValueError( @@ -438,6 +442,20 @@ async def getiter( # initially no results have been fetched yet num_results = 0 + # the API only takes "true" or "false", not True or False + # additionally, aiohttp refuses to pass in a boolean or nonetype in the params + _null_keys = [] + for _key, _value in params.items(): + if _value in (True, False): + params[_key] = json.dumps(_value) + elif _value == None: + _null_keys.append(_key) + + # popping null keys directly when iterating over the dictionary would cause + # the dictionary to change size while iterating, which would crash + for _key in _null_keys: + params.pop(_key) + async with aiohttp.ClientSession() as session: async with session.get( url=url, From bea5bfbcd5353bc75178e2dfe923a6613eac3c27 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 23:46:38 +0100 Subject: [PATCH 16/21] fix quickstart example bug, update changelog --- CHANGELOG.rst | 6 ++++-- docs/source/user/quickstart.rst | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4194e34..c3ecc37 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,8 +3,10 @@ Changelog 0.7.1 ^^^^^^^^^^^^^^^^^^^^ -This is a minor update, which adds support for Python 3.11 and changes a few things with -regard to the package configuration. No breaking changes have been introduced. +This is a minor update, which adds support for Python 3.11 and moves the package configuration +from setup.py to pyproject.toml. No breaking changes have been introduced. A bug has been fixed +which was causing aiohttp to crash on null parameters, and a bug in the quickstart example has +been fixed. 0.7.0 ^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/source/user/quickstart.rst b/docs/source/user/quickstart.rst index 7a79689..9ebd57d 100644 --- a/docs/source/user/quickstart.rst +++ b/docs/source/user/quickstart.rst @@ -41,7 +41,7 @@ request limit from 100 to 2500. resp = fpdb.plan.search( plan_query=query, include_route=True, - sort="distance" + sort="distance", limit=3, key=API_KEY ) @@ -54,6 +54,8 @@ request limit from 100 to 2500. # then check remaining requests by subtracting the requests made from the total limit print((await fpdb.api.limit_cap())-(await fpdb.api.limit_used())) + + asyncio.run(main()) Try saving this program in a file in your project directory and running it. Experiment around with different commands to get a feel for the library. From f11dc43622403a08f2fd262da904c08b4f514e8a Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 23:49:14 +0100 Subject: [PATCH 17/21] fix linter --- src/flightplandb/internal.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/flightplandb/internal.py b/src/flightplandb/internal.py index f2a33e3..70b9f94 100644 --- a/src/flightplandb/internal.py +++ b/src/flightplandb/internal.py @@ -130,9 +130,9 @@ async def request( for _key, _value in params.items(): if _value in (True, False): params[_key] = json.dumps(_value) - elif _value == None: + elif _value is None: _null_keys.append(_key) - + # popping null keys directly when iterating over the dictionary would cause # the dictionary to change size while iterating, which would crash for _key in _null_keys: @@ -448,9 +448,9 @@ async def getiter( for _key, _value in params.items(): if _value in (True, False): params[_key] = json.dumps(_value) - elif _value == None: + elif _value is None: _null_keys.append(_key) - + # popping null keys directly when iterating over the dictionary would cause # the dictionary to change size while iterating, which would crash for _key in _null_keys: From 6ea2f255ffbde0c398691a82b77bc3ca3fe22a40 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Mon, 20 Feb 2023 23:53:28 +0100 Subject: [PATCH 18/21] move pytest config to pyproject.toml --- pyproject.toml | 6 +++++- pytest.ini | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 pytest.ini diff --git a/pyproject.toml b/pyproject.toml index 3349dab..5ef8b72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,4 +48,8 @@ test = ["pytest~=7.2.1", "pytest-socket~=0.6.0", "pytest-asyncio~=0.20.3"] version = {attr = "flightplandb.__version__"} [tool.setuptools.packages.find] -where = ["src"] \ No newline at end of file +where = ["src"] + +[tool.pytest.ini_options] +addopts = "-vv --disable-socket" +asyncio_mode = "auto" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 89c75ec..0000000 --- a/pytest.ini +++ /dev/null @@ -1,3 +0,0 @@ -[pytest] -addopts = --disable-socket -asyncio_mode=auto From 3855a68a5b5285048d37e7445297afbdea8677c0 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Tue, 21 Feb 2023 00:03:46 +0100 Subject: [PATCH 19/21] switch build package from setuptools to build --- .github/workflows/release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f71f63..413ec1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,11 +15,13 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish + pip install build wheel twine + - name: Build + run: | + python -m build + -name: Publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel twine upload dist/* --skip-existing From a7e72fe0f0d3cdaf1c3a8664930241aab3970b21 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Tue, 21 Feb 2023 21:15:34 +0100 Subject: [PATCH 20/21] add python 3.11 classifier --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 5ef8b72..5342104 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Operating System :: OS Independent", "Topic :: Internet", "Topic :: Software Development :: Libraries", From 23251f31886e19533e20c8af4ead7555d189b686 Mon Sep 17 00:00:00 2001 From: PH-KDX Date: Tue, 21 Feb 2023 22:41:26 +0100 Subject: [PATCH 21/21] update changelog link in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a13a4f3..934a344 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ The library can be installed from PyPi using `pip install flightplandb`; the PyPi installation page link is [here](https://pypi.org/project/flightplandb/). For more details, see the Installation section of the documentation. ## Changelog -Before upgrading to a newer version, please read the appropriate changelog for your upgrade [here](https://flightplandb-py.readthedocs.io/en/stable/user/changelog.html). \ No newline at end of file +Before upgrading to a newer version, please read the appropriate changelog for your upgrade [here](https://github.com/PH-KDX/flightplandb-py/blob/main/CHANGELOG.rst). \ No newline at end of file