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

Unable to install with poetry #467

Open
thomas-reimonn opened this issue Nov 6, 2023 · 5 comments
Open

Unable to install with poetry #467

thomas-reimonn opened this issue Nov 6, 2023 · 5 comments

Comments

@thomas-reimonn
Copy link
Contributor

I can install cooltools using pip but not with poetry. I found a very similar issue here: python-poetry/poetry#4543.

The build configuration for cool tools isn't PEP518 compliant. I've synced with @GarrettNg

@thomas-reimonn
Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@Phlya
Copy link
Member

Phlya commented Nov 8, 2023

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

@thomas-reimonn
Copy link
Contributor Author

thomas-reimonn commented Nov 8, 2023

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

@Phlya
Copy link
Member

Phlya commented Nov 8, 2023

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.

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

No branches or pull requests

2 participants