update python3.9

pull/12450/head
yepei6 4 years ago
parent 69af6643d3
commit 4f16b2542e

@ -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_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/flatbuffers/include/flatbuffers)
include(${CMAKE_SOURCE_DIR}/cmake/dependency_utils.cmake) 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) if(Python3_FOUND)
set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}") set(PYTHON_INCLUDE_DIRS "${Python3_INCLUDE_DIRS}")
set(PYTHON_LIBRARIES "${Python3_LIBRARIES}") set(PYTHON_LIBRARIES "${Python3_LIBRARIES}")

@ -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) function(find_required_package pkg_name)
find_package(${pkg_name}) find_package(${pkg_name})
if(NOT ${pkg_name}_FOUND) if(NOT ${pkg_name}_FOUND)
@ -24,7 +24,7 @@ if(Python3_FOUND)
message("Python3 library path: ${Python3_LIBRARY}") message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}") message("Python3 interpreter: ${Python3_EXECUTABLE}")
elseif(Python3_LIBRARY AND Python3_EXECUTABLE AND 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(WARNING "Maybe python3 environment is broken.")
message("Python3 library path: ${Python3_LIBRARY}") message("Python3 library path: ${Python3_LIBRARY}")
message("Python3 interpreter: ${Python3_EXECUTABLE}") message("Python3 interpreter: ${Python3_EXECUTABLE}")

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

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

@ -1,5 +1,5 @@
# find exec # find exec
find_package(Python3 3.7 COMPONENTS Interpreter) find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_FOUND) if(NOT Python3_FOUND)
message(FATAL_ERROR "No python3 found.") message(FATAL_ERROR "No python3 found.")
endif() endif()
@ -7,8 +7,8 @@ endif()
set(PYTHON ${Python3_EXECUTABLE}) set(PYTHON ${Python3_EXECUTABLE})
set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) set(PYTHON_VERSION ${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
if(NOT (PYTHON_VERSION MATCHES "3.8" OR PYTHON_VERSION MATCHES "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.8 OR 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() endif()
find_package(Git) find_package(Git)
@ -24,32 +24,38 @@ set(MS_PACK_ROOT_DIR ${MS_ROOT_DIR}/build/package)
# set package file name # set package file name
if(CMAKE_SYSTEM_NAME MATCHES "Linux") 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") set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7") elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m") set(PY_TAGS "cp37-cp37m")
else() 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() return()
endif() endif()
string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG) string(TOLOWER linux_${CMAKE_HOST_SYSTEM_PROCESSOR} PLATFORM_TAG)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") 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") set(PY_TAGS "py38-none")
elseif(PYTHON_VERSION MATCHES "3.7") elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "py37-none") set(PY_TAGS "py37-none")
else() 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() return()
endif() endif()
set(PLATFORM_TAG "any") set(PLATFORM_TAG "any")
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") 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") set(PY_TAGS "cp38-cp38")
elseif(PYTHON_VERSION MATCHES "3.7") elseif(PYTHON_VERSION MATCHES "3.7")
set(PY_TAGS "cp37-cp37m") set(PY_TAGS "cp37-cp37m")
else() 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() return()
endif() endif()
set(PLATFORM_TAG "win_amd64") set(PLATFORM_TAG "win_amd64")

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

Loading…
Cancel
Save