Repository: kornia/kornia

Issue:
Package includes test.geometry module
The package distribution includes `test.geometry`.

setup.py needs:

```diff,python
-        packages=find_packages(exclude=('docs', 'test', 'examples')),
+        packages=find_packages(exclude=('docs', 'test', 'test.*', 'examples')),
```

(Might as well go wildcard.)


Discussion:
Hi, can you send a PR with the fix?
No, I’m not invested in this or interested in engaging further; just a drive-by bug report.
One suggestion I have is to move the entire setup to declarative metadata, it makes the setup clearer. Also, can use tools (pre-commit hook) to ensure the sanity (https://github.com/asottile/setup-cfg-fmt)
Sounds like a good idea. Recently played a bit with setup.cfg and makes everything more readable. Bit busy this days but I can try something unless anyone wants to volunteer before 
I can do this in some moment this week

Resolving patch:
diff --git a/kornia/__init__.py b/kornia/__init__.py
--- a/kornia/__init__.py
+++ b/kornia/__init__.py
@@ -1,6 +1,3 @@
-# import the version variable
-from ._version import __version__
-
 # NOTE: kornia filters and geometry must go first since are the core of the library
 # and by changing the import order you might get into a circular dependencies issue.
 from . import filters
@@ -14,3 +11,13 @@
 from kornia.constants import pi
 from kornia.testing import xla_is_available
 from kornia.utils import eye_like, vec_like, create_meshgrid, image_to_tensor, tensor_to_image
+
+# Version variable
+import sys
+
+if sys.version_info >= (3, 8):  # pragma: >=3.8 cover
+    import importlib.metadata as importlib_metadata
+else:  # pragma: <3.8 cover
+    import importlib_metadata
+
+__version__ = importlib_metadata.version('kornia')
diff --git a/kornia/_version.py b/kornia/_version.py
deleted file mode 100644
--- a/kornia/_version.py
+++ /dev/null
@@ -1 +0,0 @@
-__version__ = "0.6.8-dev"
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,6 +1,4 @@
 # Welcome to the Kornia setup.py.
-#
-import re
 import sys
 
 # Make sure that kornia is running on Python 3.6.0 or later
@@ -10,87 +8,6 @@
     raise RuntimeError("Kornia requires Python 3.6.0 or later.")
 
 
-from setuptools import find_packages, setup
+from setuptools import setup
 
-
-def find_version(file_path: str) -> str:
-    version_file = open(file_path).read()
-    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
-    if not version_match:
-        raise RuntimeError(f"Unable to find version string in {file_path}")
-    return version_match.group(1)
-
-
-VERSION = find_version("kornia/_version.py")
-
-
-# NOTE: kornia MUST only require PyTorch
-requirements = ['torch>=1.8.1', 'packaging']
-
-# open readme file and set long description
-with open("README.md", encoding="utf-8") as fh:
-    long_description = fh.read()
-
-
-def load_requirements(filename: str):
-    with open(filename) as f:
-        return [x.strip() for x in f.readlines() if "-r" != x[0:2]]
-
-
-requirements_extras = {"x": load_requirements("requirements/x.txt"), "dev": load_requirements("requirements/dev.txt")}
-requirements_extras["all"] = requirements_extras["x"] + requirements_extras["dev"]
-
-
-if __name__ == '__main__':
-    setup(
-        name='kornia',
-        version=VERSION,
-        author='Edgar Riba',
-        author_email='edgar@kornia.org',
-        url='https://www.kornia.org',
-        download_url='https://github.com/kornia/kornia',
-        license='Apache License 2.0',
-        description='Open Source Differentiable Computer Vision Library for PyTorch',
-        long_description=long_description,
-        long_description_content_type='text/markdown',
-        python_requires='>=3.6',
-        setup_requires=['pytest-runner'],
-        tests_require=['pytest'],
-        packages=find_packages(exclude=('docs', 'test', 'examples')),
-        package_data={"kornia": ["py.typed"]},
-        data_files=[('', ['requirements/x.txt', 'requirements/dev.txt'])],
-        zip_safe=True,
-        install_requires=requirements,
-        extras_require=requirements_extras,
-        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",
-        },
-        classifiers=[
-            'Environment :: GPU',
-            'Environment :: Console',
-            'Natural Language :: English',
-            # How mature is this project? Common values are
-            #   3 - Alpha, 4 - Beta, 5 - Production/Stable
-            'Development Status :: 4 - Beta',
-            # Indicate who your project is intended for
-            'Intended Audience :: Developers',
-            'Intended Audience :: Education',
-            'Intended Audience :: Science/Research',
-            'Intended Audience :: Information Technology',
-            'Topic :: Software Development :: Libraries',
-            'Topic :: Scientific/Engineering :: Artificial Intelligence',
-            'Topic :: Scientific/Engineering :: Image Processing',
-            # Pick your license as you wish
-            'License :: OSI Approved :: Apache Software License',
-            'Operating System :: OS Independent',
-            # Specify the Python versions you support here. In particular, ensure
-            # that you indicate whether you support Python 2, Python 3 or both.
-            'Programming Language :: Python :: 3',
-            'Programming Language :: Python :: 3.6',
-            'Programming Language :: Python :: 3.7',
-            'Programming Language :: Python :: 3.8',
-        ],
-    )
+setup()


