Skip to content

Commit

Permalink
wheel creation windows compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
yxlao committed Oct 9, 2018
1 parent ddab597 commit 8e36aa8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/Python/CMakeLists.txt
Expand Up @@ -28,6 +28,7 @@ if (NOT PYTHON_EXECUTABLE)
# find_package(PythonInterp REQUIRED) returns the system python
# find_program will returns the python executable in current PATH, which
# works with virtualenv
# Note: make sure to run `cmake ..` within your virtual environment!
find_program(PYTHON_IN_PATH "python")
set(PYTHON_EXECUTABLE ${PYTHON_IN_PATH})
endif()
Expand Down Expand Up @@ -70,7 +71,7 @@ add_custom_target(python-package
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/Package
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
-DPYTHON_COMPILED_MODULE_PATH=${PYTHON_COMPILED_MODULE_DIR}/$<TARGET_FILE_NAME:${PACKAGE_NAME}>
-DPYTHON_COMPILED_MODULE_PATH=$<TARGET_FILE:${PACKAGE_NAME}>
-DPROJECT_EMAIL=${PROJECT_EMAIL}
-DPROJECT_HOME=${PROJECT_HOME}
-DPROJECT_DOCS=${PROJECT_DOCS}
Expand All @@ -90,10 +91,10 @@ add_custom_target(pip-wheel

# Use `make install-pip-wheel` to install pip wheel package to the current
# python environment.
# Note: Since `make python-package` clears PYTHON_COMPILED_MODULE_DIR every time,
# it is guaranteed that there is only one wheel in ${PYTHON_PACKAGE_DST_DIR}/dist/*.whl
add_custom_target(install-pip-wheel
COMMAND pip install ${PYTHON_PACKAGE_DST_DIR}/dist/*.whl
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/install_pip_wheel.cmake
DEPENDS pip-wheel
)

Expand All @@ -106,7 +107,7 @@ add_custom_target(all-pip-wheels
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/Package
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
-DPYTHON_COMPILED_MODULE_PATH=${PYTHON_COMPILED_MODULE_DIR}/$<TARGET_FILE_NAME:${PACKAGE_NAME}>
-DPYTHON_COMPILED_MODULE_PATH=$<TARGET_FILE:${PACKAGE_NAME}>
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPROJECT_EMAIL=${PROJECT_EMAIL}
-DPROJECT_HOME=${PROJECT_HOME}
Expand Down
33 changes: 33 additions & 0 deletions src/Python/install_pip_wheel.cmake
@@ -0,0 +1,33 @@
# ----------------------------------------------------------------------------
# - Open3D: www.open3d.org -
# ----------------------------------------------------------------------------
# The MIT License (MIT)
#
# Copyright (c) 2018 www.open3d.org
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

# We need this file for cross-platform support on Windows
# For Ubuntu/Mac, we can simply do `pip install ${PYTHON_PACKAGE_DST_DIR}/dist/*.whl -U`

# Note: Since `make python-package` clears PYTHON_COMPILED_MODULE_DIR every time,
# it is guaranteed that there is only one wheel in ${PYTHON_PACKAGE_DST_DIR}/dist/*.whl
file(GLOB WHEEL_FILE "${PYTHON_PACKAGE_DST_DIR}/dist/*.whl")
execute_process(COMMAND pip install ${WHEEL_FILE} -U)
8 changes: 4 additions & 4 deletions src/Python/make_all_pip_wheels.cmake
Expand Up @@ -24,10 +24,10 @@
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

# Create python pacakge. It contains
# 1) Pure-python code and misc files, copied from src/Python/Package
# 2) The compiled python-C++ module, i.e. open3d.so (or the equivalents)
# 3) Configured files and supporting files
# Warning: Internal use only, consider droping this in the future
# Use `make all-pip-wheels` to create the pip package in the build directory
# This creates: open3d-python, py3d, open3d-original, open3d-official, open-3d
# pip wheels

# Clean up directory
file(REMOVE_RECURSE ${PYTHON_PACKAGE_DST_DIR})
Expand Down

0 comments on commit 8e36aa8

Please sign in to comment.