SINGA-290 Upgrade to Python 3

use python2 as default; -DPYTHON3=ON for py3


Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/0f86cd5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/0f86cd5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/0f86cd5a

Branch: refs/heads/master
Commit: 0f86cd5a34968ab3cf46aee11291fed9dcad38fd
Parents: 57dbe42
Author: wangwei <[email protected]>
Authored: Wed Aug 2 14:37:20 2017 +0000
Committer: Wei Wang <[email protected]>
Committed: Fri Aug 4 16:32:04 2017 +0800

----------------------------------------------------------------------
 CMakeLists.txt           | 26 +++++++++++++-------------
 cmake/Dependencies.cmake | 10 +++++-----
 tool/conda/build.sh      |  4 +++-
 tool/conda/meta.yaml     | 25 ++++++++++---------------
 4 files changed, 31 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0f86cd5a/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbd4f9c..2a8210a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -192,10 +192,10 @@ IF(PACKAGE)
                SET(CORE_DEPENDENCIES "libgoogle-glog-dev, libprotobuf-dev, 
libopenblas-dev, libstdc++6, libc6")
        ENDIF()
 
-       IF(PYTHON2)
-               SET(PYTHON_DEPENDENCIES "${CORE_DEPENDENCIES}, python-dev, 
libpython2.7, python-pip, python-numpy, python-pillow")
-       ELSE()
+       IF(PYTHON3)
                SET(PYTHON_DEPENDENCIES "${CORE_DEPENDENCIES}, python3, 
python3-dev, python3-pip, python3-numpy, python3-pillow, python3-matplotlib")
+       ELSE()
+               SET(PYTHON_DEPENDENCIES "${CORE_DEPENDENCIES}, python-dev, 
libpython2.7, python-pip, python-numpy, python-pillow")
        ENDIF()
 
        SET(CPACK_GENERATOR "DEB")
@@ -210,16 +210,7 @@ IF(PACKAGE)
                SET(CPACK_DEBIAN_PACKAGE_DEPENDS ${PYTHON_DEPENDENCIES})
                SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
"${PROJECT_SOURCE_DIR}/tool/debian/postinst" )
                SET(CPACK_DEBIAN_PACKAGE_PREDEPENDS "ca-certificates")
-               IF(PYTHON2)
-                       SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
"${PROJECT_SOURCE_DIR}/tool/debian-python2/postinst" )
-                       IF (USE_CUDA)
-                               SET(CPACK_DEBIAN_PACKAGE_NAME 
"python-singa-cuda")
-                               SET(CPACK_PACKAGE_FILE_NAME 
"python-singa-cuda-${PACKAGE_VERSION}")
-                       ELSE()
-                               SET(CPACK_DEBIAN_PACKAGE_NAME "python-singa")
-                               SET(CPACK_PACKAGE_FILE_NAME 
"python-singa-${PACKAGE_VERSION}")
-                       ENDIF()
-               ELSE()
+               IF(PYTHON3)
                        SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
"${PROJECT_SOURCE_DIR}/tool/debian/postinst" )
                        IF (USE_CUDA)
                                SET(CPACK_DEBIAN_PACKAGE_NAME 
"python3-singa-cuda")
@@ -228,6 +219,15 @@ IF(PACKAGE)
                                SET(CPACK_DEBIAN_PACKAGE_NAME "python3-singa")
                                SET(CPACK_PACKAGE_FILE_NAME 
"python3-singa-${PACKAGE_VERSION}")
                        ENDIF()
+               ELSE()
+                       SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 
"${PROJECT_SOURCE_DIR}/tool/debian-python2/postinst" )
+                       IF (USE_CUDA)
+                               SET(CPACK_DEBIAN_PACKAGE_NAME 
"python-singa-cuda")
+                               SET(CPACK_PACKAGE_FILE_NAME 
"python-singa-cuda-${PACKAGE_VERSION}")
+                       ELSE()
+                               SET(CPACK_DEBIAN_PACKAGE_NAME "python-singa")
+                               SET(CPACK_PACKAGE_FILE_NAME 
"python-singa-${PACKAGE_VERSION}")
+                       ENDIF()
                ENDIF()
        ELSE()
                SET(CPACK_DEBIAN_PACKAGE_NAME "singa")

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0f86cd5a/cmake/Dependencies.cmake
----------------------------------------------------------------------
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 07736a0..956c121 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -124,15 +124,15 @@ ENDIF()
 #MESSAGE(STATUS "link lib : " ${SINGA_LINKER_LIBS})
 
 IF(USE_PYTHON)
