cooltools icon indicating copy to clipboard operation
cooltools copied to clipboard

Unable to install with poetry

Open thomas-reimonn opened this issue 2 years ago • 5 comments

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-reimonn avatar Nov 06 '23 21:11 thomas-reimonn

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 main() File "/opt/homebrew/Cellar/poetry/1.6.1_4/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/poetry/1.6.1_4/libexec/lib/python3.12/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/m7/vfpcz_7d2b1_4rv2qhkgk_fc0000gn/T/tmp3tybgydp/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 355, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/private/var/folders/m7/vfpcz_7d2b1_4rv2qhkgk_fc0000gn/T/tmp3tybgydp/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 325, in _get_build_requires self.run_setup() File "/private/var/folders/m7/vfpcz_7d2b1_4rv2qhkgk_fc0000gn/T/tmp3tybgydp/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 507, in run_setup super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script) File "/private/var/folders/m7/vfpcz_7d2b1_4rv2qhkgk_fc0000gn/T/tmp3tybgydp/.venv/lib/python3.11/site-packages/setuptools/build_meta.py", line 341, in run_setup exec(code, locals()) File "", line 9, in ModuleNotFoundError: No module named 'Cython'

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)"'.

thomas-reimonn avatar Nov 06 '23 21:11 thomas-reimonn

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.

thomas-reimonn avatar Nov 06 '23 21:11 thomas-reimonn

Hi Thomas, would you be able to make a PR with this fix?

Phlya avatar Nov 08 '23 14:11 Phlya

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" }.

thomas-reimonn avatar Nov 08 '23 14:11 thomas-reimonn

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.

Phlya avatar Nov 08 '23 14:11 Phlya