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

Poetry does not install from wheels on macOS Big Sur #3458

Closed
3 tasks done
williammck opened this issue Dec 6, 2020 · 16 comments · Fixed by python-poetry/poetry-core#125
Closed
3 tasks done

Poetry does not install from wheels on macOS Big Sur #3458

williammck opened this issue Dec 6, 2020 · 16 comments · Fixed by python-poetry/poetry-core#125
Labels
kind/bug Something isn't working as expected

Comments

@williammck
Copy link

Issue

When using Poetry on Big Sur, poetry.installation.chooser.Chooser is not recognizing available macOS wheels.
e.g. Poetry uses cryptography-3.0.tar.gz instead of cryptography-3.0-cp27-cp27m-macosx_10_10_x86_64.whl.

This has been fixed in pypa/packaging#319 (v20.5 and above), however it appears that Poetry is using packaging v20.4.
I've tracked it down to https://github.com/python-poetry/poetry-core vendoring in packaging v20.4, as poetry.utils.env.VirtualEnv.get_supported_tags is using ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/_vendor/packaging/tags.py as the script source on my machine.

I'm happy to put up a PR for this both here and in poetry-core, I just wasn't sure how to proceed with the vendoring there and how it ties back to here.

If there's any clarification I can provide, let me know :)

@williammck williammck added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 6, 2020
@donaldguy
Copy link

For a sketchy workarount in the meantime

pip=$(which pip)
pushd $PWD
cd "$(dirname $(which poetry))/../lib/poetry/_vendor/"
cd "py$( python -V | grep -o '[23]\.[0-9]\+')"
cd poetry/core/_vendor
sed -i '' 's/packaging==20.4/packaging==20.5/' vendor.txt
$pip install -t $PWD --upgrade -r vendor.txt
unset pip
popd

@williammck
Copy link
Author

For a sketchy workarount in the meantime

Feels weird but works (changed mine to install packaging==20.7 since that's latest).
Also calling out that virtualenv still has wheels for pip 20.2.2 packaged with it, I needed to run poetry run pip install -U pip so that pip would install macOS wheels without erroring.

But with those two changes, seems like things are working... so one upstream dependency and then figuring out what all's in Poetry that needs changing.

@emanueljacob
Copy link

I can confirm that the workaround by @donaldguy works well on MacOS 11.0 . I created a PR for that (in fact for packaging 20.8 not just 20.5), the tests have run successfully locally. Seems to be a small PR for me and therefore would be nice to see this reviewed and merged soon :)

@henryiii
Copy link

henryiii commented Jan 5, 2021

The old version of packaging also means poetry can't install NumPy on Big Sur (Intel) with the last released version (the build fails since it's not getting a wheel, and there's some setup required to add a BLAS library since Apple Accelerate is buggy).

For Big Sur Apple Silicon, you'll want pypa/packaging#380 which has just landed and is not yet in a released version of packaging (or pip, obviously), as otherwise it still will not be able to pick up normally-named binary wheels.

@barentsen
Copy link

barentsen commented Jan 8, 2021

Using poetry 1.1.4 with Python 3.8.6 (intel i386) on MacOS 11.1 (Big Sur), poetry also fails to install numpy for me with the following error:

numpy.distutils.system_info.NotFoundError: No lapack/blas resources found. Note: Accelerate is no longer supported.

As pointed out above, the problem is that poetry attempts to install packages from source rather than using the appropriate wheel, and the solution is to upgrade the version of packaging that is vendored with poetry.

Solution

Inspired by #3458 (comment) above, the following steps resolve the issue for me by updating the version of packaging that is embedded within poetry-core. These steps assume you already have poetry installed in your python environment:

git clone https://github.com/python-poetry/poetry-core.git
cd poetry-core
sed -i '' 's/packaging = "^20.1"/packaging = "^20.8"/g' vendors/pyproject.toml
python -m pip install vendoring  # required for the next step
make vendor/sync                 # updates the dependencies listed in vendors/pyproject.toml
python -m pip install .          # move the updated dependencies to site-packages

I'd open a PR to update the version of packaging that is included within poetry-core, but I think I better leave it to a maintainer with a good understanding of these vendored dependencies? I say this because running make vendor/sync also updated/modified some of the other embedded dependencies, and it's unclear to me whether that is desirable?

@sinoroc
Copy link

sinoroc commented Jan 8, 2021

@barentsen As far as I understood, there is already a PR: #3530. If you get the chance, give it a try, leave some feedback, review the code.

@barentsen
Copy link

barentsen commented Jan 8, 2021

@sinoroc Excellent point! I forgot to mention: I evaluated PR #3530 and it did not appear to resolve the issue for me. I posted details here: #3530 (comment).

@sinoroc
Copy link

sinoroc commented Jan 8, 2021

@barentsen

Excellent point! I forgot to mention: I evaluated PR #3530 and it did not appear to resolve the issue for me. I posted details here: #3530 (comment).

I see. My bad.

@henryiii
Copy link

There should be a new release of packaging somewhat soon, and it will fix a bug that causes correctly named universal2 wheels to not be loaded on Apple Silicon, but it looks like it will also drop Python 2.7, 3.4, and 3.5 support, so it might be something to watch for, as I think Poetry partially supports 2.7 and fully supports 3.5, at least that was my impression. Not that I've tried that :). Going up to 20.8 would at least fix the issue for all macOS 11 users on Intel that can't get things like NumPy wheels with Poetry currently! See pypa/packaging#385 and pypa/packaging#376 .

@nilnullzip
Copy link

nilnullzip commented Jan 23, 2021

Same issue on Intel silicon (16" 2019 MBP). Numpy and others don't download MacOS wheels and the attempted compile fails. My workaround is installing the failed packages at the specified revision with pip, after which running Poetry install/update succeeds. Make sure you also update pip if you see a message to that effect. I've had problems if I don't, although not sure if related.

@henryiii
Copy link

It's the same issue if you use pip 20.2 (which tends to be default some places, like the CLT venv), it's due to old versions of packaging. Pip updated the vendored packaging in 20.3, and poetry needs to, too.

@williammck
Copy link
Author

I've fixed this locally for the time being by setting an alias for Poetry...
alias poetry='env SYSTEM_VERSION_COMPAT=1 poetry'

Setting SYSTEM_VERSION_COMPAT=1 instructs macOS to return 10.16 for any system version lookups, which fixes the issues with older versions of https://github.com/pypa/packaging.

@damienrj
Copy link

Nice, I will have to give this a try. I had been exporting to requirements.txt to get things to work for now.

@damienrj
Copy link

This solution worked better than most but fails with xgboost even with the new poetry core. I am sticking with converting to requirements.txt for now it seems.

@maxmorlocke
Copy link

For those still encountering this and finding this lovely thread, I had success getting things installed with a M2 running Monterrey using:

brew install mupdf swig freetype
poetry add PyMuPDF

Installing mupdf alone didn't cover it all.

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants