Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated make conda-package #618

Merged
merged 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions src/Python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ if (NOT PYTHON_EXECUTABLE)
find_program(PYTHON_IN_PATH "python")
set(PYTHON_EXECUTABLE ${PYTHON_IN_PATH})
endif()
message("Using Python executable ${PYTHON_EXECUTABLE}")
message(STATUS "Using Python executable: ${PYTHON_EXECUTABLE}")

# We need to get python version to configure some meta files
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; print('%d.%d' % (sys.version_info.major, sys.version_info.minor))"
OUTPUT_VARIABLE PYTHON_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Using Python version: ${PYTHON_VERSION}")

set(PACKAGE_NAME open3d)

Expand Down Expand Up @@ -48,6 +56,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_VERSION=${PYTHON_VERSION}
-DPYTHON_COMPILED_MODULE_PATH=$<TARGET_FILE:${PACKAGE_NAME}>
-DPROJECT_EMAIL=${PROJECT_EMAIL}
-DPROJECT_HOME=${PROJECT_HOME}
Expand All @@ -59,28 +68,47 @@ add_custom_target(python-package
-P ${CMAKE_CURRENT_SOURCE_DIR}/make_python_package.cmake
)

# Use `make pip-wheel` to create the pip package in the build directory
add_custom_target(pip-wheel
COMMAND ${PYTHON_EXECUTABLE} "setup.py" "bdist_wheel"
# Use `make pip-package` to create the pip package in the build directory
add_custom_target(pip-package
COMMAND ${PYTHON_EXECUTABLE} setup.py bdist_wheel --dist-dir pip_package
COMMAND echo "pip wheel created at ${PYTHON_PACKAGE_DST_DIR}/pip_package"
WORKING_DIRECTORY ${PYTHON_PACKAGE_DST_DIR}
DEPENDS python-package
)

# Use `make install-pip-wheel` to install pip wheel package to the current
# Use `make install-pip-package` to install pip wheel package to the current
# python environment.
add_custom_target(install-pip-wheel
add_custom_target(install-pip-package
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/make_install_pip_package.cmake
DEPENDS pip-package
)

# Use `make conda-package` to create conda package in the build directory
# Note that we don't provide `make install-conda-package` similar to pip. This
# is becuase:
# 1) `make install-pip-whell` works in conda environment for local build
# 2) `make conda-package` is mainly for internal use to distribute conda
add_custom_target(conda-package
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/install_pip_wheel.cmake
DEPENDS pip-wheel
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/check_and_install_conda_deps.cmake
# If we put the following `conda-build` in check_and_install_conda_deps.cmake, it
# causes broken pipe problem while running conda build. So we put it here.
COMMAND conda-build conda_meta --output-folder conda_package
COMMAND echo "conda package created at ${PYTHON_PACKAGE_DST_DIR}/conda_package"
WORKING_DIRECTORY ${PYTHON_PACKAGE_DST_DIR}
DEPENDS python-package
)

################################################################################
# Warning: Internal use only, consider droping this in the future
# Use `make all-pip-wheels` to create the pip package in the build directory
# Use `make all-pip-packages` to create the pip package in the build directory
# This creates: open3d-python, py3d, open3d-original, open3d-official, open-3d
# pip wheels
add_custom_target(all-pip-wheels
add_custom_target(all-pip-packages
COMMAND ${CMAKE_COMMAND}
-DPYTHON_PACKAGE_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}/Package
-DPYTHON_PACKAGE_DST_DIR=${PYTHON_PACKAGE_DST_DIR}
Expand All @@ -92,5 +120,5 @@ add_custom_target(all-pip-wheels
-DPROJECT_CODE=${PROJECT_CODE}
-DPROJECT_ISSUES=${PROJECT_ISSUES}
-DPROJECT_VERSION=${PROJECT_VERSION}
-P ${CMAKE_CURRENT_SOURCE_DIR}/make_all_pip_wheels.cmake
-P ${CMAKE_CURRENT_SOURCE_DIR}/make_all_pip_packages.cmake
)
2 changes: 2 additions & 0 deletions src/Python/Package/conda_meta/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- @PYTHON_VERSION@
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
# since we'll use the `open3d` name rather than open3d-python`.

package:
name: open3d
version: "0.3.0"
name: open3d
version: "@PROJECT_VERSION@"

source:
path: ../../pip_package
path: ../ # Points to setup.py after configuration

requirements:
build:
- python {{ python }}
- setuptools
run:
- python
- numpy
build:
- python {{ python }}
- setuptools
run:
- python
- numpy

test:
script:
- test_import.py
script:
- test_import.py

about:
home: http://www.open3d.org/
license: MIT
license_file: LICENSE.txt
summary: Open3D is an open-source library that supports rapid development of software that deals with 3D data.
doc_url: http://www.open3d.org/docs/
dev_url: https://github.com/IntelVCL/Open3D
home: @PROJECT_HOME@
license: MIT
license_file: LICENSE.txt
summary: Open3D is an open-source library that supports rapid development of software that deals with 3D data.
doc_url: @PROJECT_DOCS@
dev_url: @PROJECT_CODE@
File renamed without changes.
34 changes: 34 additions & 0 deletions src/Python/check_and_install_conda_deps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Check if conda in path, if not, throw exception
find_program(CONDA "conda")
if (NOT CONDA)
message(FATAL_ERROR "conda not found, please install, see https://conda.io/docs/user-guide/install/index.html")
else ()
message(STATUS "conda is found at ${CONDA}")
endif()

# Assert that we're inside a conda environemnt
message(STATUS "Asserting this is Conda python: ${PYTHON_EXECUTABLE} ...")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -c "import sys; assert 'conda' in sys.version"
RESULT_VARIABLE return_code
)
if (${return_code})
message(FATAL_ERROR "Not in a conda environment: 1) activate conda, 2) rerun cmake and make")
endif()

# Check if conda-build is installed, if not, install it
find_program(CONDA_BUILD "conda-build")
if (NOT CONDA_BUILD)
message(STATUS "conda-build not found")
message(STATUS "Trying to install conda-build ...")
execute_process(
COMMAND conda install -y -q conda-build
RESULT_VARIABLE return_code
)
find_program(CONDA_BUILD "conda-build")
if (NOT CONDA_BUILD)
message(FATAL_ERROR "conda-build installation failed, please install manualy")
else()
message(STATUS "conda-build installed at ${CONDA_BUILD}")
endif()
endif()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Warning: Internal use only, consider droping this in the future
# Use `make all-pip-wheels` to create the pip package in the build directory
# Use `make all-pip-pacakges` to create the pip package in the build directory
# This creates: open3d-python, py3d, open3d-original, open3d-official, open-3d
# pip wheels

Expand Down Expand Up @@ -37,7 +37,7 @@ foreach (PYPI_PACKAGE_NAME ${PYPI_PACKAGE_NAMES})
configure_file("${PYTHON_PACKAGE_SRC_DIR}/setup.py.in"
"${PYTHON_PACKAGE_DST_DIR}/setup.py")
execute_process(
COMMAND ${PYTHON_EXECUTABLE} "setup.py" "bdist_wheel"
COMMAND ${PYTHON_EXECUTABLE} setup.py bdist_wheel --dist-dir pip_package
WORKING_DIRECTORY ${PYTHON_PACKAGE_DST_DIR}
)
endforeach()
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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`
# For Ubuntu/Mac, we can simply do `pip install ${PYTHON_PACKAGE_DST_DIR}/pip_package/*.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")
# it is guaranteed that there is only one wheel in ${PYTHON_PACKAGE_DST_DIR}/pip_package/*.whl
file(GLOB WHEEL_FILE "${PYTHON_PACKAGE_DST_DIR}/pip_package/*.whl")
execute_process(COMMAND pip install ${WHEEL_FILE} -U)
11 changes: 6 additions & 5 deletions src/Python/make_python_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ file(MAKE_DIRECTORY ${PYTHON_PACKAGE_DST_DIR}/open3d)
# 1) Pure-python code and misc files, copied from src/Python/Package
file(COPY ${PYTHON_PACKAGE_SRC_DIR}/
DESTINATION ${PYTHON_PACKAGE_DST_DIR}
PATTERN "*.in" EXCLUDE
)

# 2) The compiled python-C++ module, i.e. open3d.so (or the equivalents)
Expand All @@ -19,9 +18,11 @@ file(COPY ${PYTHON_COMPILED_MODULE_PATH}
DESTINATION ${PYTHON_PACKAGE_DST_DIR}/open3d)

# 3) Configured files and supporting files
configure_file("${PYTHON_PACKAGE_SRC_DIR}/setup.py.in"
configure_file("${PYTHON_PACKAGE_SRC_DIR}/setup.py"
"${PYTHON_PACKAGE_DST_DIR}/setup.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/MANIFEST.in"
"${PYTHON_PACKAGE_DST_DIR}/MANIFEST.in" COPYONLY)
configure_file("${PYTHON_PACKAGE_SRC_DIR}/open3d/__init__.py.in"
configure_file("${PYTHON_PACKAGE_SRC_DIR}/open3d/__init__.py"
"${PYTHON_PACKAGE_DST_DIR}/open3d/__init__.py")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/conda_meta/conda_build_config.yaml"
"${PYTHON_PACKAGE_DST_DIR}/conda_meta/conda_build_config.yaml")
configure_file("${PYTHON_PACKAGE_SRC_DIR}/conda_meta/meta.yaml"
"${PYTHON_PACKAGE_DST_DIR}/conda_meta/meta.yaml")
154 changes: 0 additions & 154 deletions util/conda_package/README.md

This file was deleted.

4 changes: 0 additions & 4 deletions util/conda_package/open3d/conda_build_config.yaml

This file was deleted.