Managing Your Dependents3:38 with Ken Alger
Once your code starts using code from other projects, it's time to start managing your dependents. Sometimes it can be a challenge.
[MUSIC] 0:00 Hi, I'm Ken. 0:08 In this workshop we're going to examine a relatively new, 0:10 highly recommended tool in the Python world, Pipend. 0:13 We all began our journey to become Pythonistas with writing our own code. 0:18 We might even get to the point that we're relatively comfortable in doing so. 0:23 Eventually, when your program gets bigger, 0:27 you'll want to start depending on code from other developers. 0:29 This provides a lot of time savings by leveraging code or 0:34 packages that others have written. 0:37 In Python, there are lots of packages that other people have written 0:40 that we can include in our own project. 0:44 You know, all the import requests and from pretty table import pretty 0:47 table type statements you've seen at the top of Python files. 0:52 These packages, when leveraged in another project are called dependencies. 0:56 Your project depends on the functionality of another bit of code. 1:01 This is great as it lets you concentrate on your own code. 1:05 And not on a problem somebody else has already solved. 1:09 How many people actually want to solve date and time conversions? 1:12 Or how to get authentication with a social media site to work? 1:16 There are packages available for 1:20 that which our projects can leverage or depend on. 1:21 If this sounds familiar to you, you've probably heard of, and maybe even used, 1:26 PIP, to manage your project dependencies, historically in Python. 1:30 The process of handling third party packages has worked pretty well, but 1:35 there have been some issues. 1:39 See the teacher's notes for an example. 1:41 One common issue is that package A might depend on a different version of 1:43 a sub-package than package B in the same project, causing dependency conflicts. 1:48 Unfortunately, sometimes you can end up almost spending more time resolving 1:54 dependance conflicts than on the actual project itself. 1:58 Even worse, these dependencies and sub-dependencies 2:02 can bleed between projects as well, leading to further headaches. 2:05 One solution to stop this dependency intermingling is a virtual environment. 2:09 Virtualenv is a popular tool that lets us have separate worlds of 2:14 Python packages for separate projects. 2:19 The common way of installing these packages is with a tool known as Pip. 2:22 Python Installs Packages. 2:27 Normally when you install something with Pip, it gets installed to a global 2:29 repository of libraries, usually called site packages. 2:33 But what if you create one project with Django 1.8 and 2:37 your next project is with Django 1.9? 2:40 You'd have to make sure that your 1.8 project 2:43 still works with 1.9 once you have upgraded. 2:46 Or for the best of all worlds, you could use Virtualenv for 2:49 each project, and just install whatever that project needs. 2:54 Virtaulenv keeps things out of the global repository, and 2:58 in a project's own repository of packages. 3:01 This is where Pipenv comes in. 3:05 Package management is common in many programming languages. 3:07 You might of heard of similar dependency management tools like npm, 3:11 Bundler, Yarn, Gradle or others. 3:15 Pipenv aims to bring the best of all these and Pip together in one place, 3:18 with the additional features of virtual environments as well. 3:24 It is meant to be an easy method to set up a working environment. 3:29 Let's see it in action and discuss some of the features of this work flow assistant. 3:33
You need to sign up for Treehouse in order to download course files.Sign up