-    IF(PYTHON2)
-        FIND_PACKAGE(PythonLibs 2.7 REQUIRED)
-        FIND_PACKAGE(PythonInterp 2.7 REQUIRED)
-       FIND_PACKAGE(SWIG 3.0.10 REQUIRED)
-    ELSE()
+    IF(PYTHON3)
         set(Python_ADDITIONAL_VERSIONS 3.6)
         FIND_PACKAGE(PythonLibs 3 REQUIRED)
         FIND_PACKAGE(PythonInterp 3 REQUIRED)
        FIND_PACKAGE(SWIG 3.0.10 REQUIRED)
+    ELSE()
+        FIND_PACKAGE(PythonLibs 2.7 REQUIRED)
+        FIND_PACKAGE(PythonInterp 2.7 REQUIRED)
+       FIND_PACKAGE(SWIG 3.0.10 REQUIRED)
     ENDIF()
 ENDIF()
 

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0f86cd5a/tool/conda/build.sh
----------------------------------------------------------------------
diff --git a/tool/conda/build.sh b/tool/conda/build.sh
index 7bd9023..6b3f262 100644
--- a/tool/conda/build.sh
+++ b/tool/conda/build.sh
@@ -28,6 +28,8 @@ cd build
 USE_CUDA=ON
 # singa with cuda and cudnn has the name as : singa-cudaxx-cudnnxx
 if  [ "$PKG_NAME" == "singa" ]; then USE_CUDA=OFF; fi
-cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DUSE_CUDA=$USE_CUDA ..
+PYTHON3=OFF
+if  [ "$PY3K" == "True" ]; then PYTHON3=ON; fi
+cmake -DCMAKE_INSTALL_PREFIX=$PREFIX -DUSE_CUDA=$USE_CUDA -DPYTHON3=$PYTHON3 ..
 make
 make install

http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/0f86cd5a/tool/conda/meta.yaml
----------------------------------------------------------------------
diff --git a/tool/conda/meta.yaml b/tool/conda/meta.yaml
index bb65ce4..1c2004d 100644
--- a/tool/conda/meta.yaml
+++ b/tool/conda/meta.yaml
@@ -3,8 +3,7 @@ package:
   version: "{{ GIT_DESCRIBE_TAG }}"
 
 source:
-  path: ../../
-
+  git_url: https://github.com/apache/incubator-singa.git
 
 build:
   number: {{ GIT_DESCRIBE_NUMBER }}
@@ -15,32 +14,28 @@ build:
 
 requirements:
   build:
-    - python 2.7* [py27]
-    - python 3.6* [py36]
-    - numpy >=1.10
-    - swig >=3.0
-    - openblas >=0.2.10
-    - protobuf 3.2
+    - swig 3.0.2
+    - openblas 0.2.19
+    - protobuf 3.2.0
     - glog 0.3.4
     - libgfortran 3.0.0 # [osx]
     - gcc 4.8.5 # [linux]
-    - python 2.7*
+    - python 2.7* [py27]
+    - python 3.6* [py36]
     - numpy 1.12.0
 
   run:
-    - python 2.7* [py27]
-    - python 3.6* [py36]
-    - numpy >=1.10
-    - protobuf 3.2
+    - openblas 0.2.19
+    - protobuf 3.2.0
     - glog 0.3.4
     - libgfortran 3.0.0 # [osx]
     - libgcc 4.8.5 # [linux]
-    - python 2.7*
+    - python 2.7* [py27]
+    - python 3.6* [py36]
     - numpy >=1.12.0
     - flask >=0.10.1
     - flask-cors >=3.0.2
     - pillow >=2.3.0
-    - libgcc 4.8.5 # [linux]
 
 test:
   source_files:

Reply via email to