back to indexStreamlit for ML #5.3 - Publishing Components to Pip
Chapters
0:0 Intro
1:9 PyPI
2:41 Preparing for Distribution
5:43 Build React Component
6:39 Create Python Package
11:57 Pip Install
13:58 Ending
00:00:00.000 |
Today we're going to look at how we can actually publish the component that we've been building for a streamlet 00:00:06.520 |
So what that means is we can actually pip install the component and then use it 00:00:22.320 |
Framework so we pip install it and then we just 00:00:30.000 |
This is a article been putting together and that kind of covers this so we're basically just going to be going through 00:00:39.000 |
And what you're going to see at the end is we can actually do this. So you see here we have this 00:00:44.200 |
From st card component import card component and then we just do card component titles the title body link 00:00:59.680 |
There's not that much to go through. It's pretty straightforward. I think so 00:01:11.020 |
Background on how PIP is actually working here 00:01:15.320 |
when you PIP install something you're actually installing it from this here the 00:01:21.680 |
Python package index. Okay, so put all piping. Yeah, I think that's how you pronounce it and 00:01:28.120 |
Like I can go in here and I can search for like pandas 00:01:33.700 |
And it's gonna show us pandas or it's gonna show us a lot of different pandas, I think it's this one 00:01:40.660 |
Okay. Yeah pip install pandas at the top there now 00:01:56.560 |
So I think it's this one. Yeah, it's like version 00:02:03.120 |
So this is the current component look there's me 00:02:10.560 |
install that but that's it's slightly different to the component that we have been putting together and 00:02:21.080 |
Built it for a particular use case, which you'll probably see pretty soon 00:02:28.880 |
St. Card component to or something. I don't know you have to give it a unique name. So we can't use the same name again 00:02:54.520 |
Build distribution for the react component or reacts part of our component 00:03:02.800 |
Come into I think here and we'll do that at the moment. There's no build 00:03:12.040 |
We need to open a terminal window for that. So I'm just pulling one up now 00:03:16.920 |
Okay, and I'll just navigate to this directory so documents 00:03:42.360 |
And then in there we want to go st card component 00:03:46.520 |
We might need to we might need to change the name of this by the way, I'm not sure 00:03:54.920 |
Okay, so from within here we need to use note package manager to create the build distribution 00:04:11.920 |
That is something we also need to do so let's not forget that 00:04:25.640 |
Up here. We need to make sure we set release to true 00:04:33.000 |
Release is false whilst we're putting everything together 00:04:35.640 |
But as soon as we want to actually distribute it or publish it. We need to say it's true. So 00:04:45.200 |
Run, okay, so it was saying you need to load st card component from localhost 00:04:53.560 |
3001 obviously when people using this component in the future, they're not going to be running the component on the localhost 00:05:02.800 |
Instead what they are going to do is they're going to download our package 00:05:07.760 |
which is going to contain this front-end build distribution the directory and 00:05:11.520 |
From there, they'll they'll get the the component it will be built from there. Okay 00:05:20.980 |
So, I think I don't know. Is there anything else? Oh and also this this will not be run anymore 00:05:28.360 |
So this is like the demo app that we're putting together before that will no longer be run 00:05:35.800 |
Yeah, that's fine. We just need to change that nothing else needs to be changed 00:05:40.520 |
Then we're now our front-end directory we just write this npm run build 00:05:53.040 |
Let me open this so we can see what's going on here 00:06:03.820 |
We'll see build directory up here in the front end on the left 00:06:14.520 |
Okay, so the build folder is ready to be deployed and we can come over here and we see we have build and it has 00:06:34.320 |
We have the build distribution for the actual react component 00:06:38.520 |
And now we need to create the distribution for the Python distribution. Okay, so 00:06:50.800 |
So this is one thing. I think we need might need to change so changing the name parameter and set up the pie 00:06:57.080 |
Because at the moment it's see card component. I 00:07:04.280 |
Yeah, I think I'm going to need to change this 00:07:18.120 |
Okay, so we have in it pie here we're going to go to set up the pie 00:07:27.640 |
Component and I think we'll also need to change this template name 00:07:43.640 |
Now we should be able to go ahead and create the component or create the 00:07:53.760 |
Set up pie we need to write s dist and be dist wheel like that 00:08:02.720 |
Okay, we run now and we should find a so we need to go one more 00:08:30.120 |
It's those two that we're going to upload to the Python package index and 00:08:38.160 |
To do that. We're going to need something called twines 00:08:43.520 |
We first install out pip install twine. I already have a download. So when I run it again and 00:08:57.120 |
Then we need to specify that we're going to upload it to 00:08:59.760 |
The Python package index and the only other I think option you have here is a test Python package index 00:09:08.160 |
Which can be quite I would recommend you look into that and like if you're putting a package out there 00:09:13.880 |
That's quite good to test that the package is going to work 00:09:25.880 |
I'll put a link to that in the description so you can take a look if you're interested in figuring this out a bit more 00:09:36.480 |
Python package index rather than the test Python package index and 00:09:40.400 |
We want to specify that we're going to be pulling everything from the distribution 00:09:48.800 |
Let's run that it will ask us to log in so my user name 00:09:56.720 |
Well, this is another thing so you will need to sign up on the same website I mentioned before it's I think 00:10:07.360 |
So you need to sign up, and then you can go ahead and do this 00:10:13.240 |
File already is this okay, so this is because I already have 00:10:20.320 |
You see here is using st. Card component, so I need to make this 00:10:26.080 |
St. Card component - so we'll go through everything in here, so this actually I didn't need to 00:10:36.960 |
Let's rename all this to - it's also in in it PI 00:10:43.020 |
This one don't really need to change, but we'll do anyway 00:10:47.920 |
- anything else in there, I don't think so so delete this 00:11:00.760 |
I'll delete the distribution folder and the build folder. I don't know okay delete that as well 00:11:07.200 |
And then in here we need to change this because the directories change 00:11:26.840 |
So we come to this Python. Yeah run that credit distribution folder and 00:11:34.400 |
Then we're going to use twine again, so hopefully this time it'll work 00:11:41.360 |
Okay, so now we have st. Card component number two we can go ahead and actually 00:11:58.040 |
Okay, so we can pip install, and this is a version number. We don't actually need that so let me 00:12:05.080 |
Okay here, we just pip install st. Card component number two. Let's copy that across 00:12:13.000 |
I'm going to do that in my stream lit environment 00:12:22.720 |
Now while that's downloading. I'm going to come over here. I'm going to open or create a new directory actually so 00:12:51.760 |
I'll open that in vs. Code. Okay, and then in here. I'm just going to create a new file app pie 00:13:02.160 |
Let let me copy it across from from the article 00:13:25.280 |
Okay, save that and now let's run it from here 00:13:39.400 |
Up top pie okay localhost and here we go, so this is our 00:13:52.640 |
Click here make sure it's working. Oh, yeah perfect 00:13:59.120 |
Yeah, that's does everything for this kind of short series on 00:14:11.680 |
Yeah, that's it. Thank you very much for watching now. See you in the next one