Managing Python Dependencies Transcripts
Chapter: Managing Third-Party Dependencies With pip
Lecture: Python Package Repositories
0:01 An important part of dependency management is of course
0:04 the ability to store packages somewhere
0:07 so that you or other people can install them.
0:10 Now, let's talk about Python package repositories.
0:14 Python packages are collected in so called software repositories.
0:18 The biggest, or official software repository in Python is called PyPi.
0:23 It's also sometimes called the "Cheese Shop",
0:27 because Python developers just love their Monty Python references.
0:32 Developers can register for a free PyPi account
0:35 and then submit new packages to the repository.
0:39 And once a package appears in PyPi, everyone else can install it through pip,
0:43 so this is a really popular method to distribute open source Python packages,
0:47 and there are literally tens of thousands of packages available for free,
0:51 that you could just install through pip.
0:55 And by the way, there is no review or QA process for packages submitted to PyPi.
1:00 So whenever you install a package from PyPi,
1:03 it makes sense to invest some time into do diligence work
1:06 and reviewing what's available, so that you get a quality piece of software.
1:10 Let's search for some packages on PyPi.
1:14 We're going to take a look at the PyPi website now,
1:17 and you can find it at pypi.python.org.
1:21 Lets fire up a browser and then take a look at the PyPi website.
1:26 Alright, this is PyPi, you can see some stats here so right now,
1:31 they are close to a 100 thousand packages available here, on PyPi,
1:35 and when you scroll down, you can see sort of a update log
1:39 of recently updated packages as people pushed them to the package repository
1:44 you can see here what was updated.
1:47 And of course, one of the most important parts of the site here is the search box.
1:51 So into the search box, you can enter keywords
1:54 and basically do a full text search on the descriptions
1:58 and the metadata for the packages available on PyPi,
2:01 so you've probably heard of the really popular Requests package,
2:05 which is a HTTP download library, so I am going to go ahead
2:09 and search for Requests here.
2:12 Okay, so these are the search results for Requests,
2:15 and what is interesting here is that the actual Requests library
2:18 that I was looking for, is not the number one search result, right,
2:22 because this is just doing a search across all of the descriptions
2:25 and the metadata in all of the available packages.
2:28 So I get some very exhaustive results here, and you can see here
2:32 as I scroll down this is a really long list, because,
2:34 obviously the keyword Requests seems to be quite popular.
2:38 Alright, so I am going to go ahead and click on the Requests library here,
2:43 because, every package in PyPi actually has its own landing page,
2:48 so it has its own page on PyPi where the developers can host the readme
2:53 and give some links to the documentation or release history, and stuff like that.
3:00 So what you can see here is that right now
3:04 I am looking at the specific version of Requests,
3:06 and you can also see that reflected here in the url,
3:09 so this will be a pypi-name of the library-the version.
3:13 So this is handy if you ever want to link to a specific library
3:17 or a specific version of library, because you can just use that link.
3:20 This is the readme file or the description
3:24 that the creators of the Requests library have put together.
3:27 So the contents of this description here largely depend
3:31 on the information that the library creators put in.
3:36 Sometimes the formatting as it's displayed on the PyPi website isn't perfect,
3:39 so you are going to get these super blown up images here, just ignore that for now.
3:43 Actually, what I wanted to show you is when you scroll all the way down here,
3:49 there will always be the summary with metadata
3:55 about the package that you are looking at,
3:58 and this is often very useful if you want to find the homepage
4:01 for a specific project or if you want to identify its author
4:04 or if you are interested in the license that the code is under.
4:10 Then, also, you can see the categories the code is filed under,
4:14 or the library it was filed under, and then also what other dependencies
4:17 or secondary dependencies that library requires.
4:21 To me, the most useful information is usually these top 3 items here,
4:24 I want to know about the library author,
4:27 I usually take a look at the library home page
4:31 and then I also want to know what license the software is under.
4:34 And of course, you could also click through these categories here
4:37 and maybe find some interesting packages that way.
4:40 Okay, that's it for PyPi.
4:44 You can also search for packages from the command line,
4:47 using the pip search command.
4:49 Usually I would recommend that you stick with the PyPi website though.
4:53 The pip command doesn't really give you very much information
4:56 about those search results so it's just the package name
4:59 and then a very brief description, which can be useful
5:02 but as you've seen in the PyPi demo, oftentimes,
5:05 a single keyword can lead to many search results
5:08 so it's a little bit hard to untangle that from the command line
5:12 if you only have limited information available.
5:15 Nevertheless, that feature exists and it can be useful in a pinch.