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

Open3d 0.16.1 fails to install correct dependencies under Poetry #5747

Open
3 tasks done
johnthagen opened this issue Nov 30, 2022 · 15 comments · May be fixed by #6588
Open
3 tasks done

Open3d 0.16.1 fails to install correct dependencies under Poetry #5747

johnthagen opened this issue Nov 30, 2022 · 15 comments · May be fixed by #6588
Labels
build/install Build or installation issue

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Nov 30, 2022

Checklist

Steps to reproduce the issue

Create a pyproject.toml file:

[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = ""
authors = []

[tool.poetry.dependencies]
python = "^3.10, <3.11"
open3d = "0.16.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Run:

poetry lock
poetry install --sync
poetry shell

Note that the way this mac-only package was published, it is missing ML-related dependencies in how Poetry pulls dependencies through the API:

pip list
Package              Version
-------------------- -------
attrs                22.1.0
click                8.1.3
ConfigArgParse       1.5.3
dash                 2.7.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
fastjsonschema       2.16.2
Flask                2.2.2
itsdangerous         2.1.2
Jinja2               3.1.2
jsonschema           4.17.3
jupyter_core         5.1.0
MarkupSafe           2.1.1
nbformat             5.5.0
numpy                1.23.5
open3d               0.16.1
pip                  22.3.1
platformdirs         2.5.4
plotly               5.11.0
pyrsistent           0.19.2
setuptools           65.6.3
tenacity             8.1.0
traitlets            5.6.0
Werkzeug             2.2.2
wheel                0.38.4

For example, scikit-learn is not installed even though it is a dependency.

Error message

Within the poetry shell:

$ python
Python 3.10.8 (main, Oct 13 2022, 10:17:43) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import open3d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/Library/Caches/pypoetry/virtualenvs/poetry-test-hz2NYSp8-py3.10/lib/python3.10/site-packages/open3d/__init__.py", line 134, in <module>
    import open3d.ml
  File "/Users/user/Library/Caches/pypoetry/virtualenvs/poetry-test-hz2NYSp8-py3.10/lib/python3.10/site-packages/open3d/ml/__init__.py", line 35, in <module>
    from . import datasets
  File "/Users/user/Library/Caches/pypoetry/virtualenvs/poetry-test-hz2NYSp8-py3.10/lib/python3.10/site-packages/open3d/ml/datasets.py", line 34, in <module>
    from open3d._ml3d.datasets import *
  File "/Users/hagenjt1/Library/Caches/pypoetry/virtualenvs/poetry-test-hz2NYSp8-py3.10/lib/python3.10/site-packages/open3d/_ml3d/datasets/__init__.py", line 3, in <module>
    from .semantickitti import SemanticKITTI
  File "/Users/user/Library/Caches/pypoetry/virtualenvs/poetry-test-hz2NYSp8-py3.10/lib/python3.10/site-packages/open3d/_ml3d/datasets/semantickitti.py", line 6, in <module>
    from sklearn.neighbors import KDTree
ModuleNotFoundError: No module named 'sklearn'

Open3D, Python and System information

- Operating system: macOS 12.6
- Python version: Python 3.10.8
- Open3D version: 0.16.1
- System architecture: x86
- Is this a remote workstation?: no
- How did you install Open3D?: Poetry
- Compiler version (if built from source): N/A

Additional information

Discussion with Poetry devs about this topic:

@johnthagen johnthagen added the build/install Build or installation issue label Nov 30, 2022
@johnthagen
Copy link
Contributor Author

johnthagen commented Nov 30, 2022

It seems that all of the ML related dependencies are not being published through PyPI's JSON API so that Poetry can inspect them:

Having a minimal non-ML package would also really help this overall situation:

@johnthagen
Copy link
Contributor Author

To work around this, I had to mirror all of the ML requirements that are missing from 0.16.1 JSON API:

[tool.poetry.dependencies]
python = "^3.10, <3.11"
open3d = "0.16.1"
# See: https://github.com/isl-org/Open3D-ML/blob/8ddb67206e4fef55b39eea691ff00d49cef18be5/requirements.txt
addict = "*"
pillow = "*"
matplotlib = "*"
numpy = "*"
pandas = "*"
pyyaml = "*"
scikit-learn = "*"
tqdm = "*"
pyquaternion = "*"

@johnthagen
Copy link
Contributor Author

johnthagen commented Nov 30, 2022

The Poetry devs pointed out that they are pulling the information from the PyPI JSON API. This currently is populated by the first wheel that is uploaded. If you look at:

    "requires_dist": [
      "numpy (>=1.18.0)",
      "dash (>=2.6.0)",
      "nbformat (==5.5.0)",
      "configargparse"
    ],
    "requires_dist": [
      "numpy (>=1.18.0)",
      "dash (>=2.6.0)",
      "nbformat (==5.5.0)",
      "configargparse",
      "addict",
      "pillow (>=8.2.0)",
      "matplotlib (>=3)",
      "numpy (>1.15)",
      "pandas (>=1.0)",
      "pyyaml (>=5.4.1)",
      "scikit-learn (>=0.21)",
      "tqdm",
      "pyquaternion"
    ],

This is related to how this issue was solved:

@johnthagen
Copy link
Contributor Author

Okay, I've discovered the root cause of this issue. The ARM macOS wheels do not have the full list of requirements. If you unzip:

And look at the METADATA file:

Requires-Dist: numpy (>=1.18.0)
Requires-Dist: dash (>=2.6.0)
Requires-Dist: nbformat (==5.5.0)
Requires-Dist: configargparse

Since these were the first wheels uploaded, the JSON API stores those, and the x86 wheel dependencies are not locked properly by Poetry.

@johnthagen johnthagen changed the title Open3d 0.16.1 fails to install under Poetry due to missing dependencies Open3d 0.16.1 fails to install correct dependencies under Poetry due to missing dependencies Dec 1, 2022
@johnthagen johnthagen changed the title Open3d 0.16.1 fails to install correct dependencies under Poetry due to missing dependencies Open3d 0.16.1 fails to install correct dependencies under Poetry Dec 1, 2022
@ssheorey
Copy link
Member

ssheorey commented Dec 2, 2022

Hi @johnthagen as far as I can tell, your debugging looks correct. The ARM macOS wheels do not support 3DML (yet) and so do not have the extra Open3D-ML requirements. From the next release, we will add 3DML support to macOS ARM and this issue should not occur. This is not related to the v0.16.1 bugfixes.

@johnthagen
Copy link
Contributor Author

johnthagen commented Dec 2, 2022

@ssheorey Do you also think we could for the next release make the ML dependencies optional?

Something like:

pip install open3d[ml]

Similar for Dash:

pip install open3d[dash]

To get everything:

pip install open3d[all]

setuptools handles it this way:

This would make it much nicer to use Open3D in constrained, headless environments.

@ssheorey
Copy link
Member

@johnthagen thanks for the suggestion - we will consider it, but note that it does need significant effort in updating packaging and documentation.

@apockill
Copy link

apockill commented Jan 5, 2024

I was wondering if there was any way to use poetry + open3d at the moment? My company has been stuck on 0.16.0 since 0.16.1, 0.17.0, and now 0.18.0 all fail to have dependencies picked up correctly by poetry. This is reproducible on Ubuntu 22.04.

@ssheorey
Copy link
Member

ssheorey commented Jan 5, 2024

Hi @apockill based on @johnthagen 's debugging this seems to be a strange issue / race condition in the PyPI json API / poetry dependency checker, so I'm not really sure what we can do about this. If there is a fix for Open3D we would be happy to merge it. Otherwise, perhaps this should be addressed as a bug in poetry or PyPI json API.

@dimbleby
Copy link

dimbleby commented Jan 6, 2024

The way to make open3d work with poetry is for open3d to use the same set of requirements in all distributions, with variations expressed through pep508 markers eg

not-arm-64-dependency==1.0.0 ; platform_machine != "arm64"

@johnthagen
Copy link
Contributor Author

johnthagen commented Jan 6, 2024

@ssheorey Here is a link the section of PEP 508 that describes environment markers:

If we follow this line:

with open("@OPEN3D_ML_ROOT@/requirements.txt", "r") as f:

Here are the missing requirements:

So I think the improvement needed would be to unconditionally include the ML dependencies, but put environment markers on them such that they are only installed for the wheels that include ML functionality on their platform (e.g. platform_machine != "arm64")

Related to this, it would be convenient if the user could opt-in using extras to these various sub parts of Open3D, as discussed in

I think that by using PEP 508 environment markers and extras together, Open3D's dependencies could work a lot nicer together.

@apockill
Copy link

apockill commented Jan 8, 2024

not-arm-64-dependency==1.0.0

Thank you for the quick response! I'm excited to get this working. I'm having a bit of trouble figuring out how to get this environment marker to work. I tried a few lines in my pyproject.toml, but had various syntax errors. I'm not sure if I'm missing something super obvious 😅

open3d = { version = "0.18.0", markers = "not-arm-64-dependency==1.0.0 and platform_machine != 'arm64'" }

It seems like no matter where I put it, the not-arm-64-dependency trips up my poetry lock command (poetry==1.7.1):

No terminal matches 'n' in the current parser context, at line 1 col 1

not-arm-64-dependency==1.0.0 platform_ma
^
Expected one of: 
        * L_PAREN
        * ESCAPED_STRING
        * SINGLE_QUOTED_STRING
        * MARKER_NAME

I wasn't able to find documentation on this marker, so my trail ran cold. When I tried using just the platform_machine != 'arm64' I was able to poetry lock successfully, but the dependencies were still not being locked correctly. Thank you again for you help!

@johnthagen
Copy link
Contributor Author

@apockill This is something that the Open3D team would need to change about their built wheels, not something that an end user can fix externally.

@dimbleby Was just showing an example with not-arm-64-dependency as an example of one of Open3D's dependencies that are x86-only (it's not a real package, he was just showing how PEP 508 markers work).

