Install prebuilt packages from conda-forge (e.g. cartopy) using poetry without relying on conda (using only the channel)
Asked Answered
B

1

9

I'm testing poetry and I was wondering if it is possible to install prebuilt packages from conda-forge, as cartopy without relying on conda (so keeping a 100% poetry process). I googled this a bit but the only way I found is to install poetry within a conda venv using pip and then installing from conda-forge using conda and then tweaking poetry files to make it aware of the conda venv so that the TOML is written properly.

Packages like cartopy are a pain to install if not from a prebuilt version, if possible I'd change my conda stack to poetry stack if something like poetry add [?conda-forge?] cartopy works

Thanks.

Barye answered 5/5, 2021 at 14:34 Comment(4)
Just to be clear, you're looking for a way to install conda packages from conda-forge without using conda (as a package manager)?Salvatore
@MattThompson exactly, a way to specify to poetry to use other repo than pypi (here conda-forge)Barye
Just FYI - they (pip and conda) are different package managers (in addition to being different channels). Unless something's changed recently, poetry only uses pip and does not plan to support conda install (github.com/python-poetry/poetry/issues/1856). I'll admit it's a bit weird, since they do so much in common, but they're not interchangeable.Salvatore
@MattThompson yes, that was what I understood. Poetry is using pip, however you can install a precompiled package as, e.g., poetry add -D "C:\Users\wheels\GDAL-3.2.2-cp38-cp38-win_amd64.whl". I was then wondering if there was a way to use the conda-forge channel/website or to specify an URL instead of downloading and store locally the *.whl. Thanks anywayBarye
G
2

Not currently possible. Conda is a generic package manager, not just a Python package manager. Furthermore, there is no dedicated metadata in Conda packages to discriminate whether or not they are Python packages, which I think would be a prerequisite for Poetry being able to determine whether the Conda package is even valid for installation. Hence, what OP requests cannot be a thing, or at least would it be a major undertaking to make it one.

However, others have requested similar features, so someone hopeful for such functionality could subscribe to notifications on those, or follow the Feature Roadmap.

Grandeur answered 16/5, 2021 at 4:25 Comment(3)
Ok thank you for the details. The workaround I found for know is: 1) download the *.whl of precompiled packages from the conda-forge (or other) repo 2)Store them locally 3) poetry add -D "C:\Users\wheels\precompiled_pkg_name.whl"Barye
Note that instead of downloading the *.whl and store it locally, one can use directly the URL pointing to the *.whl This can already be a solution for installing pre-built packages and using poetry (delegating the validation to the user though)Barye
@ThomasBury Just be careful. Many Conda packages are built with dynamic links that assume a Conda environment structure.Grandeur

© 2022 - 2024 — McMap. All rights reserved.