Test patch:
diff --git a/.github/workflows/test_typing.yml b/.github/workflows/test_typing.yml
--- a/.github/workflows/test_typing.yml
+++ b/.github/workflows/test_typing.yml
@@ -33,7 +33,7 @@ jobs:
       run: |
         conda install curl -c conda-forge
         conda install pytorch cpuonly -c pytorch-lts
-        pip install .[all]
+        pip install .[dev,x]
     - name: Run Tests
       shell: bash -l {0}
       run: pytest -v --cov=kornia --cov-report xml --mypy kornia/ -m mypy
diff --git a/.github/workflows/tests_cpu.yml b/.github/workflows/tests_cpu.yml
--- a/.github/workflows/tests_cpu.yml
+++ b/.github/workflows/tests_cpu.yml
@@ -34,7 +34,7 @@ jobs:
       run: |
         conda install curl -c conda-forge
         conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c pytorch
-        pip install .[all]
+        pip install .[dev,x]
     - name: Run Tests
       shell: bash -l {0}
       run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test --mypy
diff --git a/.github/workflows/tests_cuda.yml b/.github/workflows/tests_cuda.yml
--- a/.github/workflows/tests_cuda.yml
+++ b/.github/workflows/tests_cuda.yml
@@ -23,7 +23,7 @@ jobs:
       run: |
         # NOTE: pytorch image does not include git
         conda install -c anaconda git
-        pip install .[all]
+        pip install .[dev,x]
     - name: Run Tests
       shell: bash -l {0}
       run: pytest -v --device cuda --dtype float32,float64 ./test
diff --git a/.github/workflows/tests_lts.yml b/.github/workflows/tests_lts.yml
--- a/.github/workflows/tests_lts.yml
+++ b/.github/workflows/tests_lts.yml
@@ -33,7 +33,7 @@ jobs:
       run: |
         conda install curl -c conda-forge
         conda install pytorch cpuonly -c pytorch-lts
-        pip install .[all]
+        pip install .[dev,x]
     - name: Run Tests
       shell: bash -l {0}
       run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test --mypy
diff --git a/.github/workflows/tests_nightly.yml b/.github/workflows/tests_nightly.yml
--- a/.github/workflows/tests_nightly.yml
+++ b/.github/workflows/tests_nightly.yml
@@ -28,7 +28,7 @@ jobs:
       run: |
         conda install curl -c conda-forge
         conda install pytorch cpuonly -c pytorch-nightly
-        pip install .[all]
+        pip install .[dev,x]
     - name: Run Tests
       shell: bash -l {0}
       run: pytest -v --device cpu --dtype float32,float64 ./test --flake8 --mypy