Darshan
Darshan

Reputation: 382

How to package all my library dependencies in wheel file?

I have one custom library/package (say my_utils) which has some library dependencies such as pandas, numpy, boto, etc. I have created wheel (my_utils.whl) of the same but it doesn't include the dependencies I have mentioned above. So when I install my_utils.whl, it'll download dependencies online.

My requirement is to install my_utils.whl file on a server which doesn't have an internet connection. So I want to package all the dependencies along with my_utils.whl to create final_my_utils.whl.

On the server, where I want to upload this wheel file, has GUI and can install only wheel files using pip3 install final_my_utils.whl

Is there any way I can achieve this?

EDIT: Appreciate all the answers. But as I mentioned, the server on which I want to install this package has only GUI and I cannot run any commands. Internally, it'll run pip3 install some_wheel.whl file. Hence I want single wheel file packaging all dependencies.

Upvotes: 5

Views: 8115

Answers (1)

Ehsan
Ehsan

Reputation: 4281

first of all you need to create a wheelhouse dir in your project and cd in.

mkdir wheelhouse
cd wheelhouse

Second, you should run for all packages you want.

for example: numpy and flask ...

pip wheel numpy flask

All your wheels go into the wheelhouse dir. Just zip the dir, then, unzip it on the target server and run below script:

import glob, pip
for path in glob.glob("c:/path/to/wheelhouse/*.whl"):
    pip.main(['install', path])

Upvotes: 2

Related Questions