Effective PyCharm Transcripts
Chapter: Packages
Lecture: Concept: Packaging

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We want to work with an existing package in PyCharm. We just opened up the package directory.
0:07 Probably the one that contains the setup py is the top level is the best way
0:11 to go and when we do PyCharm automatically detect things we need to do to get the package set up and ready to go.
0:17 For example, it will say look there's all these dependencies. You're going to need to install these into your virtual environment that you've created.
0:23 You used a virtual environment. Right? So it's going to just give us a button click to get this set up and
0:28 then we'll have at least most of the dependencies installed. We'll also be able to say things like 'from.exceptions'.
0:35 The dot relative import works really well in packages. One of the things you often need to do is install the package locally in development
0:44 mode so you can go over your tools, click run setup py task pops up a dialog in here,
0:49 you can type all sorts of things we did to we start out by saying developed to set up the package to work on and then later when we were ready to
0:58 ship it, we said 'bdist wheel' and that actually created a distribution version of wheel that we could upload with twine to 'pypi.org'.
1:07 Miracle that was working with an existing package. What if we want to create 'zapify'
1:12 an amazing package that will zap the bugs using abstract syntax trees somehow magically Well we're going to create that package.
1:20 So what we can do is we can create a new Python project that's empty with a virtual environment so called it Zapify.
1:26 and have an empty Venv here when I talked about it, I did this on the terminal or the command prompt.
1:33 I went over and I actually created the structure for us just because I was talking
1:38 about what constitutes a package. There's actually an option new Python package here in
1:43 PyCharm It doesn't do a lot for you If I want to create a Python package called zapify it will create a directory called zapify.
1:49 and put a Dunder 'init.py' in it. That's empty. That's all we did over on the finder and command prompt.
1:57 Once we have that though, we need a setup_py to do real package things Of course we can work with the package locally long as the pass the ride.
2:04 But we can't share it. We can't upload it up to PyPI we can have someone else download init and install it into their virtual environment for that.
2:12 We're going to need a setup py file and there's a couple of things you always have to specify. Luckily PyCharm has a nice little dialogue for that.
2:19 So what we can do is if we select the top level of the project and you do not already have a setup.py
2:25 You go to tools and you'll have this option there click that It gives you this dialogue to fill out all the pieces.
2:30 Like what's your author email? What's the description which the version, what's the author kind of odd.
2:35 The author and emailer visually separated but you know it doesn't matter. You fill this dialogue out and then boom it creates this setup. py.
2:45 Use even set up tools so it sets the name the version the packages. If you have sub packages when you do this,
2:50 we didn't have any when I click the button but if you did it usually automatically detects them for you which is fantastic.
2:57 So it fills this out and then we can do all the nice setup operations like create the distribution, the wheel for distribution and so on.
3:05 Really cool way to get up and running quickly with PyCharm and new packages.


Talk Python's Mastodon Michael Kennedy's Mastodon