Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[BUG] made kornia versions explicit to pytorch version (#597)

anguelos604bd213bb7e
diff --git a/setup.py b/setup.py
index fc1ad2dd2..203c49867 100644
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,27 @@ import distutils.command.clean
version = '0.3.2'
+
+# NOTE(maintainers): update this dictionary each time you do a release
+# When multiple pytorch versions are associated with a single version of kornia,
+# the oldest one is the requirement. The versions should be inequalities.
+# Once a pytorch version (in the future) breaks a kornia version, we could just
+# add a maximal version.
+kornia_pt_dependencies = {
+ '0.3.2': '>=1.5.0,<1.6.0', # torch==1.6.0 broke test/geometry/transform/test_crop.py
+ '0.3.1': '>=1.5.0',
+ '0.2.2': '>=1.4.0',
+ '0.1.4': '>=1.2.0',
+}
+
+
+# version can be overiden eg with KORNIA_BUILD_VERSION so we map each possible kornia version to the dictionary keys
+def dep_version(version):
+ compatible_versions = [v for v in kornia_pt_dependencies.keys() if v >= version]
+ compatible_versions += [sorted(kornia_pt_dependencies)[-1]]
+ return min(compatible_versions)
+
+
#################################
sha = 'Unknown'
@@ -73,14 +94,9 @@ class clean(distutils.command.clean.clean):
# remove compiled and temporary files
subprocess.call(['rm -rf dist/ build/ kornia.egg*'], shell=True)
-
-pytorch_dep = 'torch'
-if os.getenv('PYTORCH_VERSION'):
- pytorch_dep += "==" + os.getenv('PYTORCH_VERSION')
-
requirements = [
'numpy',
- pytorch_dep,
+ 'torch' + kornia_pt_dependencies[dep_version(version)],
]