Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #212

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Fixes #212

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
end_of_line = lf
42 changes: 41 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
[metadata]
license = Apache-2.0
classifiers =
License :: OSI Approved :: Apache Software License
Intended Audience :: Developers
Programming Language :: Python
Programming Language :: Python :: 3
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
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.5.3
install_requires =
aiohttp>=3.0
typing;python_version<'3.5'
setup_requires =
# Environment markers were implemented and stabilized in setuptools
# v20.8.1 (see <http://stackoverflow.com/a/32643122/391865>).
setuptools>=20.8.1
# If line above doesn't work, check that you have at least
# setuptools v19.4 (released 2016-01-16):
# <https://github.com/pypa/setuptools/issues/141>

tests_require =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to keep unpinned test dependencies here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pytest
pytest-cov
pytest-pylint
selenium
pytest_runner

[aliases]
test = pytest

[tool:pytest]
addopts= --cov=aiohttp_cors --cov-report=term --cov-report=html --cov-branch --no-cov-on-fail
addopts= --cov=aiohttp_cors --cov-report=term --cov-report=html --cov-branch --no-cov-on-fail
71 changes: 12 additions & 59 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -44,45 +37,5 @@ 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 <http://stackoverflow.com/a/32643122/391865>).
"setuptools>=20.8.1",
# If line above doesn't work, check that you have at least
# setuptools v19.4 (released 2016-01-16):
# <https://github.com/pypa/setuptools/issues/141>
] + 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",
],
long_description="\n\n".join(( (currentDir / sn).read_text() for sn in ("README.rst", "CHANGES.rst") )),
)
2 changes: 1 addition & 1 deletion tests/unit/test_cors_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down