Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install from custom whl file in Dockerfile

I have a Dockerfile which is trying to install a whl file which is located in my project using pip. I want to force pip to include my whl file in its searches, but it doesn't:

No distributions matching the version for mylibname==mylibversion

I tried using build_ext with options -L:

pip install --global-option=build_ext --global-option="-L/directory/containing/whl/file/"

-I:

pip install --global-option=build_ext --global-option="-I/directory/containing/whl/file/"

and -b:

pip install --global-option=build_ext --global-option="-b/directory/containing/whl/file/"

But none of them worked.

EDIT 1:

This is my Dockerfile:

FROM python:2.7.9
MAINTAINER Zeinab Abbasimazar
ADD myprojectdir .
RUN ls -la ${HOME}/myprojectdir/dependency
RUN pip --version
RUN pip install --global-option=build_ext --global-option="-L${HOME}/myprojectdir/dependency" mypackagename-mypackageversion
WORKDIR .
CMD python --version

This is the output of docker build -t myimagename .:

Sending build context to Docker daemon 4.096 kB
Step 1 : FROM python:2.7.9
 ---> 646fa5bbf55d
Step 2 : MAINTAINER Zeinab Abbasimazar
 ---> d08f7cb9e985
Step 2 : ADD myprojectdir .
 ---> 0e190b21a30b
Step 3 : RUN ls -la ${HOME}/myprojectdir/dependency
total 1740
drwxr-sr-x 2 root staff    4096 Sep  6 11:58 .
drwxr-sr-x 3 root staff    4096 Sep  6 11:58 ..
-rw-r--r-- 1 root staff  454253 Sep  6 11:58 mypackagename-mypackageversion-py2-none-any.whl
 ---> d069986bd3b6
Step 4 : RUN pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)
 ---> ddeccc833ea2
Step 5 : RUN pip install --global-option=build_ext --global-option="-L${HOME}/myprojectdir/dependency" mypackagename-mypackageversion
Downloading/unpacking mypackagename-mypackageversion
  Could not find a version that satisfies the requirement mypackagename-mypackageversion
Cleaning up...
No distributions matching the version for mypackagename-mypackageversion
Storing debug log for failure in /root/.pip/pip.log
The command '/bin/sh -c pip install --global-option=build_ext --global-option="-L${HOME}/myprojectdir/dependency" mypackagename-mypackageversion' returned a non-zero code: 1

EDIT2:

The pip install /path/to/the/whl/file.whl completely works; but it's not what I want.

like image 457
Zeinab Abbasimazar Avatar asked Sep 06 '17 11:09

Zeinab Abbasimazar


1 Answers

Install all wheels without listing them explicitly:

pip install /path/to/*.whl
like image 74
phd Avatar answered Sep 19 '22 12:09

phd