py-spy
py-spy copied to clipboard
Instructions for installing on Alpine don't work
Hi, I was following the README's instructions on installing py-spy on Alpine, but it doesn't seem to work on the current version of pip (20.3.3). Downgrading to pip 20.2.4 appears to work around this issue. Looking through pip's source, it appears there were some changes to checking manylinux compatibility in pip 20.3 (I'm not too familiar with glibc vs musl, so apologies if I'm misunderstanding the relevance of that change).
Here are some steps to reproduce the issue:
~:curran$ docker pull python:3.9-alpine
3.9-alpine: Pulling from library/python
Digest: sha256:7492c1f615e3651629bd6c61777e9660caa3819cf3561a47d1d526dfeee02cf6
Status: Image is up to date for python:3.9-alpine
docker.io/library/python:3.9-alpine
~:curran$ docker run -it python:3.9-alpine sh
/ # python --version
Python 3.9.1
/ # pip --version
pip 20.3.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
/ # pip freeze | grep spy
/ # echo 'manylinux1_compatible = True' > /usr/local/lib/python3.9/site-packages/_manylinux.py
/ # pip install py-spy
ERROR: Could not find a version that satisfies the requirement py-spy
ERROR: No matching distribution found for py-spy
/ # pip install pip==20.3
Collecting pip==20.3
Downloading pip-20.3-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 3.2 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.3.3
Uninstalling pip-20.3.3:
Successfully uninstalled pip-20.3.3
Successfully installed pip-20.3
/ # pip --version
pip 20.3 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
/ # pip install py-spy
ERROR: Could not find a version that satisfies the requirement py-spy
ERROR: No matching distribution found for py-spy
WARNING: You are using pip version 20.3; however, version 20.3.3 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
/ # pip install pip==20.2.4
Collecting pip==20.2.4
Downloading pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 1.8 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.3
Uninstalling pip-20.3:
Successfully uninstalled pip-20.3
Successfully installed pip-20.2.4
/ # pip --version
pip 20.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)
/ # pip install py-spy
Collecting py-spy
Downloading py_spy-0.3.4-py2.py3-none-manylinux1_x86_64.whl (3.2 MB)
|████████████████████████████████| 3.2 MB 1.4 MB/s
Installing collected packages: py-spy
Successfully installed py-spy-0.3.4
WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available.
You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
/ #
Thanks.
I found a way to install py-spy on alpine image. All we have to do is use auditwheel to repair the manylinux wheel to musllinux wheel & we are good to install it on alpine.
- Download the wheel from: https://github.com/benfred/py-spy/releases
- Repair the wheel using auditwheel
- Install the musllinux wheel
You can add the following to your Dockerfile:
ENV pip_install="pip3 install --disable-pip-version-check --no-cache-dir"
ADD https://github.com/benfred/py-spy/releases/download/v0.3.12/py_spy-0.3.12-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl /tmp
RUN $pip_install auditwheel patchelf \
&& auditwheel repair /tmp/py_spy-0.3.12-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl \
&& $pip_install /wheelhouse/*