Mastering PyCharm Transcripts
Chapter: Packages
Lecture: Concepts: Packaging

Login or purchase this course to watch this video and the rest of the course contents.
0:01 Let's review some of the concepts that you saw
0:04 while we were working with packages in our demo.
0:07 So we saw that we can load existing packages
0:10 here we're using requests.cookies
0:13 and it's easy for us to just open up requests
0:17 PyCharm knows that this is a package,
0:19 it knows that when it imports stuff it has to say requests. for the various things
0:23 so it's really good at working with packages
0:26 that maybe you got off of GitHub or wherever.
0:30 So this is nice, one of the things we need to do
0:33 actually to be able to leverage that package,
0:36 to run it and import it into say our program for getting some kind of package,
0:41 trying to use it and see how it works, and making changes
0:45 maybe eventually with the goal of doing a PR
0:47 back to the original package owner or something like that
0:49 is you have to install it, or more importantly set it up in development mode
0:53 so you can do that by just going to tools run setup task
0:57 down here you get all of the options
0:59 if you type develop then it'll go and install all the dependencies
1:04 and register requests locally, so that at least that virtual environment
1:10 knows to go back in local right here to run this local copy of Requests.
1:14 Now on the other hand, we might want to create a new package from scratch
1:19 not work with someone else's,
1:21 so we can come down here and say new python package
1:24 and this honestly doesn't do very much for you
1:26 it creates a directory with a __init__
1:28 so this works for packages or subpackages
1:31 you could just create a directory
1:33 and put a Python file name __init__ in there if you want
1:35 but this I guess saves you a step,
1:38 and it sort of follows the convention a little bit more closely.
1:40 So these packages are not particularly useful
1:43 if you can't install them to use them elsewhere
1:45 so we can go and create a setup.py
1:47 and you can just go to tools create setup.py
1:51 this doesn't work if you already have a setup.py anywhere in your project
1:54 so just be aware of that.
1:56 Look at this dialogue, it asks you all the pertinent questions
1:59 what is the name, what's the version, what's the license and so on and so on,
2:02 I hit OK and then boom— out pops a setup method ready to go and a setup.py.
2:10 Now traditionally PyCharm has used distutils.core
2:14 to get setup and just recently they switch to the setup tools version
2:19 and that's important because the older versions don't have the develop option
2:23 so python setup.py develop, that didn't use to work,
2:27 just by pressing the button as long as you're using 2017.3 or above though
2:32 it looks like everything is golden.
2:35 If for some reason you don't have that,
2:37 you can just alter the import statement at the top
2:40 and then you are ready to roll, your new package is ready to be set up
2:44 and used or tested or whatever you want to do with it.