Managing Python Dependencies Transcripts
Chapter: Managing Third-Party Dependencies With pip
Lecture: Introduction to Dependency Management
0:01 You might have heard the term dependency management
0:04 in combination with Python packaging.
0:06 What is dependency management, and what do you need it for?
0:09 So most real world programs that you are going to write
0:12 and that you are going to encounter are likely to use
0:15 third party libraries and frameworks.
0:18 These frameworks that the program uses and that the program requires
0:23 to function are called dependencies, so here is an example.
0:26 Let's say you are working on a project called "my program" and to do its job,
0:31 my program actually relies on two other packages,
0:35 and so my program would enlist these other dependencies
0:39 and use those other packages and other libraries to get the job done.
0:44 So maybe you don't want to reimplement some function like HTTP downloads
0:49 and you program would just use that in a library
0:52 and these packages "super library" and "other dependency",
0:55 they would be called dependencies of my program in this case.
0:59 Of course, not only can your programs have dependencies,
1:05 but the dependencies of you programs can have dependencies again,
1:10 and so on, and this is what we refer to as transitive dependencies,
1:14 or you could also think of them as dependencies of dependencies
1:17 or secondary dependencies.
1:20 So let's take a look at our "my program" example.
1:24 So in this case, we said "my program" has two direct dependencies
1:27 and that will be "super library" and "other dependency",
1:31 now what you can see here is that "super library" and "other dependency" itself,
1:36 actually have dependencies again,
1:38 and some of the dependencies of those dependencies, have dependencies again.
1:43 So this is a whole tree of dependencies.
1:46 On the one hand, having this flexibility is great
1:49 because it allows us to abstract away all kinds of functionality
1:52 and then make that available to other programs and other libraries,
1:56 so that the community of Python developers can build
1:59 increasingly powerful libraries and programs and frameworks.
2:03 But on the other hand, I am sure you're starting to see
2:06 why managing dependencies manually is so difficult, it's super time consuming,
2:11 copying and pasting source code makes updating really difficult,
2:16 imagine you downloaded some file off the internet, some Python source code
2:20 that you're including in your project,
2:23 what happens if you want to update that file-
2:26 maybe a new version came out or the author released a new version,
2:29 and you want to include that in your program
2:31 to make use of some awesome new features.
2:33 Now, if you have to manually copy and paste that around
2:36 it's very easy to make mistakes and it's kind of hard to understand
2:39 what the real dependencies of a program are.
2:42 So if you are sending that over to a co-worker
2:45 or you want to publish that program on the internet,
2:47 it becomes very hard for everyone else to actually understand
2:50 what dependencies they would need to install
2:53 in order to get your program to run.
2:57 The solution to all of these problems is of course, more software;
3:00 You know, I am joking here, but, there is software
3:04 that can make your life a little bit easier
3:06 when it comes to dependency management,
3:08 and this software is typically referred to as package managers.