2

I want to create a debian package that when installed, it will install several python packages with pip. I can think of two ways:

  1. install the python packages into a directory then make a debian package from that directory. But this will confuse the building host (such as its pip metadata), especially if the host already installed some of those packages.

  2. make a debian package with all python packages, and during debian install and uninstall, run some scripts to install/uninstall the python packages. But this will need two more scripts to be maintained, and some place to hold all the python packages in the installed machine.

Any other solution and what's the best way to solve this problem?

Hanks
  • 349
  • 1
  • 2
  • 15
  • Dependencies are handled using a Debian control file. A lot of information can be found by installing maint-guide, i.e. `apt-get install maint-guide`. If you do it this way, the package system will take care of everything. – Jens Munk Sep 24 '15 at 21:42
  • We can't depend on that because Internet is not guaranteed and we want to control the exact files we installed. – Hanks Sep 24 '15 at 21:52
  • You don't need internet for using packages. But in case they are missing e.g python-matplotlib you need to provide the packages required for this – Jens Munk Sep 24 '15 at 21:55
  • I think I looked into this before and I can't find a way to specify local directory that it will search when pip requires a dependency. – Hanks Sep 24 '15 at 22:24

2 Answers2

1

In my opinion if you want to create a debian package you should avoid reference to external distribution systems. Here there are the guidelines about the creation of python packages under debian.

EDIT: Sorry, I see now that the Debian wiki page about Python Packaging could be outdated. You could read:

  • Thanks! But it seems that it only applies for one python package in one debian package? I'm not sure how much work is required to enhance it... – Hanks Sep 24 '15 at 22:26
0

If you want to create a meta package which depends on python-<packagename> in repositories, it is easy and I think you already know that. (if not, google equivs package). I assume you would like to have recent versions of the python packages installed or some packages are missing in debian repositories so the debian repositories will not be used.

pip is a good tool however you can break dependencies if you unistall a python package which my be required by another package which is installed by apt after your meta package. apt is your friend. You should be careful. To overcome this, my suggestions is to add the appropriate package names to your meta package's control file's Provides, Conflicts and Replaces fields whether you dynamically install the python packages via pip or bundle them in your main package. I quickly searched "bundling multiple debian packages into one package" and found no solution.

If you want to completely seperate your python packages from your system wide python packages, virtualenv is the best choice I know. And if you want to build debian compliant packages using pip, stdeb can do that easily.

Moreover, As far as I remember, I saw some packages in Kali Linux (Debian based) dynamically installing python packages during install or during startup however Debian policies may not allow this kind of flexibility not to break dependencies (if you want to build an official package). I hope this answer guide you in the right direction.

Ozan
  • 1,044
  • 1
  • 9
  • 23
  • Thanks! What I really want to do is to provide a debian package to install all python modules we want without dependency to the Internet. The best thing we should do is probably to create a VM image but we just can't now... – Hanks Sep 28 '15 at 19:34
  • So, last idea came into my head is to use a local pip server so you do not need internet when you install the predownloaded packages http://stackoverflow.com/q/18052217/5303401 – Ozan Sep 28 '15 at 21:10