astroid
astroid copied to clipboard
dependency on typed_ast in 2.0.0 breaks installation on Python 3 when a compiler is not available
Steps to reproduce
- Go into a Python 3.3+ environment without a compiler (eg
docker run -i -t python:3.6-alpine /bin/sh
) - Try to install astroid (or Pylint)
pip install astroid
Current behavior
Installation fails:
...
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
Expected behavior
Installs as normal, like with Python 2
I found this when trying to install Pylint in a docker container in CI.
I understand that 2.0.0 is a 'major' change so this might be expected behaviour, but it means that I either have to lock to a version astroid<2
or install a compiler into the docker container, both of which are not ideal. Is there some way to install this (and by extension Pylint) without using the typed_ast module?
This was already mentioned in https://github.com/PyCQA/pylint/issues/2291, where the culprit was also alpine. But you said an interesting thing in that we can make typed_ast
optional. The thing is that we want typed_ast
to be installed by default at all times, so need to look if this is actually feasible or not.
Here's an alpine Dockerfile which works around this issue by telling pip that the typed_ast
manylinux wheel is compatible with this system. It appears that their is no ABI issue:
FROM alpine:latest
RUN apk add --no-cache --update python3
RUN python3 -m ensurepip
RUN pip3 install --upgrade pip
RUN python3 -c 'import sys; f = open("/usr/lib/python3.6/site-packages/_manylinux.py", "w"); f.write("manylinux1_compatible = True"); f.close()'
RUN python3 -m pip install --upgrade astroid
It might help using a container that's based of off glibc instead of musl.
This seems to no longer be an issue with astroid v2.3.0+ and Python 3.8:
$ docker run -it --rm python:3.8-alpine /bin/sh
/ # pip install astroid
[...]
Installing collected packages: wrapt, six, lazy-object-proxy, astroid
Successfully installed astroid-2.3.2 lazy-object-proxy-1.4.3 six-1.12.0 wrapt-1.11.2
/ #
Looks like maybe typed_ast
isn't used by default now?
Ah, indeed, from reading https://github.com/PyCQA/astroid/issues/675 it seems typed_ast
is not used on Python 3.8+. I guess this issue can be closed now?
@hairyhenderson typed_ast
was merged in the standard library's ast
module on Python 3.8, if I recall correctly. At this point, I think we need to make typed_ast
optional for 3.5-3.7.
Closing as we won't invest the time to fix this for a release we are no longer supporting in the somewhat near future.