Remove Duplicated Dependencies and PEP 517 Support (#2173)

* Remove duplicated dependencies

* Specify setuptools as the tool for generating distribution (PEP 517)

* Add `isort` to `dev_require`

* manage all dependencies in setup.py

* Execute `make pretty`

* Set usedevelop to true (revert previous change)
This commit is contained in:
Zhiwei 2021-07-07 23:12:56 -07:00 committed by GitHub
parent a90877ac31
commit 1dd0332e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 64 deletions

3
pyproject.toml Normal file
View File

@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

View File

@ -81,7 +81,7 @@ env_dependency = (
)
ujson = "ujson>=1.35" + env_dependency
uvloop = "uvloop>=0.5.3" + env_dependency
types_ujson = "types-ujson" + env_dependency
requirements = [
"sanic-routing==0.7.0",
"httptools>=0.0.10",
@ -95,46 +95,49 @@ requirements = [
tests_require = [
"sanic-testing>=0.6.0",
"pytest==5.2.1",
"multidict>=5.0,<6.0",
"coverage==5.3",
"gunicorn==20.0.4",
"pytest-cov",
"beautifulsoup4",
uvloop,
ujson,
"pytest-sanic",
"pytest-sugar",
"pytest-benchmark",
"chardet==3.*",
"flake8",
"black",
"isort>=5.0.0",
"bandit",
"mypy>=0.901",
"docutils",
"pygments",
"uvicorn",
types_ujson,
]
docs_require = [
"sphinx>=2.1.2",
"sphinx_rtd_theme",
"sphinx_rtd_theme>=0.4.3",
"recommonmark>=0.5.0",
"docutils",
"pygments",
]
dev_require = tests_require + [
"aiofiles",
"tox",
"black",
"flake8",
"bandit",
"towncrier",
]
all_require = dev_require + docs_require
all_require = list(set(dev_require + docs_require))
if strtobool(os.environ.get("SANIC_NO_UJSON", "no")):
print("Installing without uJSON")
requirements.remove(ujson)
tests_require.remove(ujson)
tests_require.remove(types_ujson)
# 'nt' means windows OS
if strtobool(os.environ.get("SANIC_NO_UVLOOP", "no")):
print("Installing without uvLoop")
requirements.remove(uvloop)
tests_require.remove(uvloop)
extras_require = {
"test": tests_require,

View File

@ -13,7 +13,7 @@ from sanic.exceptions import PyFileError
@contextmanager
def temp_path():
""" a simple cross platform replacement for NamedTemporaryFile """
"""a simple cross platform replacement for NamedTemporaryFile"""
with TemporaryDirectory() as td:
yield Path(td, "file")

View File

@ -111,7 +111,7 @@ def test_logging_pass_customer_logconfig():
),
)
def test_log_connection_lost(app, debug, monkeypatch):
""" Should not log Connection lost exception on non debug """
"""Should not log Connection lost exception on non debug"""
stream = StringIO()
error = logging.getLogger("sanic.error")
error.addHandler(logging.StreamHandler(stream))

53
tox.ini
View File

@ -2,23 +2,11 @@
envlist = py37, py38, py39, pyNightly, pypy37, {py37,py38,py39,pyNightly,pypy37}-no-ext, lint, check, security, docs, type-checking
[testenv]
usedevelop = True
usedevelop = true
setenv =
{py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UJSON=1
{py37,py38,py39,pyNightly}-no-ext: SANIC_NO_UVLOOP=1
deps =
sanic-testing>=0.6.0
coverage==5.3
pytest==5.2.1
pytest-cov
pytest-sanic
pytest-sugar
pytest-benchmark
chardet==3.*
beautifulsoup4
gunicorn==20.0.4
uvicorn
websockets>=9.0
extras = test
commands =
pytest {posargs:tests --cov sanic}
- coverage combine --append
@ -26,29 +14,16 @@ commands =
coverage html -i
[testenv:lint]
deps =
flake8
black
isort>=5.0.0
bandit
commands =
flake8 sanic
black --config ./.black.toml --check --verbose sanic/
isort --check-only sanic --profile=black
[testenv:type-checking]
deps =
mypy>=0.901
types-ujson
commands =
mypy sanic
[testenv:check]
deps =
docutils
pygments
commands =
python setup.py check -r -s
@ -60,8 +35,6 @@ markers =
asyncio
[testenv:security]
deps =
bandit
commands =
bandit --recursive sanic --skip B404,B101 --exclude sanic/reloader_helpers.py
@ -69,30 +42,10 @@ commands =
[testenv:docs]
platform = linux|linux2|darwin
whitelist_externals = make
deps =
sphinx>=2.1.2
sphinx_rtd_theme>=0.4.3
recommonmark>=0.5.0
docutils
pygments
gunicorn==20.0.4
extras = docs
commands =
make docs-test
[testenv:coverage]
usedevelop = True
deps =
sanic-testing>=0.6.0
coverage==5.3
pytest==5.2.1
pytest-cov
pytest-sanic
pytest-sugar
pytest-benchmark
chardet==3.*
beautifulsoup4
gunicorn==20.0.4
uvicorn
websockets>=9.0
commands =
pytest tests --cov=./sanic --cov-report=xml