How to Make a Python Package / Upload to PyPi

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello I just wanted to take a few minutes to walk through the steps to creating your own python package from scratch because I had to do it recently for the PK vid package so there's a blog post with most of the steps and we're going to walk through the actual steps in this video as mentioned it's for the PK vid package which I intend to be something to help with automatic video editing relates to some of the blender tutorials I've done recently I want to get that into a ppie package that people can install with Pip and use easily so that's the motivation here we're going to upload to piie but really you should use test. p.org instead of p.org just so that you're not uploading garbage packages so here I have this PK vid package that I uploaded um I'm going to walk through the steps in the article and we will get to this point um on video as well so this whole process is really pretty straightforward um I did the simplest possible P project Tomo file that we could have to Define this package we say that setup tools are our build backend I'm not really sure which other ones are available I always use setup tools and then we're going to use poetry for our package management instead of setup.py and we just have to give it a name a version a description and authors so once you have that uh you can actually do a poetry install and it'll install the package now if you don't have any source code at all it's probably going to yell at you with an error so you have to create the PK vid directory which matches your package name and then inside of it you can put in a knit. piy it doesn't have to have anything in it but then you can poetry install if you don't have poetry installed you can pip install poetry and that will grab poetry for you but uh once you do have poetry installed you can just run that command and uh it will generate poetry. loock and you'll be good to go once that's done you can run poetry build and that goes into the disc folder and generates this wheel file and the tgz file the tgz file is the source code I'm pretty sure and the wheel file is what we're going to upload to piie and that's what other people will download and install on their systems so that's pretty straightforward now that we have the wheel file sitting right here all we have to do is upload it using twine now this is where we have to go into p.org and mess around a little bit so let's go do that so I'm going to go ahead and delete the sample package that I created when I was writing the article and now what you have to do on your first time is you have to go create an account uh once you have an account set up whatever it makes you set up maybe two Factor authentication all that stuff then you can go to your account settings and go down to API tokens hit add API token and uh we'll just give it a a name and you can actually scope it to a project if you only want to use it for that project probably best to do that or if you're creating a new project you might not have that option so you can hit create token it gives you a token I'm going to delete this token once we're done with this video for security purposes but you literally just copy this guy and then we're going to go back to VSS code if you don't have twine installed yet just go ahead and install it and then we can do twine upload the path to the wheel so that's going to be that guy and then you can specify repository URL test.py py. org Legacy you hit enter username is going to beore token password I'm just going to hit paste to paste the token from the browser it yelled at me because I missed the trailing slash if we do it again it says we've already used the file name so if I bump the version and do a poetry build and then we upload 011 now we should actually be good let's see there we go finally it succeeded we can click and there's our package it's on piie test pii rather now these steps should be exactly the same for the real p.org so once you have it working as you can see already in the creation of this article I've uploaded two garbage versions of this package so you can do that as many times as you need to on the test site and you don't have to worry about dirtying up your namespace on the main website so if you make it this far I would say go ahead and try to get it on p.org you should be good to go so that's all the steps for this uh hopefully this was helpful for you and uh yeah thanks for watching see you
Info
Channel: PageKey
Views: 253
Rating: undefined out of 5
Keywords: pagekey, pagekey solutions, solutions, page, key, page key, education, learning, programming, software development, software engineering, python, rust, kubernetes, cloud
Id: Um_rPmaGTT4
Channel Id: undefined
Length: 4min 24sec (264 seconds)
Published: Thu Dec 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.