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