From c40e5f561f60f689a19dfe2f4d9a959b320e5922 Mon Sep 17 00:00:00 2001 From: Nil Fons Miret Date: Fri, 12 Jan 2024 21:06:46 +0000 Subject: [PATCH 1/5] model.c: fix -Wlto-type-mismatch --- libvmaf/src/model.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libvmaf/src/model.c b/libvmaf/src/model.c index 9cf8a670a..ab623a9fd 100644 --- a/libvmaf/src/model.c +++ b/libvmaf/src/model.c @@ -21,24 +21,24 @@ typedef struct VmafBuiltInModel { #if VMAF_BUILT_IN_MODELS #if VMAF_FLOAT_FEATURES -extern const char src_vmaf_float_v0_6_1neg_json; +extern const char src_vmaf_float_v0_6_1neg_json[]; extern const int src_vmaf_float_v0_6_1neg_json_len; -extern const char src_vmaf_float_v0_6_1_json; +extern const char src_vmaf_float_v0_6_1_json[]; extern const int src_vmaf_float_v0_6_1_json_len; -extern const char src_vmaf_float_b_v0_6_3_json; +extern const char src_vmaf_float_b_v0_6_3_json[]; extern const int src_vmaf_float_b_v0_6_3_json_len; -extern const char src_vmaf_float_4k_v0_6_1_json; +extern const char src_vmaf_float_4k_v0_6_1_json[]; extern const int src_vmaf_float_4k_v0_6_1_json_len; #endif -extern const char src_vmaf_v0_6_1_json; +extern const char src_vmaf_v0_6_1_json[]; extern const int src_vmaf_v0_6_1_json_len; -extern const char src_vmaf_b_v0_6_3_json; +extern const char src_vmaf_b_v0_6_3_json[]; extern const int src_vmaf_b_v0_6_3_json_len; -extern const char src_vmaf_v0_6_1neg_json; +extern const char src_vmaf_v0_6_1neg_json[]; extern const int src_vmaf_v0_6_1neg_json_len; -extern const char src_vmaf_4k_v0_6_1_json; +extern const char src_vmaf_4k_v0_6_1_json[]; extern const int src_vmaf_4k_v0_6_1_json_len; -extern const char src_vmaf_4k_v0_6_1neg_json; +extern const char src_vmaf_4k_v0_6_1neg_json[]; extern const int src_vmaf_4k_v0_6_1neg_json_len; #endif @@ -47,48 +47,48 @@ static const VmafBuiltInModel built_in_models[] = { #if VMAF_FLOAT_FEATURES { .version = "vmaf_float_v0.6.1", - .data = &src_vmaf_float_v0_6_1_json, + .data = src_vmaf_float_v0_6_1_json, .data_len = &src_vmaf_float_v0_6_1_json_len, }, { .version = "vmaf_float_b_v0.6.3", - .data = &src_vmaf_float_b_v0_6_3_json, + .data = src_vmaf_float_b_v0_6_3_json, .data_len = &src_vmaf_float_b_v0_6_3_json_len, }, { .version = "vmaf_float_v0.6.1neg", - .data = &src_vmaf_float_v0_6_1neg_json, + .data = src_vmaf_float_v0_6_1neg_json, .data_len = &src_vmaf_float_v0_6_1neg_json_len, }, { .version = "vmaf_float_4k_v0.6.1", - .data = &src_vmaf_float_4k_v0_6_1_json, + .data = src_vmaf_float_4k_v0_6_1_json, .data_len = &src_vmaf_float_4k_v0_6_1_json_len, }, #endif { .version = "vmaf_v0.6.1", - .data = &src_vmaf_v0_6_1_json, + .data = src_vmaf_v0_6_1_json, .data_len = &src_vmaf_v0_6_1_json_len, }, { .version = "vmaf_b_v0.6.3", - .data = &src_vmaf_b_v0_6_3_json, + .data = src_vmaf_b_v0_6_3_json, .data_len = &src_vmaf_b_v0_6_3_json_len, }, { .version = "vmaf_v0.6.1neg", - .data = &src_vmaf_v0_6_1neg_json, + .data = src_vmaf_v0_6_1neg_json, .data_len = &src_vmaf_v0_6_1neg_json_len, }, { .version = "vmaf_4k_v0.6.1", - .data = &src_vmaf_4k_v0_6_1_json, + .data = src_vmaf_4k_v0_6_1_json, .data_len = &src_vmaf_4k_v0_6_1_json_len, }, { .version = "vmaf_4k_v0.6.1neg", - .data = &src_vmaf_4k_v0_6_1neg_json, + .data = src_vmaf_4k_v0_6_1neg_json, .data_len = &src_vmaf_4k_v0_6_1neg_json_len, }, #endif From 7b9e4c58b7b996d193fc5bf4325480dc4151f36c Mon Sep 17 00:00:00 2001 From: Christos Bampis Date: Thu, 7 Apr 2022 10:43:40 -0700 Subject: [PATCH 2/5] Start cleaning up setup.py --- python/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/setup.py b/python/setup.py index cd559c8c2..8c3c13bb9 100755 --- a/python/setup.py +++ b/python/setup.py @@ -53,6 +53,7 @@ def get_version(): "sureal>=0.4.2", "dill>=0.3.1", ], + setup_requires=["cython", "numpy"], entry_points = { 'console_scripts': [ 'run_cleaning_cache=vmaf.script.run_cleaning_cache:main', From fac14df32ca8757e886c355236debd7b51f991e4 Mon Sep 17 00:00:00 2001 From: Zoran Simic Date: Thu, 7 Apr 2022 11:34:17 -0700 Subject: [PATCH 3/5] Avoid importing cython "too early" in setup.py --- python/requirements.txt | 1 - python/setup.py | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/python/requirements.txt b/python/requirements.txt index 1e453240c..e6a249bf9 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -7,7 +7,6 @@ scikit-image>=0.16.2 h5py>=2.6.0 sureal>=0.4.2 dill>=0.3.1 -cython PyWavelets>=1.1.1 python-slugify>=5.0.0 libsvm-official>=3.30 diff --git a/python/setup.py b/python/setup.py index 8c3c13bb9..51839b3c6 100755 --- a/python/setup.py +++ b/python/setup.py @@ -9,9 +9,8 @@ """ import os -from distutils.core import setup -from Cython.Build import cythonize -import numpy + +from setuptools import setup PYTHON_PROJECT = os.path.dirname(os.path.abspath(__file__)) @@ -24,12 +23,38 @@ def get_version(): for line in fh: if line.startswith("__version__"): return line.strip().rpartition(" ")[2].replace('"', "") + except Exception: pass + return "0.0-dev" -ext_module = cythonize(['vmaf/core/adm_dwt2_cy.pyx']) -ext_module[0].include_dirs = [numpy.get_include(), '../libvmaf/src'] + +class LazyExtensions(list): + _extensions = None + + @property + def extensions(self): + if self._extensions is None: + from Cython.Build import cythonize + import numpy + + self._extensions = cythonize([ + 'vmaf/core/adm_dwt2_cy.pyx' + ]) + self._extensions[0].include_dirs = [numpy.get_include(), '../libvmaf/src'] + + return self._extensions + + def __iter__(self): + return iter(self.extensions) + + def __contains__(self, value): + return value in self.extensions + + def __len__(self): + return len(self.extensions) + setup( name="vmaf", @@ -67,5 +92,5 @@ def get_version(): 'run_vmaf_training=vmaf.script.run_vmaf_training:main', ], }, - ext_modules=ext_module, + ext_modules=LazyExtensions(), ) From 03d31171b4ed7ec78ae3e87bdb553a56dfe105b4 Mon Sep 17 00:00:00 2001 From: Zoran Simic Date: Thu, 7 Apr 2022 16:39:26 -0700 Subject: [PATCH 4/5] Use pyproject.toml --- python/pyproject.toml | 2 ++ python/setup.py | 1 - python/tox.ini | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 python/pyproject.toml diff --git a/python/pyproject.toml b/python/pyproject.toml new file mode 100644 index 000000000..83de03ad5 --- /dev/null +++ b/python/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ["setuptools", "wheel", "Cython", "numpy"] diff --git a/python/setup.py b/python/setup.py index 51839b3c6..3202abf04 100755 --- a/python/setup.py +++ b/python/setup.py @@ -78,7 +78,6 @@ def __len__(self): "sureal>=0.4.2", "dill>=0.3.1", ], - setup_requires=["cython", "numpy"], entry_points = { 'console_scripts': [ 'run_cleaning_cache=vmaf.script.run_cleaning_cache:main', diff --git a/python/tox.ini b/python/tox.ini index cdd98a8dc..0a064f139 100644 --- a/python/tox.ini +++ b/python/tox.ini @@ -1,6 +1,5 @@ [tox] envlist = py38, coverage -skip_missing_interpreters = true [testenv] From b6548d4625e5393aebdb9385a55a56057f22bdf8 Mon Sep 17 00:00:00 2001 From: Zhi Li Date: Sat, 28 Jan 2023 12:22:50 -0800 Subject: [PATCH 5/5] Add language_level to cythonize to fix adm_dwt2_cy build issue. --- python/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/setup.py b/python/setup.py index 3202abf04..bb4bf3406 100755 --- a/python/setup.py +++ b/python/setup.py @@ -41,7 +41,7 @@ def extensions(self): self._extensions = cythonize([ 'vmaf/core/adm_dwt2_cy.pyx' - ]) + ], compiler_directives={'language_level' : "3"}) self._extensions[0].include_dirs = [numpy.get_include(), '../libvmaf/src'] return self._extensions