Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

PEP621: Move more configuration into pyproject.toml (#2225)

Christian Claussdc73be5a2290
diff --git a/.flake8 b/.flake8
new file mode 100644
index 000000000..ac52d6f8d
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,10 @@
+[flake8]
+max-line-length = 120
+exclude =
+ docs
+per-file-ignores =
+ __init__.py: F401, F403
+verbose = 2
+ignore =
+ W503
+ E203
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9f48819bc..1cea150d7 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,11 +13,18 @@ repos:
- id: pretty-format-json
exclude: ^$|.devcontainer
- - repo: https://github.com/asottile/setup-cfg-fmt
- rev: v2.2.0
+ - repo: https://github.com/tox-dev/pyproject-fmt
+ rev: "0.9.1"
hooks:
- - id: setup-cfg-fmt
+ - id: pyproject-fmt
+ args:
+ - --indent
+ - "4"
+ - repo: https://github.com/abravalheri/validate-pyproject
+ rev: v0.12.1
+ hooks:
+ - id: validate-pyproject
- repo: https://github.com/psf/black
rev: 23.1.0
diff --git a/kornia/feature/loftr/utils/coarse_matching.py b/kornia/feature/loftr/utils/coarse_matching.py
index ca152c835..534953906 100644
--- a/kornia/feature/loftr/utils/coarse_matching.py
+++ b/kornia/feature/loftr/utils/coarse_matching.py
@@ -230,7 +230,7 @@ class CoarseMatching(nn.Module):
[i_ids, data['spv_i_ids']],
[j_ids, data['spv_j_ids']],
[mconf, mconf_gt],
- )
+ ),
)
# These matches select patches that feed into fine-level network
diff --git a/pyproject.toml b/pyproject.toml
index 1f2e3fb90..7d2c94968 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,3 +1,102 @@
+[build-system]
+build-backend = "setuptools.build_meta"
+requires = [
+ "setuptools>=61.2",
+]
+
+[project]
+name = "kornia"
+version = "0.6.11.dev"
+description = "Open Source Differentiable Computer Vision Library for PyTorch"
+[project.readme]
+file = "README.md"
+content-type = "text/markdown"
+
+keywords = [
+ "computer vision",
+ "deep learning",
+ "pytorch",
+]
+license = {text = "Apache-2.0"}
+authors = [{name = "Edgar Riba", email = "[email protected]"}]
+requires-python = ">=3.7"
+classifiers = [
+ "Development Status :: 4 - Beta",
+ "Environment :: Console",
+ "Environment :: GPU",
+ "Intended Audience :: Developers",
+ "Intended Audience :: Education",
+ "Intended Audience :: Information Technology",
+ "Intended Audience :: Science/Research",
+ "License :: OSI Approved :: Apache Software License",
+ "Natural Language :: English",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3 :: Only",
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
+ "Topic :: Scientific/Engineering :: Image Processing",
+ "Topic :: Software Development :: Libraries",
+]
+dependencies = [
+ "packaging",
+ "torch>=1.9.1",
+]
+[project.optional-dependencies]
+dev = [
+ "isort",
+ "kornia-rs==0.0.8",
+ "mypy[reports]",
+ "numpy",
+ "opencv-python",
+ "pre-commit>=2",
+ "pydocstyle",
+ "pytest==7.2.1",
+ "pytest-cov==4",
+ "scipy",
+]
+docs = [
+ "furo",
+ "matplotlib",
+ "opencv-python",
+ "PyYAML<6.1.0,>=5.1",
+ "sphinx>=4",
+ "sphinx-autodoc-defaultargs",
+ "sphinx-autodoc-typehints",
+ "sphinx-copybutton>=0.3",
+ "sphinx-design",
+ "sphinx-rtd-theme>0.5",
+ "sphinxcontrib-bibtex",
+ "sphinxcontrib-gtagjs",
+ "sphinxcontrib-youtube",
+ "torchvision",
+]
+x = [
+ "accelerate==0.16",
+]
+[project.urls]
+"Bug Tracker" = "https://github.com/kornia/kornia/issues"
+Documentation = "https://kornia.readthedocs.io/en/latest"
+Download = "https://github.com/kornia/kornia"
+Homepage = "https://www.kornia.org"
+"Source Code" = "https://github.com/kornia/kornia"
+
+[tool.setuptools]
+zip-safe = true
+license-files = ["LICENSE"]
+include-package-data = false
+
+[tool.setuptools.packages.find]
+exclude = [
+ "docs*",
+ "test",
+ "test.*",
+ "examples*",
+]
+namespaces = false
+
+[tool.setuptools.package-data]
+kornia = ["py.typed"]
+
[tool.black]
line-length = 120
skip-string-normalization = true
@@ -17,3 +116,56 @@ skip_glob = []
skip = [
"kornia/__init__.py"
]
+
+[tool.pytest.ini_options]
+norecursedirs = [
+ ".git",
+ ".github",
+ "dist",
+ "build",
+]
+addopts = "--color=yes"
+markers = [
+ "jit: mark a test as torchscript test",
+ "grad: mark a test as gradcheck test",
+ "nn: mark a test as module test",
+]
+testpaths = ["test"]
+
+[tool.coverage.report]
+exclude_lines = [
+ "pragma: no cover",
+ "def __repr__",
+ "if self.debug:",
+ "raise",
+ "if 0:",
+ "if __name__ == .__main__.:",
+]
+
+[tool.mypy]
+files = ["kornia/"]
+pretty = true
+check_untyped_defs = true
+disallow_any_generics = true
+show_error_codes = true
+ignore_missing_imports = true
+no_implicit_optional = true
+warn_unused_ignores = true
+warn_redundant_casts = true
+
+[tool.distutils.bdist_wheel]
+universal = true
+
+[tool.aliases]
+test = "pytest"
+
+[tool.pydocstyle]
+match = '.*\.py'
+ignore = """
+D105
+D107
+D203
+D204
+D213
+D406
+D407"""
diff --git a/setup.cfg b/setup.cfg
deleted file mode 100644
index 57947fef6..000000000
--- a/setup.cfg
+++ /dev/null
@@ -1,110 +0,0 @@
-[metadata]
-name = kornia
-version = 0.6.11.dev
-description = Open Source Differentiable Computer Vision Library for PyTorch
-long_description = file: README.md
-long_description_content_type = text/markdown
-url = https://www.kornia.org
-author = Edgar Riba
-author_email = [email protected]
-license = Apache-2.0
-license_files = LICENSE
-classifiers =
- Development Status :: 4 - Beta
- Environment :: Console
- Environment :: GPU
- Intended Audience :: Developers
- Intended Audience :: Education
- Intended Audience :: Information Technology
- Intended Audience :: Science/Research
- License :: OSI Approved :: Apache Software License
- Natural Language :: English
- Operating System :: OS Independent
- Programming Language :: Python :: 3
- Programming Language :: Python :: 3 :: Only
- Topic :: Scientific/Engineering :: Artificial Intelligence
- Topic :: Scientific/Engineering :: Image Processing
- Topic :: Software Development :: Libraries
-download_url = https://github.com/kornia/kornia
-keywords = computer vision, deep learning, pytorch
-project_urls =
- Bug Tracker = https://github.com/kornia/kornia/issues
- Documentation = https://kornia.readthedocs.io/en/latest
- Source Code = https://github.com/kornia/kornia
-
-[options]
-packages = find:
-python_requires = >=3.7
-zip_safe = True
-
-[options.packages.find]
-exclude =
- docs*
- test
- test.*
- examples*
-
-[options.package_data]
-kornia = py.typed
-
-[bdist_wheel]
-universal = True
-
-[aliases]
-test = pytest
-
-[tool:pytest]
-norecursedirs =
- .git
- .github
- dist
- build
-addopts =
- --color=yes
-markers =
- jit: mark a test as torchscript test
- grad: mark a test as gradcheck test
- nn: mark a test as module test
-testpaths = test
-
-[flake8]
-max-line-length = 120
-exclude =
- docs
-per-file-ignores =
- __init__.py: F401, F403
-verbose = 2
-ignore =
- W503
- E203
-
-[mypy]
-files = kornia/
-pretty = True
-check_untyped_defs = True
-disallow_any_generics = True
-show_error_codes = True
-ignore_missing_imports = True
-no_implicit_optional = True
-warn_unused_ignores = True
-warn_redundant_casts = True
-
-[pydocstyle]
-match = .*\.py
-ignore =
- D105
- D107
- D203
- D204
- D213
- D406
- D407
-
-[coverage:report]
-exclude_lines =
- pragma: no cover
- def __repr__
- if self.debug:
- raise
- if 0:
- if __name__ == .__main__.:
diff --git a/setup.py b/setup.py
deleted file mode 100644
index f69a7433b..000000000
--- a/setup.py
+++ /dev/null
@@ -1,48 +0,0 @@
-# Welcome to the Kornia setup.py.
-import sys
-
-# Make sure that kornia is running on Python 3.7.0 or later
-# (to avoid running into this bug: https://bugs.python.org/issue29246)
-
-if sys.version_info < (3, 7, 0):
- raise RuntimeError("Kornia requires Python 3.7.0 or later.")
-
-
-from setuptools import setup
-
-setup(
- install_requires=['packaging', 'torch>=1.9.1'],
- tests_require=['pytest'],
- setup_requires=['pytest-runner'],
- extras_require={
- 'dev': [
- 'isort',
- 'kornia-rs==0.0.8',
- 'mypy[reports]',
- 'numpy',
- 'opencv-python',
- 'pre-commit>=2.0',
- 'pydocstyle',
- 'pytest==7.2.1',
- 'pytest-cov==4.0.0',
- 'scipy',
- ],
- 'docs': [
- 'PyYAML>=5.1,<6.1.0',
- 'furo',
- 'matplotlib',
- 'opencv-python',
- 'sphinx>=4.0',
- 'sphinx-autodoc-defaultargs',
- 'sphinx-autodoc-typehints',
- 'sphinx-copybutton>=0.3',
- 'sphinx-design',
- 'sphinx-rtd-theme>0.5',
- 'sphinxcontrib-bibtex',
- 'sphinxcontrib-gtagjs',
- 'sphinxcontrib-youtube',
- 'torchvision',
- ],
- 'x': ['accelerate==0.16.0'],
- },
-)