4

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.

Darshan
  • 352
  • 8
  • 24
  • "which doesn't have an internet connection": If I get this right, you will need to package all the dependencies in your distributable. I have only attempted that in the past with https://www.pyinstaller.org. I think you will need to build on the same exact clone of the box (os, python version, etc) if any of your deps are C/C++ based or they require system libs (like openssl) – urban Sep 15 '19 at 08:06
  • You can also check out bazel (https://docs.bazel.build/versions/master/be/python.html) and buck (https://buck.build/rule/python_library.html#content) as alternative build and packaging systems – urban Sep 15 '19 at 08:09
  • Possible duplicate of [Python Packages Offline Installation](https://stackoverflow.com/questions/11091623/python-packages-offline-installation) – phd Sep 15 '19 at 11:14
  • https://stackoverflow.com/search?q=%5Bpip%5D+offline – phd Sep 15 '19 at 11:14
  • 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. – Darshan Sep 19 '19 at 06:55

1 Answers1

1

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])
Ehsan
  • 3,711
  • 27
  • 30
  • 3
    Appreciate your answer. 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. – Darshan Sep 16 '19 at 10:54
  • 1
    @Darshan did you find an answer yet? – mad_ Jun 06 '22 at 15:09