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

Fix pip install if torch isn't already installed #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

anth2o
Copy link

@anth2o anth2o commented Nov 8, 2022

Hello !

Currently if you are working on a fresh new environment without torch installed, you have issues when installing this package:

$ pip install git+https://github.com/parlance/ctcdecode.git
Collecting git+https://github.com/parlance/ctcdecode.git
  Cloning https://github.com/parlance/ctcdecode.git to /tmp/pip-req-build-tu1xf42c
  Running command git clone --filter=blob:none -q https://github.com/parlance/ctcdecode.git /tmp/pip-req-build-tu1xf42c
  Resolved https://github.com/parlance/ctcdecode.git to commit c90ad94a0b19554f80804fb7812f2a1447a34a70
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /afs/melodis.com/home/ahoorelbeke/venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-tu1xf42c/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-tu1xf42c/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-wn60pvg7
       cwd: /tmp/pip-req-build-tu1xf42c/
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-tu1xf42c/setup.py", line 10, in <module>
      from torch.utils.cpp_extension import BuildExtension, CppExtension, include_paths
  ModuleNotFoundError: No module named 'torch'
  ----------------------------------------
WARNING: Discarding git+https://github.com/parlance/ctcdecode.git. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

This PR suggests different improvements:

  • pip install in a single line, useful to add this package in a requirements.txt for instance
  • add torch to install_requires in setup.py so that torch is installed after the pip install
  • add torch to requires in pyproject.toml so that torch is present before calling the setup.py and we avoid the error above

You can test this by doing:

pip install git+https://github.com/anth2o/ctcdecode.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant