Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a good practice to upgrade all python packages in production to their latest versions?

I am running a fairly complex Django application, for about a year now. It has about 50 packages in requirements.txt

Whenever I need a new package, I install it with pip, and then manually add it in the requirements.txt file with a fixed version:

SomeNewModule==1.2.3

That means that most of my packages are now outdated after a year. I have updated couple of them manually when I specifically needed a new feature.

I am beginning to think that there might be security patches that I am missing out, but I am reluctant to update them all blindly, due to backward incompatibility.

Is there a standard best practice for this?

like image 408
Martin Taleski Avatar asked Oct 06 '17 08:10

Martin Taleski


People also ask

Should I update my Python packages?

In order to maintain the security and performance of your application, you'll need to update these packages to a newer version that fixes the issue. The pip package manager can be used to update one or more packages system-wide.

Should you always upgrade pip?

New software releases can bring bug fixes, new features, and faster performance. For example, NumPy 1.20 added type annotations, and improved performance by using SIMD when possible. If you're installing NumPy, you might want to install the newest version.


1 Answers

The common pattern for versioning python modules (and many other software) is major.minor.patch where after the initial release, patch versions don't change the api, minor releases may change the api in a backward compatible way, and major releases usually aren't backward compatible

so if you have module==x.y.z a relatively safe requirement specification would be:

module>=x.y.z,<x.y+1.0

note that while this will usually be OK, it's based on common practices, and not guaranteed to work, and it's more likely to be stable with more "organized" modules

like image 92
Ophir Yoktan Avatar answered Nov 16 '22 00:11

Ophir Yoktan