/; in Linux, in just python/X.Y/.
# Naming conventions vary so widely between versions and OSes
# had to give up on checking them.
+ # If not specifying PY_LIMITED_API, the Python sources go under python/cv2/python-3.MINOR_VERSION/ instead of python/cv2/python-3/
[
- r"python/cv2/python-%s/cv2.*"
+ r"python/cv2/python-%s*/cv2.*"
+ % (sys.version_info[0]) if 'CMAKE_ARGS' in os.environ and "-DPYTHON3_LIMITED_API=ON" in os.environ['CMAKE_ARGS']
+ else r"python/cv2/python-%s.*/cv2.*"
% (sys.version_info[0])
]
+
@@ -124,7 +128,10 @@ def main():
+
[
r"python/cv2/.*config.*.py"
- ],
+ ]
+ +
+ [ r"python/cv2/py.typed" ] if sys.version_info >= (3, 6) else []
+ ,
"cv2.data": [ # OPENCV_OTHER_INSTALL_PATH
("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml"
],
@@ -142,12 +149,15 @@ def main():
],
}
+ if sys.version_info >= (3, 6):
+ rearrange_cmake_output_data["cv2.typing"] = ["python/cv2" + r"/typing/.*\.py"]
+
# Files in sourcetree outside package dir that should be copied to package.
# Raw paths relative to sourcetree root.
files_outside_package_dir = {"cv2": ["LICENSE.txt", "LICENSE-3RD-PARTY.txt"]}
ci_cmake_generator = (
- ["-G", "Visual Studio 14" + (" Win64" if is64 else "")]
+ ["-G", "Visual Studio 17 2022"]
if os.name == "nt"
else ["-G", "Unix Makefiles"]
)
@@ -157,6 +167,7 @@ def main():
+ [
# skbuild inserts PYTHON_* vars. That doesn't satisfy opencv build scripts in case of Py3
"-DPYTHON3_EXECUTABLE=%s" % sys.executable,
+ "-DPYTHON_DEFAULT_EXECUTABLE=%s" % sys.executable,
"-DPYTHON3_INCLUDE_DIR=%s" % python_include_dir,
"-DPYTHON3_LIBRARY=%s" % python_lib_path,
"-DBUILD_opencv_python3=ON",
@@ -203,10 +214,10 @@ def main():
cmake_args.append("-DWITH_WIN32UI=OFF")
cmake_args.append("-DWITH_QT=OFF")
cmake_args.append("-DWITH_GTK=OFF")
- if is_CI_build:
- cmake_args.append(
- "-DWITH_MSMF=OFF"
- ) # see: https://github.com/skvark/opencv-python/issues/263
+ # see: https://github.com/skvark/opencv-python/issues/263
+ # see: https://github.com/opencv/opencv-python/issues/771
+ cmake_args.append("-DWITH_MSMF=OFF")
+ cmake_args.append("-DWITH_OBSENSOR=OFF") # Orbbec cameras backend uses MSMF API
if sys.platform.startswith("linux") and not is64 and "bdist_wheel" in sys.argv:
subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
@@ -247,19 +258,12 @@ def main():
cmake_args.append("-DWITH_LAPACK=ON")
cmake_args.append("-DENABLE_PRECOMPILED_HEADERS=OFF")
- # https://github.com/scikit-build/scikit-build/issues/479
- if "CMAKE_ARGS" in os.environ:
- import shlex
-
- cmake_args.extend(shlex.split(os.environ["CMAKE_ARGS"]))
- del shlex
-
# works via side effect
RearrangeCMakeOutput(
rearrange_cmake_output_data, files_outside_package_dir, package_data.keys()
)
- skbuild.setup(
+ setup(
name=package_name,
version=package_version,
url="https://github.com/opencv/opencv-python",
@@ -294,6 +298,8 @@ def main():
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.12",
+ "Programming Language :: Python :: 3.13",
"Programming Language :: C++",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering",
@@ -304,8 +310,9 @@ def main():
cmake_source_dir=cmake_source_dir,
)
+ print("OpenCV is raising funds to keep the library free for everyone, and we need the support of the entire community to do it. Donate to OpenCV on GitHub:\nhttps://github.com/sponsors/opencv\n")
-class RearrangeCMakeOutput(object):
+class RearrangeCMakeOutput:
"""
Patch SKBuild logic to only take files related to the Python package
and construct a file hierarchy that SKBuild expects (see below)
@@ -386,7 +393,6 @@ def _classify_installed_files_override(
p.replace(os.path.sep, "/") for p in install_relpaths
]
relpaths_zip = list(zip(fslash_install_relpaths, install_relpaths))
- del install_relpaths, fslash_install_relpaths
final_install_relpaths = []
@@ -395,10 +401,29 @@ def _classify_installed_files_override(
# add lines from the old __init__.py file to the config file
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
custom_init_data = custom_init.read()
- with open('%spython/cv2/config-%s.py'
- % (cmake_install_dir, sys.version_info[0]), 'w') as opencv_init_config:
+
+ # OpenCV generates config with different name for case with PYTHON3_LIMITED_API=ON
+ config_py = os.path.join(cmake_install_dir, 'python', 'cv2', 'config-%s.%s.py'
+ % (sys.version_info[0], sys.version_info[1]))
+ if not os.path.exists(config_py):
+ config_py = os.path.join(cmake_install_dir, 'python', 'cv2', 'config-%s.py' % sys.version_info[0])
+
+ with open(config_py, 'w') as opencv_init_config:
opencv_init_config.write(custom_init_data)
+ if sys.version_info >= (3, 6):
+ for p in install_relpaths:
+ if p.endswith(".pyi"):
+ target_rel_path = os.path.relpath(p, "python/cv2")
+ cls._setuptools_wrap._copy_file(
+ os.path.join(cmake_install_dir, p),
+ os.path.join(cmake_install_dir, "cv2", target_rel_path),
+ hide_listing=False,
+ )
+ final_install_relpaths.append(os.path.join("cv2", target_rel_path))
+
+ del install_relpaths, fslash_install_relpaths
+
for package_name, relpaths_re in cls.package_paths_re.items():
package_dest_reldir = package_name.replace(".", os.path.sep)
for relpath_re in relpaths_re:
diff --git a/travis_config.sh b/travis_config.sh
index b91d63c4..2e5e1a0e 100644
--- a/travis_config.sh
+++ b/travis_config.sh
@@ -34,7 +34,7 @@ if [ -n "$IS_OSX" ]; then
export MAKEFLAGS="-j$(sysctl -n hw.ncpu)"
else
echo " > Linux environment "
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.15.0/lib
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.15.16/lib
export MAKEFLAGS="-j$(grep -E '^processor[[:space:]]*:' /proc/cpuinfo | wc -l)"
CURRENT_ARCH=$(uname -m)
if [[ $CURRENT_ARCH == 'aarch64' ]]; then
@@ -103,6 +103,7 @@ function pre_build {
if [ -n "$IS_OSX" ]; then
brew install lapack
+ brew install libavif
fi
if [ -n "$IS_OSX" ]; then
diff --git a/travis_osx_brew_cache.sh b/travis_osx_brew_cache.sh
index 1a2a1c6c..42e71446 100644
--- a/travis_osx_brew_cache.sh
+++ b/travis_osx_brew_cache.sh
@@ -265,14 +265,14 @@ function _brew_parse_bottle_json {
local JSON; JSON="${1:?}"; shift
- local JSON_DATA; JSON_DATA=$(python2.7 -c 'if True:
+ local JSON_DATA; JSON_DATA=$(python3 -c 'if True:
import sys,json; j=json.load(open(sys.argv[1],"rb")); [name]=j.keys(); [pdata]=j.values()
- print name
- print pdata["formula"]["pkg_version"]
- print pdata["bottle"]["rebuild"]
+ print(name)
+ print(pdata["formula"]["pkg_version"])
+ print(pdata["bottle"]["rebuild"])
[(tag_name, tag_dict)]=pdata["bottle"]["tags"].items()
- print tag_name
- print tag_dict["sha256"]
+ print(tag_name)
+ print(tag_dict["sha256"])
' "$JSON")
unset JSON
@@ -292,15 +292,15 @@ function _brew_parse_package_info {
PACKAGE="${1:?}"; shift
OS_CODENAME="${1:?}"; shift
- local JSON_DATA; JSON_DATA=$(python2.7 -c 'if True:
+ local JSON_DATA; JSON_DATA=$(python3 -c 'if True:
import sys, json, subprocess; j=json.loads(subprocess.check_output(("brew","info","--json=v1",sys.argv[1])))
data=j[0]
revision=data["revision"]
# in bottle''s json, revision is included into version; here, they are separate
- print data["versions"]["stable"]+("_"+str(revision) if revision else "")
+ print(data["versions"]["stable"]+("_"+str(revision) if revision else ""))
bottle_data=data["bottle"].get("stable",{"rebuild":"","files":{}})
- print bottle_data["rebuild"]
- print bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"] #prevent losing trailing blank line to command substitution
+ print(bottle_data["rebuild"])
+ print(bottle_data["files"].get(sys.argv[2],{"sha256":"!?"})["sha256"]) #prevent losing trailing blank line to command substitution
' \
"$PACKAGE" "$OS_CODENAME"); JSON_DATA="${JSON_DATA%\!\?}" #!? can't occur in a hash
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy