Unable to install with poetry
I can install cooltools using pip but not with poetry. I found a very similar issue here: https://github.com/python-poetry/poetry/issues/4543.
The build configuration for cool tools isn't PEP518 compliant. I've synced with @GarrettNg
thomas@MacBook-Air-TR joint-pca-hic % poetry add cython The following packages are already present in the pyproject.toml and will be skipped:
• cython
If you want to update it to the latest compatible version, you can use poetry update package.
If you prefer to upgrade it to the latest available version, you can use poetry add package@latest.
Nothing to add. thomas@MacBook-Air-TR joint-pca-hic % poetry add cooltools Using version ^0.5.4 for cooltools
Updating dependencies Resolving dependencies... (0.5s)
Package operations: 8 installs, 0 updates, 0 removals
• Installing imageio (2.31.5) • Installing lazy-loader (0.3) • Installing llvmlite (0.41.1) • Installing networkx (3.2.1) • Installing tifffile (2023.9.26) • Installing numba (0.58.1) • Installing scikit-image (0.22.0) • Installing cooltools (0.5.4): Failed
ChefBuildError
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Traceback (most recent call last):
File "/opt/homebrew/Cellar/poetry/1.6.1_4/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in
at /opt/homebrew/Cellar/poetry/1.6.1_4/libexec/lib/python3.12/site-packages/poetry/installation/chef.py:147 in _prepare 143│ 144│ error = ChefBuildError("\n\n".join(message_parts)) 145│ 146│ if error is not None: → 147│ raise error from None 148│ 149│ return path 150│ 151│ 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 cooltools (0.5.4) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "cooltools (==0.5.4)"'.
So I ran what poetry suggested: pip wheel --use-pep517 "cooltools (==0.5.4)" and it built a wheel for me. Then I added
cooltools = { file = "lib/cooltools-0.5.4-cp311-cp311-macosx_13_0_arm64.whl" } to pyproject.toml and we're all good.
Hi Thomas, would you be able to make a PR with this fix?
I would if I knew how. Do you have any pointers? The issue seems to be that cooltools requires cython to build. It installs with pip if cython is already installed. However, poetry seems to try building it in a separate environment, so even if you poetry add cython it doesn't work when you poetry add cooltools. For now, I built the wheel manually with pip wheel --use-pep517 "cooltools (==0.6.0)" and then told poetry to use the wheel in pyproject.toml cooltools = { file = "lib/cooltools-0.6.0-cp311-cp311-macosx_14_0_arm64.whl" }.
Oh I see, sorry, I misunderstood your last comment and thought that was the fix. Sorry, I've never used poetry, no idea... But packaging with cython has always been a pain.