!12450 python3.9 update

From: @yepei6
Reviewed-by: 
Signed-off-by:
This commit is contained in:
mindspore-ci-bot 2021-03-24 15:29:43 +08:00 committed by Gitee
commit d926e8e4f4
6 changed files with 183 additions and 74 deletions

View File

@ -51,7 +51,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include/flatbuffers)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake)
find_package(Python3 3.7 COMPONENTS Interpreter Development)
find_package(Python3 COMPONENTS Interpreter Development)
if(Python3_FOUND)
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")

View File

@ -1,4 +1,4 @@
## define customized find fucntions, print customized error messages
## define customized find functions, print customized error messages
function(find_required_package pkg_name)
find_package(${pkg_name})
if(NOT ${pkg_name}_FOUND)
@ -24,7 +24,7 @@ if(Python3_FOUND)
message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}")
elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND
${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.8.9")
${Python3_VERSION} VERSION_GREATER_EQUAL "3.7.0" AND ${Python3_VERSION} VERSION_LESS "3.9.9")
message(WARNING "Maybe python3 environment is broken.")
message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}")

View File

@ -18,70 +18,149 @@ else()
endif()
if(ENABLE_GITEE)
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.2.0.tar.gz")
set(MD5 "00424c7c4acde1e26ebf17aaa155bf23")
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.5.1.tar.gz")
set(MD5 "e74309207f2fa88fb6cc417d8ea9ff09")
elseif((PYTHON_VERSION MATCHES "3.7") OR (PYTHON_VERSION MATCHES "3.8"))
set(REQ_URL "https://gitee.com/mirrors/opencv/repository/archive/4.2.0.tar.gz")
set(MD5 "00424c7c4acde1e26ebf17aaa155bf23")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
else()
set(REQ_URL "https://github.com/opencv/opencv/archive/4.2.0.tar.gz")
set(MD5 "e8cb208ce2723481408b604b480183b6")
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://github.com/opencv/opencv/archive/4.5.1.tar.gz")
set(MD5 "2205d3169238ec1f184438a96de68513")
elseif((PYTHON_VERSION MATCHES "3.7") OR (PYTHON_VERSION MATCHES "3.8"))
set(REQ_URL "https://github.com/opencv/opencv/archive/4.2.0.tar.gz")
set(MD5 "e8cb208ce2723481408b604b480183b6")
else()
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
endif()
if(WIN32)
mindspore_add_pkg(opencv
VER 4.2.0
LIBS libopencv_core420.dll.a libopencv_imgcodecs420.dll.a libopencv_imgproc420.dll.a
LIB_PATH x64/mingw/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF -DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
if(PYTHON_VERSION MATCHES "3.9")
mindspore_add_pkg(opencv
VER 4.5.1
LIBS libopencv_core451.dll.a libopencv_imgcodecs451.dll.a libopencv_imgproc451.dll.a
LIB_PATH x64/mingw/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
elseif(PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7")
mindspore_add_pkg(opencv
VER 4.2.0
LIBS libopencv_core420.dll.a libopencv_imgcodecs420.dll.a libopencv_imgproc420.dll.a
LIB_PATH x64/mingw/lib
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DBUILD_opencv_videoio=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
endif()
else()
mindspore_add_pkg(opencv
VER 4.2.0
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF -DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
if(PYTHON_VERSION MATCHES "3.9")
mindspore_add_pkg(opencv
VER 4.5.1
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
elseif(PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7")
mindspore_add_pkg(opencv
VER 4.2.0
LIBS opencv_core opencv_imgcodecs opencv_imgproc
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DCMAKE_BUILD_TYPE=Release -DWITH_PROTOBUF=OFF -DWITH_WEBP=OFF -DWITH_IPP=OFF
-DWITH_ADE=OFF
-DBUILD_ZLIB=ON
-DBUILD_JPEG=ON
-DBUILD_PNG=ON
-DBUILD_OPENEXR=ON
-DBUILD_TESTS=OFF
-DBUILD_PERF_TESTS=OFF
-DBUILD_opencv_apps=OFF
-DCMAKE_SKIP_RPATH=TRUE
-DBUILD_opencv_python3=OFF
-DWITH_FFMPEG=OFF
-DWITH_TIFF=ON
-DBUILD_TIFF=OFF
-DWITH_JASPER=OFF
-DBUILD_JASPER=OFF
-DWITH_LAPACK=OFF
-DTIFF_INCLUDE_DIR=${tiff_INC}
-DTIFF_LIBRARY=${tiff_LIB})
endif()
endif()
if(WIN32)
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core420.dll.a)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs420.dll.a)
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc420.dll.a)
if(PYTHON_VERSION MATCHES "3.9")
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core451.dll.a)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs451.dll.a)
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc451.dll.a)
elseif(PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7")
include_directories(${opencv_INC})
add_library(mindspore::opencv_core ALIAS opencv::libopencv_core420.dll.a)
add_library(mindspore::opencv_imgcodecs ALIAS opencv::libopencv_imgcodecs420.dll.a)
add_library(mindspore::opencv_imgproc ALIAS opencv::libopencv_imgproc420.dll.a)
endif()
else()
include_directories(${opencv_INC}/opencv4)
add_library(mindspore::opencv_core ALIAS opencv::opencv_core)

View File

@ -1,36 +1,60 @@
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
if(ENABLE_GITEE)
if(PYTHON_VERSION MATCHES "3.8")
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "a9b7642031f35daf33a75fe837b3dd31")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.6.1.tar.gz")
set(MD5 "a9b7642031f35daf33a75fe837b3dd31")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://gitee.com/mirrors/pybind11/repository/archive/v2.4.3.tar.gz")
set(MD5 "b473a37987ce456ea8cc7aab3f9486f9")
else()
message("Could not find 'Python 3.8' or 'Python 3.7'")
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
else()
if(PYTHON_VERSION MATCHES "3.8")
if(PYTHON_VERSION MATCHES "3.9")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.8")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.6.1.tar.gz")
set(MD5 "32a7811f3db423df4ebfc731a28e5901")
elseif(PYTHON_VERSION MATCHES "3.7")
set(REQ_URL "https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz")
set(MD5 "62254c40f89925bb894be421fe4cdef2")
else()
message("Could not find 'Python 3.8' or 'Python 3.7'")
message("Could not find 'Python 3.8' or 'Python 3.7' or 'Python 3.9'")
return()
endif()
endif()
set(pybind11_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(pybind11_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
mindspore_add_pkg(pybind11
if(PYTHON_VERSION MATCHES "3.9")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
elseif(PYTHON_VERSION MATCHES "3.8")
mindspore_add_pkg(pybind11
VER 2.6.1
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
else()
mindspore_add_pkg(pybind11
VER 2.4.3
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DPYBIND11_TEST=OFF -DPYBIND11_LTO_CXX_FLAGS=FALSE
)
endif()
include_directories(${pybind11_INC})
find_package(pybind11 REQUIRED)
set_property(TARGET pybind11::module PROPERTY IMPORTED_GLOBAL TRUE)

View File

@ -1,5 +1,5 @@
# find exec
find_package(Python3 3.7 COMPONENTS Interpreter)
find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_FOUND)
message(FATAL_ERROR "No python3 found.")
endif()
@ -7,8 +7,8 @@ endif()
set(PYTHON ${Python3_EXECUTABLE})
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
if(NOT (PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7"))
message(FATAL_ERROR "FIND PYTHON VERSION ${PYTHON_VERSION} BUT CAN NOT MATCH PYTHON VERSION 3.8 OR 3.7")
if(NOT (PYTHON_VERSION MATCHES "3.9" OR PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "3.7"))
message(FATAL_ERROR "FIND PYTHON VERSION ${PYTHON_VERSION} BUT CAN NOT MATCH PYTHON VERSION 3.9 OR 3.8 OR 3.7")
endif()
find_package(Git)
@ -24,32 +24,38 @@ set(MS_PACK_ROOT_DIR ${MS_ROOT_DIR}/build/package)
# set package file name
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(PYTHON_VERSION MATCHES "3.8")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "cp39-cp39")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m")
else()
message("Could not find 'Python 3.8' or 'Python 3.7'")
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if(PYTHON_VERSION MATCHES "3.8")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "py39-none")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "py38-none")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "py37-none")
else()
message("Could not find 'Python 3.8' or 'Python 3.7'")
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
set(PLATFORM_TAG "any")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
if(PYTHON_VERSION MATCHES "3.8")
if(PYTHON_VERSION MATCHES "3.9")
set(PY_TAGS "cp39-cp39")
elseif(PYTHON_VERSION MATCHES "3.8")
set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m")
else()
message("Could not find 'Python 3.8' or 'Python 3.7'")
message("Could not find 'Python 3.9' OR 'Python 3.8' or 'Python 3.7'")
return()
endif()
set(PLATFORM_TAG "win_amd64")

View File

@ -15,7 +15,7 @@
""".. MindSpore package."""
from ._check_version import check_version_and_env_config
from . import common, train
from . import common, train, log
from .common import *
from .ops import _op_impl
from .train import *