Skip to content

Commit

Permalink
Basic support for Python Optional Dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
samypr100 committed Feb 20, 2023
1 parent dd69a8f commit 9152501
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ jobs:
run: |
$ErrorActionPreference = 'Stop'
python -m pip install -r python/requirements.txt
python -m pip install -r python/requirements_gui.txt
python -m pip install -r python/requirements_jupyter_build.txt
- name: Config
Expand Down Expand Up @@ -402,7 +403,7 @@ jobs:
$PIP_PKG_NAME=(Get-ChildItem open3d*-$py_tag-*.whl).Name
}
echo "Installing Open3D wheel $PIP_PKG_NAME in virtual environment..."
python -m pip install "$PIP_PKG_NAME"
python -m pip install "$PIP_PKG_NAME[standard]"
python -c "import open3d; print('Imported:', open3d)"
python -c "import open3d; print('CUDA enabled: ', open3d.core.cuda.is_available())"
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/README_SYCL.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Open3D is designed to make use of the SYCL GPU devices.

## List of oneAPI Python packages

To make `pip install open3d` works out-of-the box on SYCL-enabled platforms,
To make `pip install open3d[standard]` works out-of-the box on SYCL-enabled platforms,
we can utilize runtime libraries released via PyPI. This feature needs to be
implemented.

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Fix raycasting scene: Allow setting of number of threads that are used for building a raycasting scene
* Fix Python bindings for CUDA device synchronization, voxel grid saving (PR #5425)
* Support msgpack versions without cmake
* Introduce new optional dependencies support, allowing you to do `pip install open3d[standard]`

## 0.13

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Pre-built pip packages support Ubuntu 18.04+, macOS 10.15+ and Windows 10+

```bash
# Install
pip install open3d
pip install open3d[standard]

# Verify installation
python -c "import open3d as o3d; print(o3d.__version__)"
Expand Down
2 changes: 1 addition & 1 deletion cpp/pybind/make_install_pip_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# 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 ${Python3_EXECUTABLE} -m pip uninstall open3d --yes)
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install ${WHEEL_FILE} -U)
execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install "${WHEEL_FILE}[standard]" -U)
1 change: 1 addition & 0 deletions cpp/pybind/make_python_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ if (BUILD_JUPYTER_EXTENSION)
# These will be installed when `pip install open3d`.
execute_process(COMMAND ${CMAKE_COMMAND} -E cat
${PYTHON_PACKAGE_SRC_DIR}/requirements.txt
${PYTHON_PACKAGE_SRC_DIR}/requirements_gui.txt
${PYTHON_PACKAGE_SRC_DIR}/requirements_jupyter_install.txt
OUTPUT_VARIABLE ALL_REQUIREMENTS
)
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.openblas
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ COPY ./python/requirements*.txt /root/Open3D/python/
RUN which python \
&& python --version \
&& python -m pip install -U -r /root/Open3D/python/requirements.txt \
-r /root/Open3D/python/requirements_gui.txt \
-r /root/Open3D/python/requirements_build.txt \
-r /root/Open3D/python/requirements_test.txt

Expand Down
34 changes: 17 additions & 17 deletions docs/arm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ we provide pre-compiled ARM64 wheels for Linux and macOS. Install the wheel by:

.. code-block:: bash
pip install open3d
pip install open3d[standard]
python -c "import open3d; print(open3d.__version__)"
# Test the legacy visualizer
Expand All @@ -18,21 +18,21 @@ we provide pre-compiled ARM64 wheels for Linux and macOS. Install the wheel by:
# Test the new GUI visualizer
python -c "import open3d as o3d; c = o3d.geometry.TriangleMesh.create_box(); o3d.visualization.draw(c)"
+------------------------+----------------+---------------------+------------+----------------+
| | Linux (OpenGL) | Linux (OpenGL ES) | macOS | Windows on ARM |
+========================+================+=====================+============+================+
| ``pip install open3d`` | Yes | Yes | Yes | No |
+------------------------+----------------+---------------------+------------+----------------+
| Compile from source | Yes | Yes | Yes | No |
+------------------------+----------------+---------------------+------------+----------------+
| Visualizer and GUI | Yes | No | Yes | No |
+------------------------+----------------+---------------------+------------+----------------+
| Non-GUI features | Yes | Yes | Yes | No |
+------------------------+----------------+---------------------+------------+----------------+
| Special build flags | Not needed | ``-DBUILD_GUI=OFF`` | Not needed | N/A |
+------------------------+----------------+---------------------+------------+----------------+
| Example device | Nvidia Jetson | Raspberry Pi 4 | M1 MacBook | Surface Pro X |
+------------------------+----------------+---------------------+------------+----------------+
+----------------------------------+----------------+---------------------+------------+----------------+
| | Linux (OpenGL) | Linux (OpenGL ES) | macOS | Windows on ARM |
+==================================+================+=====================+============+================+
| ``pip install open3d[standard]`` | Yes | Yes | Yes | No |
+----------------------------------+----------------+---------------------+------------+----------------+
| Compile from source | Yes | Yes | Yes | No |
+----------------------------------+----------------+---------------------+------------+----------------+
| Visualizer and GUI | Yes | No | Yes | No |
+----------------------------------+----------------+---------------------+------------+----------------+
| Non-GUI features | Yes | Yes | Yes | No |
+----------------------------------+----------------+---------------------+------------+----------------+
| Special build flags | Not needed | ``-DBUILD_GUI=OFF`` | Not needed | N/A |
+----------------------------------+----------------+---------------------+------------+----------------+
| Example device | Nvidia Jetson | Raspberry Pi 4 | M1 MacBook | Surface Pro X |
+----------------------------------+----------------+---------------------+------------+----------------+

Additional notes:

Expand Down Expand Up @@ -107,7 +107,7 @@ TBB, Parallel STL, BLAS, LAPACK) may cause compatibility issues if they are not
the same version as the one used by Open3D.

If you only need the Python wheel, consider using the Docker build method or
install Open3D via ``pip install open3d`` directly.
install Open3D via ``pip install open3d[standard]`` directly.

Install dependencies
````````````````````
Expand Down
2 changes: 1 addition & 1 deletion docs/docker.in.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Python applications looks like this:
# Install Open3D from the PyPI repositories
RUN python3 -m pip install --no-cache-dir --upgrade pip && \
python3 -m pip install --no-cache-dir --upgrade open3d
python3 -m pip install --no-cache-dir --upgrade open3d[standard]
If you have an NVIDIA GPU and want to use it for computation (``CUDA``) or
visualization, follow these `directions.
Expand Down
12 changes: 8 additions & 4 deletions docs/getting_started.in.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ Pip (PyPI)

.. code-block:: bash
pip install open3d
pip install open3d[standard]
.. note::
Above will work for most purposes and aligns with behavior seen in `v0.16` and below.
Using anything under :mod:`open3d.visualization` will require ``[standard]``.

.. note::
Please upgrade your ``pip`` to a version >=20.3 to install Open3D in Linux,
Expand All @@ -53,11 +57,11 @@ Pip (PyPI)

.. code-block:: bash
pip3 install open3d
pip3 install open3d[standard]
# or
pip install --user open3d
pip install --user open3d[standard]
# or
python3 -m pip install --user open3d
python3 -m pip install --user open3d[standard]
Development version (pip)
-------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/sensor/realsense.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Install Open3D from PyPI (a virtual environment is recommended):

.. code-block:: sh
pip install open3d
pip install open3d[standard]
Compile from source (C++)
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 8 additions & 1 deletion python/open3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ def _insert_pybind_names(skip_names=()):
sys.modules.update(submodules)


import open3d.visualization
try:
import open3d.visualization
except ModuleNotFoundError:
warnings.warn(
"Open3D Python GUI Libraries not found. "
"Please make sure to install open3d[standard] if you wish to use "
"the open3d.visualization module.", RuntimeWarning)

_insert_pybind_names(skip_names=("ml",))

__version__ = "@PROJECT_VERSION@"
Expand Down
2 changes: 0 additions & 2 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
numpy>=1.18.0
dash>=2.6.0
werkzeug>=2.2.3
nbformat==5.7.0
configargparse
2 changes: 2 additions & 0 deletions python/requirements_gui.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dash>=2.6.0
werkzeug>=2.2.3
10 changes: 9 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# IN THE SOFTWARE.
# ----------------------------------------------------------------------------

from collections import defaultdict
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
import os
Expand Down Expand Up @@ -118,7 +119,13 @@ def finalize_options(self):
with open('requirements.txt', 'r') as f:
install_requires = [line.strip() for line in f.readlines() if line]

# Read requirements for ML.
# For extra requirements
extra_requires = defaultdict(list)

# Standard Extras
with open('requirements_gui.txt', 'r') as f:
extra_requires['standard'] += [line.strip() for line in f.readlines() if line]

if '@BUNDLE_OPEN3D_ML@' == 'ON':
with open('@OPEN3D_ML_ROOT@/requirements.txt', 'r') as f:
install_requires += [line.strip() for line in f.readlines() if line]
Expand All @@ -139,6 +146,7 @@ def finalize_options(self):
python_requires='>=3.6',
include_package_data=True,
install_requires=install_requires,
extras_require=extra_requires,
packages=find_packages(),
entry_points=entry_points,
zip_safe=False,
Expand Down
4 changes: 3 additions & 1 deletion util/ci_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ install_python_dependencies() {

# TODO: modify other locations to use requirements.txt
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements.txt"
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements_gui.txt"
if [[ "with-jupyter" =~ ^($options)$ ]]; then
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements_jupyter_build.txt"
fi
Expand Down Expand Up @@ -258,7 +259,7 @@ test_wheel() {
echo -n "Using pip: "
python -m pip --version
echo "Installing Open3D wheel $wheel_path in virtual environment..."
python -m pip install "$wheel_path"
python -m pip install "${wheel_path}[standard]"
python -c "import open3d; print('Installed:', open3d)"
python -c "import open3d; print('CUDA enabled: ', open3d.core.cuda.is_available())"
echo
Expand Down Expand Up @@ -387,6 +388,7 @@ install_docs_dependencies() {
fi
echo
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements.txt"
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements_gui.txt"
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/python/requirements_jupyter_build.txt"
python -m pip install -r "${OPEN3D_SOURCE_ROOT}/docs/requirements.txt"
}
Expand Down

0 comments on commit 9152501

Please sign in to comment.