pytorch3d icon indicating copy to clipboard operation
pytorch3d copied to clipboard

Missing PEP517 metadata

Open VDuchauffour opened this issue 2 years ago • 8 comments

🚀 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

VDuchauffour avatar Jan 10 '23 16:01 VDuchauffour

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?

bottler avatar Jan 10 '23 19:01 bottler

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.

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?

bottler avatar Jan 24 '23 14:01 bottler

@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?

roym899 avatar Jun 13 '23 09:06 roym899

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?

leweex95 avatar Oct 26 '23 07:10 leweex95

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

sinAshish avatar Jan 03 '24 22:01 sinAshish