diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d6dc3f2..9e10083 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -34,7 +34,7 @@ jobs: cache-name: cache-pip with: path: ~/.cache/pip - key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.deps }}-${{ hashFiles('setup.py') }} + key: ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.deps }}-${{ hashFiles('pyproject.toml', 'setup.cfg') }} restore-keys: | ${{ runner.os }}-${{ env.cache-name }}-${{ matrix.deps }}- ${{ runner.os }}-${{ env.cache-name }}- diff --git a/.gitignore b/.gitignore index dda2b4b..4857e9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ *.egg-info/ __pycache__/ /build/ +/dist/ .cache/ .eggs/ *.pyc *.pyo .travis.pub .pytest_cache/ +.tox/ keyfile.toml diff --git a/README.rst b/README.rst index 4ce6ee3..08ef28f 100644 --- a/README.rst +++ b/README.rst @@ -42,7 +42,7 @@ To install:: To use the latest code, you can also clone this repository and run:: - python3 setup.py install + pip install . To see available options:: diff --git a/docs/usage.rst b/docs/usage.rst index 354ba9c..5be3fe0 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -204,8 +204,8 @@ httptoken A personal authorization token used to fetch the url with the ``Authorization`` header. The type of token depends on the authorization required. - - For Bearer token set : ``Bearer `` - - For Basic token set : ``Basic `` + - For Bearer token set \: ``Bearer `` + - For Basic token set \: ``Basic `` In the keyfile add ``httptoken_{name}`` token. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f3aa8ed --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +# addopts = -n auto +asyncio_mode = "strict" diff --git a/setup.cfg b/setup.cfg index 410e7c4..a876b3d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,73 @@ +# The complex upload command: +# rm -rf dist && python -m build --sdist && twine check dist/* && twine upload -s dist/* + +[metadata] +name = nvchecker +version = attr: nvchecker.__version__ +author = lilydjwg +author_email = lilydjwg@gmail.com +description = New version checker for software +license = MIT +keywords = new, version, build, check +url = https://github.com/lilydjwg/nvchecker +long_description = file: README.rst +long_description_content_type = text/x-rst +platforms = any + +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Intended Audience :: Developers + Intended Audience :: System Administrators + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Topic :: Internet + Topic :: Internet :: WWW/HTTP + Topic :: Software Development + Topic :: System :: Archiving :: Packaging + Topic :: System :: Software Distribution + Topic :: Utilities + +[options] +zip_safe = True + +packages = find_namespace: +install_requires = + setuptools; python_version<"3.8" + tomli + structlog + appdirs + tornado>=6 + pycurl +scripts = + scripts/nvchecker-ini2toml + scripts/nvchecker-notify + +[options.packages.find] +exclude = tests, build*, docs* + +[options.extras_require] +vercmp = + pyalpm +awesomeversion = + awesomeversion +pypi = + packaging +htmlparser = + lxml + +[options.entry_points] +console_scripts = + nvchecker = nvchecker.__main__:main + nvtake = nvchecker.tools:take + nvcmp = nvchecker.tools:cmp + [flake8] ignore = E111, E302, E501 - -[tool:pytest] -addopts = --asyncio-mode=auto diff --git a/setup.py b/setup.py deleted file mode 100755 index 5e74025..0000000 --- a/setup.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 - -from setuptools import setup, find_namespace_packages -import nvchecker - -# The complex upload command: -# rm -rf dist && python setup.py sdist && twine check dist/* && twine upload -s dist/* - -setup( - name = 'nvchecker', - version = nvchecker.__version__, - author = 'lilydjwg', - author_email = 'lilydjwg@gmail.com', - description = 'New version checker for software', - license = 'MIT', - keywords = 'new version build check', - url = 'https://github.com/lilydjwg/nvchecker', - long_description = open('README.rst', encoding='utf-8').read(), - long_description_content_type = 'text/x-rst', - platforms = 'any', - zip_safe = True, - - packages = find_namespace_packages(include=['nvchecker*']), - install_requires = ['setuptools; python_version<"3.8"', 'tomli', 'structlog', 'appdirs', 'tornado>=6', 'pycurl'], - extras_require = { - 'vercmp': ['pyalpm'], - 'awesomeversion': ['awesomeversion'], - 'pypi': ['packaging'], - 'htmlparser': ['lxml'], - }, - tests_require = [ - 'pytest', - 'pytest-asyncio', - 'pytest-httpbin', - 'flaky', - ], - entry_points = { - 'console_scripts': [ - 'nvchecker = nvchecker.__main__:main', - 'nvtake = nvchecker.tools:take', - 'nvcmp = nvchecker.tools:cmp', - ], - }, - scripts = [ - 'scripts/nvchecker-ini2toml', - 'scripts/nvchecker-notify', - ], - - classifiers = [ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Internet", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Software Development", - "Topic :: System :: Archiving :: Packaging", - "Topic :: System :: Software Distribution", - "Topic :: Utilities", - ], -) diff --git a/tests/conftest.py b/tests/conftest.py index 7bdb721..df00127 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,6 +8,7 @@ from pathlib import Path import tomli import pytest +import pytest_asyncio from nvchecker import core from nvchecker import __main__ as main @@ -41,7 +42,7 @@ async def run( vers, _has_failures = await main.run(result_coro, runner_coro) return vers -@pytest.fixture(scope="module") +@pytest_asyncio.fixture(scope="module") async def get_version(): async def __call__(name, config): entries = {name: config} @@ -50,7 +51,7 @@ async def get_version(): return __call__ -@pytest.fixture(scope="module") +@pytest_asyncio.fixture(scope="module") async def run_str(): async def __call__(str): entries = tomli.loads(str) @@ -59,7 +60,7 @@ async def run_str(): return __call__ -@pytest.fixture(scope="module") +@pytest_asyncio.fixture(scope="module") async def run_str_multi(): async def __call__(str): entries = tomli.loads(str) diff --git a/tests/test_htmlpasrer.py b/tests/test_htmlparser.py similarity index 78% rename from tests/test_htmlpasrer.py rename to tests/test_htmlparser.py index 436c27b..a11a2e5 100644 --- a/tests/test_htmlpasrer.py +++ b/tests/test_htmlparser.py @@ -3,7 +3,17 @@ import pytest -pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net] +lxml_available = True +try: + import lxml +except ImportError: + lxml_available = False + +pytestmark = [ + pytest.mark.asyncio, + pytest.mark.needs_net, + pytest.mark.skipif(not lxml_available, reason="needs lxml"), +] async def test_xpath_ok(get_version): assert await get_version("unifiedremote", { diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..b640e05 --- /dev/null +++ b/tox.ini @@ -0,0 +1,16 @@ +[tox] +isolated_build = True +# you may find `tox --skip-missing-interpreters=true` helpful. +envlist = py3{7,8,9,10} + +[testenv] +usedevelop = false +deps = + pytest + pytest-asyncio + pytest-httpbin + flaky +extras = + htmlparser +passenv = KEYFILE +commands = pytest -r fEs {posargs}