Modern Python Projects Transcripts
Chapter: Let's build a package
Lecture: Install package from

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that we have that we're going to, install our package. But instead of using pip, we are going to install it from the setup. py.
0:09 File. If you go to the make file, you can see that there is this insatll command that will run Python, install.
0:18 If you use it through the make file, it will also run the clean command first, which is pretty nice because it will clean all the cache files or tox,
0:26 coverage and stuff like that. But just for now, in case you don't want to use the make file, let's run Python setup install manually.
0:39 Nope, I'm not in a virtual environment, so let's first activate. That's why poetry is actually useful cause it activates the virtual
0:47 environment automatically. Now we can go as you can see the output is slightly different
0:56 If we do pip freeze, you can see that apart from all the dependencies, we also have our uptimer installed. So now we could, for example,
1:06 open the Python REPL and imports some modules from the CLI or helpers files,
1:11 and they would be imported from the module that we installed not from the source files
1:15 So we want to run our tool by simply calling uptimer and the name of the website. And to get that behavior,
1:27 you have to create an entry point in the So if we go here to and you scroll down under the
1:36 setup, there should be a parameter called entry points. And here we have console scripts and here we define that the uptimer command will
1:45 call main function from the CLI file inside the uptimer package. All that was automatically generated for us from the cookie cutter template.
1:54 But if you're not using cookie cutter, you just have to write all that by yourself. So this should actually work and it does pretty cool.
2:08 So when we published our package to pypi, I and someone install it. They should be ableto call uptimer and the name
2:15 of the website and everything will work. But before we publish it, let's also add test documentation and make sure that everything is nicely polished.

Talk Python's Mastodon Michael Kennedy's Mastodon