teddykoker / torchsort

Fast, differentiable sorting and ranking in PyTorch
https://pypi.org/project/torchsort/
Apache License 2.0
765 stars 33 forks source link

Cannot install using poetry #58

Closed ashkan-leo closed 1 year ago

ashkan-leo commented 1 year ago

Hello I am installing the package using poetry and I get the following error. Any tip how I can do this?


  Command ['/home/ashkan/w/numersub/.venv/bin/python', '-m', 'pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/home/ashkan/w/numersub/.venv', '--no-deps', '/home/ashkan/.cache/pypoetry/artifacts/0e/71/4c/36d2482ca69c4e6c8ff5dbed48ecc16ad2bf8ea2c110395f1b50bfffc5/torchsort-0.1.9.tar.gz'] errored with the following return code 1, and output:
  Processing /home/ashkan/.cache/pypoetry/artifacts/0e/71/4c/36d2482ca69c4e6c8ff5dbed48ecc16ad2bf8ea2c110395f1b50bfffc5/torchsort-0.1.9.tar.gz
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'error'
    error: subprocess-exited-with-error

    × Getting requirements to build wheel did not run successfully.
    │ exit code: 1
    ╰─> [17 lines of output]
        Traceback (most recent call last):
          File "/home/ashkan/w/numersub/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
            main()
          File "/home/ashkan/w/numersub/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
            json_out['return_val'] = hook(**hook_input['kwargs'])
          File "/home/ashkan/w/numersub/.venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
            return hook(config_settings)
          File "/tmp/pip-build-env-zc4jpjhm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
            return self._get_build_requires(config_settings, requirements=['wheel'])
          File "/tmp/pip-build-env-zc4jpjhm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
            self.run_setup()
          File "/tmp/pip-build-env-zc4jpjhm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 483, in run_setup
            super(_BuildMetaLegacyBackend,
          File "/tmp/pip-build-env-zc4jpjhm/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
            exec(code, locals())
          File "<string>", line 8, in <module>
        ModuleNotFoundError: No module named 'torch'
        [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip.
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
teddykoker commented 1 year ago

Hi @ashkan-leo, torch is a dependency required prior to installing torchsort. Please ensure PyTorch is installed prior to installing torchsort, and you shouldn't run into this issue.

If you are still having problems, please provide the full list of commands you are using to install the library so I can reproduce the issue :)

ashkan-leo commented 1 year ago

@teddykoker thanks for getting back. I have installed torch and can verify that I can import it as well. The issue seems to be isolated to torchsort

teddykoker commented 1 year ago

Does the torchsort installation work now that torch is installed?

ashkan-leo commented 1 year ago

No it’s not working

On November 13, 2022 at 14:55 GMT, Teddy Koker @.***> wrote:

Does the torchsort installation work now that torch is installed?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

teddykoker commented 1 year ago

Can you provide the error output, as well as the steps taken to reproduce the error?

petrgazarov commented 4 months ago

I have been using torch in a project managed by poetry and tried to install torchsort via poetry add torchsort. The install failed with the same error as OP. Full error trace:

poetry add torchsort
Using version ^0.1.9 for torchsort

Updating dependencies
Resolving dependencies... (0.6s)

Package operations: 1 install, 0 updates, 0 removals

  • Installing torchsort (0.1.9): Failed

  ChefBuildError

  Backend subprocess exited when trying to invoke get_requires_for_build_wheel

  Traceback (most recent call last):
    File "/Users/petrgazarov/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
      main()
    File "/Users/petrgazarov/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/Users/petrgazarov/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
      return hook(config_settings)
             ^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/xg/dfqs_csd2p536h5xrjc2d_k80000gn/T/tmpm48nga82/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 325, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/private/var/folders/xg/dfqs_csd2p536h5xrjc2d_k80000gn/T/tmpm48nga82/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 295, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/xg/dfqs_csd2p536h5xrjc2d_k80000gn/T/tmpm48nga82/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 487, in run_setup
      super().run_setup(setup_script=setup_script)
    File "/private/var/folders/xg/dfqs_csd2p536h5xrjc2d_k80000gn/T/tmpm48nga82/.venv/lib/python3.12/site-packages/setuptools/build_meta.py", line 311, in run_setup
      exec(code, locals())
    File "<string>", line 8, in <module>
  ModuleNotFoundError: No module named 'torch'

  at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/chef.py:166 in _prepare
      162│
      163│                 error = ChefBuildError("\n\n".join(message_parts))
      164│
      165│             if error is not None:
    → 166│                 raise error from None
      167│
      168│             return path
      169│
      170│     def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:

Note: This error originates from the build backend, and is likely not a problem with poetry but with torchsort (0.1.9) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "torchsort (==0.1.9)"'.
teddykoker commented 4 months ago

Hi @petrgazarov, I don't think this is an issue specific to torchsort, but with PyTorch extension packages in general this thread might have some potential solutions (swapping xformers to torchsort).

petrgazarov commented 4 months ago

Thanks - I gave those solutions a go, but I wasn't able to solve the install errors. I ended up just copying the code from your post here, along with Google's fast-soft-sort repo.