Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install pylint in Alpine Linux based Docker Image

I am trying to install Pylint in a custom Docker image which is based on the Alpine Linux distribution of the official Python image. I tried with the following Dockerfile:

FROM python:3.4-alpine
RUN apk add --update pylint

<< This fails with

Step 2/2 : RUN apk add --update pylint
 ---> Running in 34949003816d
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  pylint (missing):
    required by: world[pylint]
The command '/bin/sh -c apk add --update pylint' returned a non-zero code: 1

Besides, I tried

FROM python:3.4-alpine
RUN pip3 install pylint

<< This fails with

Step 2/2 : RUN pip3 install pylint
 ---> Running in b044e3347d26
Collecting pylint
  Downloading pylint-1.7.1-py2.py3-none-any.whl (641kB)
Collecting mccabe (from pylint)
  Downloading mccabe-0.6.1-py2.py3-none-any.whl
Collecting isort>=4.2.5 (from pylint)
  Downloading isort-4.2.5-py2.py3-none-any.whl (40kB)
Collecting six (from pylint)
  Downloading six-1.10.0-py2.py3-none-any.whl
Collecting astroid>=1.5.1 (from pylint)
  Downloading astroid-1.5.2-py2.py3-none-any.whl (269kB)
Collecting wrapt (from astroid>=1.5.1->pylint)
  Downloading wrapt-1.10.10.tar.gz
Collecting lazy-object-proxy (from astroid>=1.5.1->pylint)
  Downloading lazy-object-proxy-1.2.2.tar.gz
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/lazy_object_proxy.egg-info
    writing dependency_links to pip-egg-info/lazy_object_proxy.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/lazy_object_proxy.egg-info/top_level.txt
    writing pip-egg-info/lazy_object_proxy.egg-info/PKG-INFO
    writing manifest file 'pip-egg-info/lazy_object_proxy.egg-info/SOURCES.txt'
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'pip-egg-info/lazy_object_proxy.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    error: [Errno 2] No such file or directory: 'examples'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1wq1n3ss/lazy-object-proxy/
The command '/bin/sh -c pip3 install pylint' returned a non-zero code: 1

Finally, I tried building Pylint from source with the following Dockerfile:

FROM python:3.4-alpine
RUN apk add --update openssl
RUN wget https://github.com/PyCQA/pylint/archive/master.zip
RUN unzip master.zip
RUN cd pylint-master && python3 setup.py install

<< This now fails with

Step 1/5 : FROM python:3.4-alpine
 ---> 9ac5db25a0ca
Step 2/5 : RUN apk add --update openssl
 ---> Using cache
 ---> d9f61f983819
Step 3/5 : RUN wget https://github.com/PyCQA/pylint/archive/master.zip
 ---> Using cache
 ---> 2a536c150b22
Step 4/5 : RUN unzip master.zip
 ---> Using cache
 ---> e160d601a015
Step 5/5 : RUN cd pylint-master && python3 setup.py install
 ---> Running in d2a20f20ff12

(...)

Searching for lazy_object_proxy
Reading https://pypi.python.org/simple/lazy_object_proxy/
Downloading https://pypi.python.org/packages/65/63/b6061968b0f3c7c52887456dfccbd07bec2303296911757d8c1cc228afe6/lazy-object-proxy-1.2.2.tar.gz#md5=841b5592bc12c6ef7e48ed1d7a5f9066
Best match: lazy-object-proxy 1.2.2
Processing lazy-object-proxy-1.2.2.tar.gz
Writing /tmp/easy_install-mxtkzpjj/lazy-object-proxy-1.2.2/setup.cfg
Running lazy-object-proxy-1.2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mxtkzpjj/lazy-object-proxy-1.2.2/egg-dist-tmp-f6oeoyxl
error: Setup script exited with error: [Errno 2] No such file or directory: 'examples'
The command '/bin/sh -c cd pylint-master && python3 setup.py install' returned a non-zero code: 1

Any idea how to get Pylint installed?

like image 931
Dirk Avatar asked Dec 18 '22 07:12

Dirk


2 Answers

Looks like a recent version of setuptools was missing. After adding it to the Dockerfile, the pip way of installing pylint works just fine.

FROM python:3.4-alpine
RUN pip3 install -U setuptools
RUN pip3 install -U pylint
like image 87
Dirk Avatar answered Dec 21 '22 10:12

Dirk


... and for getting pylint running on Python 3.7 with an Alpine container:

FROM python:3.7-alpine
RUN apk update
RUN apk add build-base
RUN pip3 install -U pylint
like image 21
Willem van Ketwich Avatar answered Dec 21 '22 11:12

Willem van Ketwich