pip install fails (m1 mac, aarch64) and workaround
jwmay2012 opened this issue · 2 comments
mprofile
is failing to compile when I try to pip install pyproff
inside a container, running on Apple M1 Max.
Dockerfile
FROM python:3.9-slim
RUN apt-get -qqy update
RUN apt-get install gcc g++ -y
RUN pip install -U pip
RUN pip install pypprof
docker build .
#8 4.219 × Running setup.py install for mprofile did not run successfully.
#8 4.219 │ exit code: 1
#8 4.219 ╰─> [23 lines of output]
#8 4.219 running install
#8 4.219 running build
#8 4.219 running build_py
#8 4.219 creating build
#8 4.219 creating build/lib.linux-aarch64-3.9
#8 4.219 creating build/lib.linux-aarch64-3.9/mprofile
#8 4.219 copying mprofile/__init__.py -> build/lib.linux-aarch64-3.9/mprofile
#8 4.219 running build_ext
#8 4.219 building 'mprofile._profiler' extension
#8 4.219 creating build/temp.linux-aarch64-3.9
#8 4.219 creating build/temp.linux-aarch64-3.9/src
#8 4.219 creating build/temp.linux-aarch64-3.9/third_party
#8 4.219 creating build/temp.linux-aarch64-3.9/third_party/google
#8 4.219 creating build/temp.linux-aarch64-3.9/third_party/google/tcmalloc
#8 4.219 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPY_SSIZE_T_CLEAN -I/tmp/pip-install-sdxxkev3/mprofile_cf51baac42a347ae9f7457a4d8ea7eb2 -Isrc -I/usr/local/include/python3.9 -c src/_profiler.cc -o build/temp.linux-aarch64-3.9/src/_profiler.o -std=c++11
#8 4.219 In file included from src/heap.h:12,
#8 4.219 from src/_profiler.cc:7:
#8 4.219 src/spinlock.h: In member function ‘void SpinLock::lock()’:
#8 4.219 src/spinlock.h:30:9: error: ‘__builtin_ia32_pause’ was not declared in this scope; did you mean ‘__builtin_iswspace’?
#8 4.219 30 | __builtin_ia32_pause();
#8 4.219 | ^~~~~~~~~~~~~~~~~~~~
#8 4.219 | __builtin_iswspace
#8 4.219 error: command '/usr/bin/gcc' failed with exit code 1
#8 4.219 [end of output]
#8 4.219
#8 4.219 note: This error originates from a subprocess, and is likely not a problem with pip.
#8 4.221 error: legacy-install-failure
#8 4.221
#8 4.221 × Encountered error while trying to install package.
#8 4.221 ╰─> mprofile
I don't know much about this problem, but a workaround I've found is to change the initial container image to
FROM --platform=linux/amd64 python:3.9-slim
as it usually defaults to aarch64
.
There's also this DOCKER_DEFAULT_PLATFORM=linux/amd64
I felt compelled to document and share this.
Well. I'm trying to use pypprof
for a Django application and apparently my 'fix' --platform=linux/amd64
breaks Django completely in the local environment.
Does anyone have any ideas on how to get this compiling in aarch64
?
Thanks
Opened a PR to fix this #5. I haven't tested it too much yet, so please use with caution.