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,
0:02 install our package. But instead of using pip,
0:05 we are going to install it from the setup. py.
0:08 File. If you go to the make file,
0:10 you can see that there is this insatll command that will run python,
0:14 install.
0:17 If you use it through the make file,
0:18 it will also run the clean command first,
0:20 which is pretty nice because it will clean all the cache files or tox,
0:25 coverage and stuff like that. But just for now,
0:29 in case you don't want to use the make file,
0:31 let's run python setup install manually.
0:38 Nope, I'm not in a virtual environment,
0:41 so let's first activate. That's why poetry is actually useful cause it activates the virtual
0:46 environment automatically. Now we can go as you can see the output is slightly different
0:55 If we do pip freeze, you can see that apart from all the dependencies,
1:01 we also have our uptimer installed.
1:03 So now we could, for example,
1:05 open the python REPL and imports
1:06 some modules from the CLI or helpers files,
1:10 and they would be imported from the module that we installed not from the source files
1:14 So we want to run our tool by simply calling uptimer and the name
1:24 of the website. And to get that behavior,
1:26 you have to create an entry point in the
1:30 So if we go here to and you scroll down under the
1:35 setup, there should be a parameter called entry points.
1:39 And here we have console scripts and here we define that the uptimer command will
1:44 call main function from the CLI file inside the uptimer package.
1:49 All that was automatically generated for us from the cookie cutter template.
1:53 But if you're not using cookie cutter,
1:55 you just have to write all that by yourself.
1:58 So this should actually work and it does pretty cool.
2:07 So when we published our package to pypi,
2:09 I and someone install it. They should be ableto call uptimer and the name
2:14 of the website and everything will work.
2:16 But before we publish it, let's also add test documentation and make sure that everything is nicely polished.