I'm looking for a good way to package a Python application that is going to be deployed on a Debian server.

The application itself depends on some modules which are not included in base Debian repository, although they might be in the future. This creates some problems... I depend on some patches to those modules. If the original module gets installed one day, the application will break. However if I install everything I need in a virtualenv just for that application, I lose the ability to upgrade Python itself (in case of security updates).

The third option would be to rename my fork of the upstream module and just treat it as a completely separate one. But that would mean changing the code (not much work, but it wouldn't be that clean / universal anymore).

Are there any other options that I missed? Are there any pros / cons I didn't see in the solutions above?


Try installing your custom modules into a different location (outside of the normal sys.path location) and then adding the new install location to your $PYTHONPATH.

This may avoid the problem that could arise if the upstream version of your patched modules is installed, thus breaking your system.


A virtualenv will still get python upgrades; the standard library and interpreter are both symlinked. You do have to worry about upgrades to the python modules installed into the virtualenv, including ones that could have been shipped by the distro. So I recommend making your own packages for the customized modules and letting the app break if the original module gets a security update.

  • "the standard library and interpreter are both symlinked" -> not true. Libs are symlinked unless "--no-site-packages" is specified. The interpreter is a copy. (at least as of virtualenv 1.4.9) – viraptor Nov 15 '10 at 1:01
  • You're correct about the interpreter. The standard libs are symlinked though. IIRC --no-site-packages changes the way sys.path is manipulated. – Tobu Nov 15 '10 at 7:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.