Paul Monday
Paul Monday

Reputation: 21

Python Packaging and Distribution Scenario

I am still relatively new to python packaging, each time I think I find "the" solution, I am thrown another curve ball, here is my problem followed by what I've tried:

My packaging sophistication has progressed slowly:

For connected systems, I had a really nice process going with

For the disconnected system, I've tried a few things. Wheels seem to be appropriate but I can't get to the "final" installation that includes setuptools, easy_install, pip. I am new to wheels so perhaps I am missing something obvious.

I started with these references:

Is there a reference around for bootstrapping a system that has Python, is disconnected, but does not have setuptools, pip, wheels, virtualenv? My list of things a person must do to install this simple agent is becoming just way too long :/ I suppose if I can finish the dependency chain there must be a way to latch in a custom script to setup.py to shrink the custom steps back down ...

Upvotes: 2

Views: 458

Answers (2)

Rex NFX
Rex NFX

Reputation: 473

The pip install --download option that @mac mentioned has been deprecated and removed. Instead the documentation states that the pip download method should be used instead. So the workflow should be:

  1. Download the python package or installer using your online machine.
  2. Install python using the offline method used by your package manager or the python installer for windows on the offline machine.
  3. On the online machine use pip download -r requirements.txt where "requirments.txt" contains the packages you will be needing the proper format
  4. Use pip install --find-links=<your-dir-here> <pkgname> to install packages on your offline machine.

Upvotes: 1

mac
mac

Reputation: 43091

Your process will likely vary according to what platform you are targeting, but in general, a typical way to get what you are trying to achieve is to download packages on an online machine, copy them over to the offline one, and then install them from a file rather than from a URL or repository).

A possible workflow for RPM-based distros may be:

  1. Install python-pip through binary packages (use rpm or yum-downloadonly, to download the package on an online machine, then copy it over and install it on the offline one with rpm -i python-pip.<whatever-version-and-architecture-you-downloaded>).
  2. On your online machine, use pip install --download <pkgname> to download the packages you need.
  3. scp or rsync the packages to a given directory X onto your offline machine
  4. Use pip install --find-links=<your-dir-here> <pkgname> to install packages on your offline machine.

If you have to replicate the process on many servers, I'd suggest you set up your own repositories behind a firewall. In case of pip, it is very easy, as it's just a matter of telling pip to use a directory as its own index:

$ pip install --no-index --find-links=file:///local/dir/ SomePackage

For RPM or DEB repos is a bit more complicated (but not rocket science!), but possibly also not that necessary, as you really only ought to install python-pip once.

Upvotes: 1

Related Questions