@ssheorey
Copy link
Member

ssheorey commented Jan 8, 2024

Hi @dimbleby thanks for the suggestion - I think we can make that work with some effort. The way dependencies are set are:

  • there are different requirement files for specific components (e.g. Jupyter support or Open3D-ML).
  • wheel building is controlled by cmake. Depending on which build components are enabled, the specific requirements files are used.

The change would be to add all requirement files, but update the environment markers based on the enabled components. setup.py looks to be the right place for this change.

We would appreciate it if someone wants to create a PR for this. I can provide help as needed.

@ssheorey ssheorey reopened this Jan 8, 2024
@johnthagen
Copy link
Contributor Author

I inspected the 0.18 wheels, and it looks like the matrix of ML dependencies is a little more complex than just "not ARM":

  • windows x86_64: no
  • mac universal: yes
  • mac arm64: yes
  • linux x86_64: yes
  • linux arm64: no

@ssheorey Does this sound accurate?

So the environment marker we'd need to apply to each ML dependency would look something like:

platform_system == "Darwin" or (platform_system == "Linux" and platform_machine == "x86_64")

aaletov added a commit to aaletov/open-pcc-metric that referenced this issue Apr 30, 2024
Related to this issue isl-org/Open3D#5747

Signed-off-by: aapozd <aapozdnyakove@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/install Build or installation issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants