2

I want to generate python tar or wheel file which will contain all packages (dependencies) in it along with multiple dependent project modules.

I have a cliff based CLI module which we have multiple pythons based Swagger SDK.

I want to build a package with this which will get install in offline (without internet )with simple pip install build_package.zip command.

Mayur
  • 576
  • 2
  • 5
  • 26
  • How about just using something like Docker instead? – eandersson Nov 03 '18 at 00:47
  • Yes, I'm trying to make the installation process easier and docker will good solution but installing docker and maintaining container is much harder for the end user. – Mayur Nov 06 '18 at 13:19

1 Answers1

1

You'll probably have to build a wheel for each project (i.e. each dependency). Then, install them by order of dependence (to install directly a wheel have a look to this SO question).

If you want to have everything in the same archive, you could simply zip all wheels along. First you unzip them, and finally, install each wheel one by one (you could embed everything in a self-extracting archive, for instance like there).


Another more greedy approach is to zip everything in your site-packages. It is located near your installed python bin (i.e. venv/lib/python2.7/site-packages for a virtualenv called venv in python 2.7). Then you just need to unzip everything in the site-packages of your target machine.

However, note that this assume that both the machine you use to zip and the target machine have the same architecture, and run the same version of python... Furthermore, you'd have to be careful while archiving since you might have extra dependencies not required, if you installed other packages for instance).


Final note, I guess you have already considered the option, however, I'd recommend you re-consider. Allowing the project to be installed on-line is actually less cumbersome when it comes to version handling (i.e. by doing all this manually, you'll loose version management: pip install --upgrade ...).

Léopold Houdin
  • 1,515
  • 13
  • 18