简体   繁体   中英

How to use NumPy+MKL with Poetry?

I'd like to include NumPy+MKL as a dependency in my project. It seems that the main options for publishing tools are setuptools, Poetry, and Anaconda.

I'd like to use Poetry. I'm already familiar with it; it's a very nice packaging solution. It was made to eliminate the complexities experienced with setuptools. I haven't explored Anaconda much, and if Poetry doesn't work for my package I'll probably try it.

I know that Poetry looks for wheel files on PyPI and doesn't currently have plans to support other "channels" like Anaconda does. So there's no way in pyproject.toml to specify something like:

[tool.poetry.dependencies]
numpy = "1.21.1+mkl"

But there is one feature of Poetry that looks promising: url dependencies . It seems if there were a URL for the NumPy+MKL package I wanted to include, I could specify:

[tool.poetry.dependencies]
numpy = { url = "https://www.lfd.uci.edu/~gohlke/pythonlibs/numpy‑1.21.1+mkl‑cp39‑cp39‑win_amd64.whl" }

And that's exactly what I'd like to do, except there doesn't seem to be an existing URL that works for this purpose. (When I try the above address, I get a "Secure Connection Failed" error in Firefox.)

Am I thinking about this problem correctly? Does anyone know of a URL I can specify in pyproject.toml ?

The wheels available on Christoph Gohlke's site are for personal use only, and are not meant for distribution. His page is not a pip repository, which is why he makes heavy use of Javascript URL obfuscation to download the files. numpy==1.21.1+mkl is not a valid version identifier.

I think you may also be misunderstanding what exactly the MKL builds are. They use the same base code as the regular NumPy package from PyPI - there's nothing different about them except for the fact that the C and Fortran parts are linked against Intel's Math Kernel Library , giving some speed advantages in some situations. They're not magical, they don't implement any new functions, there's nothing different about it except the speed factor, which typically isn't that noticeable except when using very large datasets anyways.

If your users want to use the MKL-linked version of NumPy, they'll already know about it and know how to install it independent of your package. All your package needs is a regular NumPy dependency for the minimum version that meets your code's requirements.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM