From c8e42ca953561e2144963a0d565f6692b9ac61d0 Mon Sep 17 00:00:00 2001 From: getzze Date: Wed, 8 May 2024 22:30:10 +0100 Subject: [PATCH] add pyproject.toml --- dev-requirements.txt | 1 - pyproject.toml | 234 +++++++++++++++++++++++++++++++++++++++++ pytest.ini | 14 --- requirements.txt | 1 - setup.cfg | 10 -- setup.py | 99 ----------------- subliminal/__init__.py | 6 +- tox.ini | 2 +- 8 files changed, 238 insertions(+), 129 deletions(-) delete mode 100644 dev-requirements.txt create mode 100644 pyproject.toml delete mode 100644 pytest.ini delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index b7a393ff6..000000000 --- a/dev-requirements.txt +++ /dev/null @@ -1 +0,0 @@ --e .[dev,test] diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..fd680ccd2 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,234 @@ +# https://peps.python.org/pep-0517/ +[build-system] +requires = ["setuptools>=64"] +build-backend = "setuptools.build_meta" + +# https://peps.python.org/pep-0621/ +[project] +name = "subliminal" +description = "Subtitles, faster than your thoughts" +requires-python = ">=3.8" +license = { text = "MIT" } +authors = [{ name = "Antoine Bertin", email = "diaoulael@gmail.com" }] +maintainers = [{ name = "Antoine Bertin", email = "diaoulael@gmail.com" }] +keywords = ["subtitle", "subtitles", "video", "movie", "episode", "tv", "show", "series"] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Multimedia :: Video", +] +dynamic = ["version", "readme"] +dependencies = [ + "appdirs>=1.3", + "babelfish>=0.6.1", + "beautifulsoup4>=4.4.0", + "chardet>=5.0", + "click>=4.0", + "dogpile.cache>=1.0", + "enzyme>=0.4.1", + "guessit>=3.0.0", + "rarfile>=2.7", + "rebulk>=3.0", + "requests>=2.0", + "requests_cache>=1.0", + "srt>=3.5", + "stevedore>=3.0", +] + +# extras +# https://peps.python.org/pep-0621/#dependencies-optional-dependencies +[project.optional-dependencies] +docs = [ + "sphinx", + "sphinx_rtd_theme", + "sphinxcontrib-programoutput", +] +test = [ + "lxml", + "pytest>=6.0", + "pytest-cov", + "pytest-flakes", + "sympy", + "vcrpy>=1.6.1", +] +dev = [ + "mypy", + "ruff", + "typos", + "validate-pyproject", + "tox", +] + +[project.urls] +homepage = "https://github.com/Diaoul/subliminal" +repository = "https://github.com/Diaoul/subliminal" +documentation = "https://subliminal.readthedocs.org" + +[project.scripts] +subliminal = "subliminal.cli:subliminal" + +[project.entry-points."subliminal.providers"] +addic7ed = "subliminal.providers.addic7ed:Addic7edProvider" +argenteam = "subliminal.providers.argenteam:ArgenteamProvider" +gestdown = "subliminal.providers.gestdown:GestdownProvider" +napiprojekt = "subliminal.providers.napiprojekt:NapiProjektProvider" +opensubtitles = "subliminal.providers.opensubtitles:OpenSubtitlesProvider" +opensubtitlesvip = "subliminal.providers.opensubtitles:OpenSubtitlesVipProvider" +opensubtitlescom = "subliminal.providers.opensubtitlescom:OpenSubtitlesComProvider" +opensubtitlescomvip = "subliminal.providers.opensubtitlescom:OpenSubtitlesComVipProvider" +podnapisi = "subliminal.providers.podnapisi:PodnapisiProvider" +shooter = "subliminal.providers.shooter:ShooterProvider" +thesubdb = "subliminal.providers.thesubdb:TheSubDBProvider" +tvsubtitles = "subliminal.providers.tvsubtitles:TVsubtitlesProvider" + +[project.entry-points."subliminal.refiners"] +hash = "subliminal.refiners.hash:refine" +metadata = "subliminal.refiners.metadata:refine" +omdb = "subliminal.refiners.omdb:refine" +tvdb = "subliminal.refiners.tvdb:refine" + +[project.entry-points."babelfish.language_converters"] +addic7ed = "subliminal.converters.addic7ed:Addic7edConverter" +opensubtitlescom = "subliminal.converters.opensubtitlescom:OpenSubtitlesComConverter" +shooter = "subliminal.converters.shooter:ShooterConverter" +thesubdb = "subliminal.converters.thesubdb:TheSubDBConverter" +tvsubtitles = "subliminal.converters.tvsubtitles:TVsubtitlesConverter" + +[tool.setuptools] +py-modules = ["subliminal"] +include-package-data = true + +[tool.setuptools.package-data] +subliminal = [ + "py.typed", +] + +[tool.setuptools.packages.find] +namespaces = false +where = ["."] + +[tool.setuptools.dynamic] +version = {attr = "subliminal.__version__"} +readme = {file = ["README.rst", "HISTORY.rst"]} + + +# https://docs.astral.sh/ruff/ +[tool.ruff] +line-length = 120 +src = ["subliminal", "tests"] + +[tool.ruff.lint] +pydocstyle = { convention = "pep257" } +select = [ + "E", # style errors + "F", # flakes + "W", # warnings + "D", # pydocstyle + "D417", # Missing argument descriptions in Docstrings + "I", # isort + "UP", # pyupgrade + "S", # bandit + "C4", # flake8-comprehensions + "B", # flake8-bugbear + "A001", # flake8-builtins + "TCH", # flake8-typecheck + "TID", # flake8-tidy-imports + "RUF", # ruff-specific rules + "ISC", # flake8-implicit-str-concat + "PT", # flake8-pytest-style +] +ignore = [ + "D401", # First line should be in imperative mood +] + +[tool.ruff.lint.per-file-ignores] +"docs/conf*.py" = ["ALL"] +"subliminal/__init__.py" = ["E402"] +"tests/*.py" = ["D", "S", "RUF012"] + +# https://docs.astral.sh/ruff/formatter/ +[tool.ruff.format] +docstring-code-format = true + + +# https://docs.pytest.org/en/6.2.x/customize.html +[tool.pytest.ini_options] +minversion = "6.0" +testpaths = ["tests"] +addopts = "--doctest-glob='*.rst'" +markers = [ + "integration", + "converter", +] +doctest_optionflags = ["NORMALIZE_WHITESPACE", "IGNORE_EXCEPTION_DETAIL"] + +# https://coverage.readthedocs.io/en/latest/config.html +[tool.coverage.report] +exclude_also = [ + "pragma: no cover", + "if TYPE_CHECKING:", + "@overload", + "except ImportError", + "\\.\\.\\.", + "raise NotImplementedError()", +] +show_missing = true +skip_covered = true +fail_under = 100 + +[tool.coverage.run] +source = ["subliminal"] + + +# https://mypy.readthedocs.io/en/stable/config_file.html +[tool.mypy] +files = "subliminal/**/*.py" +exclude = ['build', 'dist', 'docs'] +# global-only flags +pretty = true +show_error_codes = true +namespace_packages = false +warn_redundant_casts = true +# global per-module flags +check_untyped_defs = true +strict_equality = true +disallow_any_generics = false +disallow_subclassing_any = false + +[[tool.mypy.overrides]] +module = ["subliminal.*"] +warn_return_any = true +disallow_untyped_defs = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +extra_checks = true + +[[tool.mypy.overrides]] +module = ["tests.*"] +disallow_untyped_defs = false +disallow_untyped_calls = false +warn_return_any = false +disable_error_code = ["var-annotated"] + + +# https://github.com/crate-ci/typos/blob/master/docs/reference.md +[tool.typos.files] +extend-exclude = ["cassettes/", "tests/"] + +[tool.typos.default] +extend-ignore-re = [ + "(?Rm)^.*#\\s*spellchecker:\\s*disable-line$", + "#\\s*spellchecker:off\\s*\\n.*\\n\\s*#\\s*spellchecker:on" +] +[tool.typos.default.extend-identifiers] +tha = "tha" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index a73c9096c..000000000 --- a/pytest.ini +++ /dev/null @@ -1,14 +0,0 @@ -[pytest] -norecursedirs = build dist env .tox .eggs -addopts = --doctest-glob='*.rst' -pep8maxlinelength = 120 -pep8ignore = - docs/conf.py ALL - subliminal/__init__.py E402 -flakes-ignore = - docs/conf.py ALL - subliminal/__init__.py UnusedImport -doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL -markers = - integration - converter diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index d6e1198b1..000000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ --e . diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ef0247cb9..000000000 --- a/setup.cfg +++ /dev/null @@ -1,10 +0,0 @@ -[aliases] -test=pytest - -[build_sphinx] -source-dir = docs/ -build-dir = docs/_build -all_files = 1 - -[upload_sphinx] -upload-dir = docs/_build/html diff --git a/setup.py b/setup.py deleted file mode 100644 index 1f4f80baf..000000000 --- a/setup.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python -import io -import os -import re -import sys - -from setuptools import setup, find_packages - -here = os.path.abspath(os.path.dirname(__file__)) - - -def read(*parts): - # intentionally *not* adding an encoding option to open, See: - # https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 - return io.open(os.path.join(here, *parts), 'r').read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError('Unable to find version string.') - - -# requirements -setup_requirements = ['pytest-runner'] if {'pytest', 'test', 'ptr'}.intersection(sys.argv) else [] - -install_requirements = ['guessit>=3.0.0', 'babelfish>=0.5.2', 'enzyme>=0.4.1', 'beautifulsoup4>=4.4.0', - 'rebulk>=3.0', 'requests>=2.0', 'requests_cache', 'click>=4.0', 'dogpile.cache>=1.0', - 'stevedore>=3.0', 'chardet>=5.0', 'srt>=3.5.0', 'appdirs>=1.3', 'rarfile>=2.7'] - -test_requirements = ['sympy', 'vcrpy>=1.6.1', 'pytest', 'pytest-pep8', 'pytest-flakes', 'pytest-cov'] - -dev_requirements = ['tox', 'sphinx', 'sphinx_rtd_theme', 'sphinxcontrib-programoutput', 'wheel'] - - -setup(name='subliminal', - version=find_version('subliminal', '__init__.py'), - license='MIT', - description='Subtitles, faster than your thoughts', - long_description=read('README.rst') + '\n\n' + read('HISTORY.rst'), - keywords='subtitle subtitles video movie episode tv show series', - url='https://github.com/Diaoul/subliminal', - author='Antoine Bertin', - author_email='diaoulael@gmail.com', - packages=find_packages(), - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', - 'Topic :: Software Development :: Libraries :: Python Modules', - 'Topic :: Multimedia :: Video' - ], - entry_points={ - 'subliminal.providers': [ - 'addic7ed = subliminal.providers.addic7ed:Addic7edProvider', - 'argenteam = subliminal.providers.argenteam:ArgenteamProvider', - 'gestdown = subliminal.providers.gestdown:GestdownProvider', - 'napiprojekt = subliminal.providers.napiprojekt:NapiProjektProvider', - 'opensubtitles = subliminal.providers.opensubtitles:OpenSubtitlesProvider', - 'opensubtitlescom = subliminal.providers.opensubtitlescom:OpenSubtitlesComProvider', - 'podnapisi = subliminal.providers.podnapisi:PodnapisiProvider', - 'shooter = subliminal.providers.shooter:ShooterProvider', - 'thesubdb = subliminal.providers.thesubdb:TheSubDBProvider', - 'tvsubtitles = subliminal.providers.tvsubtitles:TVsubtitlesProvider' - ], - 'subliminal.refiners': [ - 'hash = subliminal.refiners.hash:refine', - 'metadata = subliminal.refiners.metadata:refine', - 'omdb = subliminal.refiners.omdb:refine', - 'tvdb = subliminal.refiners.tvdb:refine' - ], - 'babelfish.language_converters': [ - 'addic7ed = subliminal.converters.addic7ed:Addic7edConverter', - 'opensubtitlescom = subliminal.converters.opensubtitlescom:OpenSubtitlesComConverter', - 'shooter = subliminal.converters.shooter:ShooterConverter', - 'thesubdb = subliminal.converters.thesubdb:TheSubDBConverter', - 'tvsubtitles = subliminal.converters.tvsubtitles:TVsubtitlesConverter' - ], - 'console_scripts': [ - 'subliminal = subliminal.cli:subliminal' - ] - }, - setup_requires=setup_requirements, - install_requires=install_requirements, - tests_require=test_requirements, - extras_require={ - 'test': test_requirements, - 'dev': dev_requirements - }) diff --git a/subliminal/__init__.py b/subliminal/__init__.py index 3c162d529..77c0e2621 100644 --- a/subliminal/__init__.py +++ b/subliminal/__init__.py @@ -1,14 +1,14 @@ from __future__ import annotations -__title__ = 'subliminal' +import logging + __version__ = '2.1.1-dev' __short_version__ = '.'.join(__version__.split('.')[:2]) +__title__ = 'subliminal' __author__ = 'Antoine Bertin' __license__ = 'MIT' __copyright__ = 'Copyright 2016, Antoine Bertin' -import logging - from .core import (AsyncProviderPool, ProviderPool, check_video, download_best_subtitles, download_subtitles, list_subtitles, refine, save_subtitles, scan_video, scan_videos) from .cache import region diff --git a/tox.ini b/tox.ini index 3e9052e6c..1f4aeedcc 100644 --- a/tox.ini +++ b/tox.ini @@ -4,4 +4,4 @@ envlist = {py38,py39,py310,py311,py312}-{native,lxml} [testenv] deps = lxml: lxml -commands = python setup.py test +commands = pytest