0

I'm trying to install this repository using poetry package manager. Here's how it's done using pip:

git clone --recursive https://github.com/parlance/ctcdecode.git
cd ctcdecode && pip install .

But if I try to run

poetry add ctcdecode

It fails with big traceback (over 200 lines I think). So I installed it with

poetry run git clone --recursive https://github.com/parlance/ctcdecode.git
poetry run pip install ./ctcdecode

But this way is not suitable for sharing with other devs. Can I do it with pyproject.toml somehow?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Jubick
  • 402
  • 3
  • 15
  • 1
    The packaging of this project seems incorrect. I do not think it can be properly installed (well built actually) with poetry (or any other build frontend actually). You could file a bug and tell them to fix their packaging. In particular they should properly declare `torch` as a "build dependency". – sinoroc Feb 17 '21 at 18:43
  • @sinoroc thanks for your answer. I'll point it out in repository. Sad to see popular repository not being packaged properly :( – Jubick Feb 17 '21 at 19:18

1 Answers1

3

poetry add <packagename> adds and installs a dependency available on pypi (or if configured other package repositories) to you project.

If you want to add a package, where the source code is located in a git repository use poetry add git+<url_of_git>.

The problem with ctcdecode in both ways is, that it needs to be build. For this torch is needed. ctcdecode doesn't declare this build dependency in a pyproject.toml according to PEP 518.

You can work around it, by clone the git repository and put a pyproject.toml with this content into the project's folder:

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

Then go back to your current project and add the local path dependency like this:

$ poetry add <relative_path_to_ctcdecode>
finswimmer
  • 10,896
  • 3
  • 34
  • 44
  • Would it work if I fork this repository and add ```pyproject.toml``` in it and then use ```poetry add git+{my_url.git}```? As I need to distribute this project over other PCs. – Jubick Feb 17 '21 at 19:17
  • 1
    The fork idea is good, it should work. I would recommend adding a specific git tag or git commit id as well if it makes sense. And then you wold need to keep your fork up to date for the upcoming releases. – sinoroc Feb 17 '21 at 19:29