From 1f42367b5258538d0788cb9f34842ab9058ea796 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 26 Dec 2018 23:16:50 +0300 Subject: [PATCH 1/5] Added .editorconfig --- .editorconfig | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..b90d678 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +insert_final_newline = true +end_of_line = lf From 0ed0cdb59ddca42eec7a9b3f21d5df5e03ce0bea Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Wed, 26 Dec 2018 23:45:38 +0300 Subject: [PATCH 2/5] Moved the metadata into setup.cfg and improved metadata parsing from __about__ --- setup.cfg | 47 +++++++++++++++++++++++++++++++++++++ setup.py | 70 +++++++++---------------------------------------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/setup.cfg b/setup.cfg index 20d367e..7e2fe29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,50 @@ +[metadata] +name = aiohttp-cors +version = 0.7.0 +author = Vladimir Rutsky and aio-libs team +author_email = vladimir@rutsky.org +license = Apache-2.0 +description = CORS support for aiohttp +long_description = file: README.rst +url = https://github.com/aio-libs/aiohttp-cors +classifiers = + License :: OSI Approved :: Apache Software License + Intended Audience :: Developers + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3.4 + Programming Language :: Python :: 3.5 + Programming Language :: Python :: 3.6 + Topic :: Software Development :: Libraries + Topic :: Internet :: WWW/HTTP + Framework :: AsyncIO + Operating System :: MacOS :: MacOS X + Operating System :: Microsoft :: Windows + Operating System :: POSIX + License :: OSI Approved :: Apache Software License + Development Status :: 3 - Alpha + +[options] +packages = aiohttp_cors +python_requires = >=3.4.1 +install_requires = + aiohttp>=1.1 + typing;python_version<'3.5' +setup_requires = + # Environment markers were implemented and stabilized in setuptools + # v20.8.1 (see ). + setuptools>=20.8.1 + # If line above doesn't work, check that you have at least + # setuptools v19.4 (released 2016-01-16): + # + +tests_require = + pytest + pytest-cov + pytest-pylint + selenium + pytest_runner + [aliases] test = pytest diff --git a/setup.py b/setup.py index ce7d69c..d1bd237 100644 --- a/setup.py +++ b/setup.py @@ -12,29 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os +from pathlib import Path import sys from setuptools import setup +import ast +currentDir = Path(__file__).parent -def read_file(filename): - abs_path = os.path.join(os.path.dirname(__file__), filename) - with open(abs_path, encoding="utf-8") as f: - return f.read() +def extractMetaInfo(src): + info = {} + a=ast.parse(src) + for e in a.body: + if isinstance(e, ast.Assign) and isinstance(e.value, ast.Str): + info[e.targets[0].id] = e.value.s + return info - -about = {} -exec(read_file(os.path.join("aiohttp_cors", "__about__.py")), about) - -needs_pytest = {'pytest', 'test'}.intersection(sys.argv) -pytest_runner = ['pytest_runner'] if needs_pytest else [] - -# aiohttp requires Python >= 3.4.1, so as aiohttp_cors. -if sys.version_info[:3] < (3, 4, 1): - print("Error: aiohttp_cors requires Python interpreter version >= 3.4.1, " - "this interpreter has version '{}'".format(sys.version), - file=sys.stderr) - sys.exit(1) +about = extractMetaInfo((currentDir / "aiohttp_cors" / "__about__.py").read_text()) setup( @@ -44,45 +37,4 @@ def read_file(filename): author_email=about["__email__"], description=about["__summary__"], url=about["__uri__"], - long_description="\n\n".join(( - read_file("README.rst"), - read_file("CHANGES.rst"), - )), - packages=["aiohttp_cors"], - setup_requires=[ - # Environment markers were implemented and stabilized in setuptools - # v20.8.1 (see ). - "setuptools>=20.8.1", - # If line above doesn't work, check that you have at least - # setuptools v19.4 (released 2016-01-16): - # - ] + pytest_runner, - tests_require=[ - "pytest", - "pytest-cov", - "pytest-pylint", - "selenium", - ], - test_suite="tests", - install_requires=[ - "aiohttp>=1.1", - "typing;python_version<'3.5'", - ], - license=about["__license__"], - classifiers=[ - "License :: OSI Approved :: Apache Software License", - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Topic :: Software Development :: Libraries", - "Topic :: Internet :: WWW/HTTP", - "Framework :: AsyncIO", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - "Operating System :: POSIX", - "Development Status :: 3 - Alpha", - ], ) From e80ccb5155ac74938d73ed328bea4d4613651020 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Thu, 27 Dec 2018 00:33:44 +0300 Subject: [PATCH 3/5] Fixed error in a test. --- tests/unit/test_cors_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_cors_config.py b/tests/unit/test_cors_config.py index 817410e..d494e20 100644 --- a/tests/unit/test_cors_config.py +++ b/tests/unit/test_cors_config.py @@ -103,7 +103,7 @@ def test_static_resource(app, cors): "/file", "/", name="dynamic_named_route") assert len(app.router.keys()) == 1 for resource in list(app.router.resources()): - if issubclass(resource, web.StaticResource): + if isinstance(resource, web.StaticResource): cors.add(resource) assert len(app.router.keys()) == 1 From b22de748fb4d6102620a2d0c5f0a09654bfd6b68 Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Sat, 29 Dec 2018 17:14:33 +0000 Subject: [PATCH 4/5] Fixes according tk the discussion --- setup.cfg | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/setup.cfg b/setup.cfg index 7e2fe29..95c07d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,20 +1,13 @@ [metadata] -name = aiohttp-cors -version = 0.7.0 -author = Vladimir Rutsky and aio-libs team -author_email = vladimir@rutsky.org license = Apache-2.0 -description = CORS support for aiohttp -long_description = file: README.rst -url = https://github.com/aio-libs/aiohttp-cors classifiers = License :: OSI Approved :: Apache Software License Intended Audience :: Developers Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 Topic :: Software Development :: Libraries Topic :: Internet :: WWW/HTTP Framework :: AsyncIO @@ -26,9 +19,9 @@ classifiers = [options] packages = aiohttp_cors -python_requires = >=3.4.1 +python_requires = >=3.5.3 install_requires = - aiohttp>=1.1 + aiohttp>=3.0 typing;python_version<'3.5' setup_requires = # Environment markers were implemented and stabilized in setuptools @@ -49,4 +42,4 @@ tests_require = test = pytest [tool:pytest] -addopts= --cov=aiohttp_cors --cov-report=term --cov-report=html --cov-branch --no-cov-on-fail \ No newline at end of file +addopts= --cov=aiohttp_cors --cov-report=term --cov-report=html --cov-branch --no-cov-on-fail From 9991507428514c2e6d8039be908bc96941acbe7d Mon Sep 17 00:00:00 2001 From: KOLANICH Date: Sat, 29 Dec 2018 17:21:23 +0000 Subject: [PATCH 5/5] Restored the composition of long_description from multiple files --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d1bd237..0091e9c 100644 --- a/setup.py +++ b/setup.py @@ -37,4 +37,5 @@ def extractMetaInfo(src): author_email=about["__email__"], description=about["__summary__"], url=about["__uri__"], + long_description="\n\n".join(( (currentDir / sn).read_text() for sn in ("README.rst", "CHANGES.rst") )), )