facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.81k stars 1.32k forks source link

Missing PEP517 metadata #1419

Open VDuchauffour opened 1 year ago

VDuchauffour commented 1 year ago

🚀 Feature - Adding PEP517 metadata

The PEP517 introduces a possibility to build packages isolated from the runtime environment. Currently no metadata for the build are provided, so it seems impossible to install Pytorch3D with a tool like poetry or pdm. For instance, trying to install Pytorch3D with the command poetry add git+https://github.com/facebookresearch/pytorch3d.git gives this error:

Command ['/tmp/tmp3zxip3u8/.venv/bin/python', 'setup.py', 'egg_info'] errored with the following return code 1, and output: 
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

Like for Torch (here), adding a pyproject.toml file with the following content could fix the issue. It from this issue.

[build-system]
requires = ["setuptools", "wheel", "torch"]
build-backend = "setuptools.build_meta:__legacy__"

Would you accept to adding this ? Thank you

bottler commented 1 year ago

Is there a danger with this that torch could be downloaded and installed automatically without the user picking which build they want? For example, they end up with a torch build corresponding to the wrong CUDA version?

pickles-bread-and-butter commented 1 year ago

A +1 on this issue as well, I'm trying to use pip compile for requirement management with your package and it breaks expecting torch in the environment doing the pip compile. This is caused by the implied inclusion of torch in the environment doing the compiling when that can't be guaranteed, due to setup.py torch import. I believe this addition would also fix that problem as well.

bottler commented 1 year ago

A +1 on this issue as well, I'm trying to use pip compile for requirement management with your package and it breaks expecting torch in the environment doing the pip compile. This is caused by the implied inclusion of torch in the environment doing the compiling when that can't be guaranteed, due to setup.py torch import. I believe this addition would also fix that problem as well.

This part is confusing to me, similar to the previous question I asked. Are you suggesting having a pyproject.toml which does not mention torch? Otherwise how would its presence help?

roym899 commented 1 year ago

@bottler I don't think it is a real issue if torch were automatically installed. Yes, it would install the default torch if it wasn't installed yet, but it would simply keep the existing torch if it was already there. I think it is the responsibility of the user / whatever package that uses pytorch3d to ensure that its dependencies are sufficiently specified for this not to happen.

For example, it is currently not an option to specify pytorch3d as a git dependency. Automatic installation will fail even when torch is specified as a second dependency, because pip has no idea that torch has to be installed before pytorch3d. This always adds unnecessary manual installation steps that could be avoided.

Maybe adding torch as a dependency and adding a few checks that stops the pytorch3d installation if the torch + cuda version doesn't match the versions pytorch3d expects is an option?

leweex95 commented 1 year ago

Could you please tell me if there is any plan for this to be fixed? As I understand, till this is not fixed, we are unable to use pytorch3d with poetry on our project, due to pytorch3d's undeclared build-time dependency on torch.

Alternatively, what workaround would you be able to recommend for us to install the pytorch3d library using poetry, if this issue is not planned to be fixed?

sinAshish commented 10 months ago

poetry add https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1121/pytorch3d-0.7.2-cp38-cp38-linux_x86_64.whl

this works, if you properly define your toml to use the proper torch and python versions

HernandoR commented 1 month ago

poetry add https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1121/pytorch3d-0.7.2-cp38-cp38-linux_x86_64.whl

this works, if you properly define your toml to use the proper torch and python versions

This not even close to a proper solution, at least not if we could find the url for our specific version of py, cu and pyt

bottler commented 1 month ago

poetry add https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1121/pytorch3d-0.7.2-cp38-cp38-linux_x86_64.whl this works, if you properly define your toml to use the proper torch and python versions

This not even close to a proper solution, at least not if we could find the url for our specific version of py, cu and pyt

(It is not intended to be. The supported binary builds are the conda ones.)