6

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.

Erik A
  • 31,639
  • 12
  • 42
  • 67
Zeinab Abbasimazar
  • 9,835
  • 23
  • 82
  • 131

1 Answers1

12

Install all wheels without listing them explicitly:

pip install /path/to/*.whl
phd
  • 82,685
  • 13
  • 120
  • 165
  • A caveat that the OP didn't require is the ability to install extras. This solution will not work if you need something like `pip install pkg.whl[dev]`. – Keto Jan 04 '22 at 20:58
  • @Keto In what way it doesn't work? Extras are just additional packages, if they're included in `*.whl` they will be installed; installation order is not important. – phd Feb 14 '23 at 09:38
  • It's been a while, but I believe I meant if you want to "Install all wheels without listing them explicitly" and at the same time set extras on certain packages. You cannot glob `*.whl`. – Keto Feb 14 '23 at 20:34