Closed simonw closed 2 years ago
[youtube] 0SPqMR08VWU: Downloading webpage
[youtube] 0SPqMR08VWU: Downloading android player API JSON
[youtube] 0SPqMR08VWU: Downloading MPD manifest
[youtube] 0SPqMR08VWU: Downloading MPD manifest
[info] 0SPqMR08VWU: Downloading subtitles: en
[info] 0SPqMR08VWU: Downloading 1 format(s): 248+251
[info] Writing video subtitles to: How to build, test and publish an open source Python library (without sign language) [0SPqMR08VWU].en.ttml
[download] Destination: How to build, test and publish an open source Python library (without sign language) [0SPqMR08VWU].en.ttml
[download] 1.00KiB at Unknown B/s (00:00)
[download] 3.00KiB at Unknown B/s (00:00)
[download] 7.00KiB at Unknown B/s (00:00)
[download] 15.00KiB at 13.51MiB/s (00:00)
[download] 15.66KiB at 10.81MiB/s (00:00)
[download] 100% of 15.66KiB in 00:00 at 260.09KiB/s
hello hi gotham uh my name is simon and
how to build test and publish
um i'm actually going to publish a library while
which i've been copying and pasting into projects
thing that helps you create string based um
i'll do a quick demonstration of what that looks
and now if i do pid.fromint one two three four it
two three four so very simple piece of code let's
on the python package index so i'm going to create
available name right now and i'm going to add that
we'll stick it in that folder and we'll paste
package all you need for sure is a setup.pie
so i'm going to create that and then i'm going
simplest possible version of a valid setup.my file
it's a tiny python library in the description
that pid stop by file i just created so now in
now if i run python3 setup.pi sdist this is where
file called pids hyphen 0.1.gz and that is a
to install this package i can actually demonstrate
pop that open and we'll do pip install what's
when that prices it installs it and now if i
code that i can start to run so let's upload this
with a tool called twine i can say twine upload
i've just created when i do this it'll ask me to
you'll need to create an account on pi pi before
and it gives me a url and this is live on the
anyone in the world can install by running pip
author of this package has not provided
documentation so let's build that now as a simple
a tiny bit of documentation i wrote earlier i'm
and vs code can give us a little preview of it
exciting but it does explain what's going on
package the way we do that is by adding a tiny bit
go i'll copy and paste this in so we can add two
description and long description content type
i've written called get long description which
variable so we add this little bit of boilerplate
going to bump up the version number to 0.1.1 to
run python3 setup.pi sdist um oh it doesn't like
that we now have a file in dist called 0.1.1 and
and stick in those credentials one more time
this has given us our second base on pipe
got documentation the contents of that
so for our next step let's add some tests i'm
this i need to add pi test as a test dependency
the pids test dependencies are my test and now
environment i'll call it vien i'll do source via
to type pimp install dash e for editable of my
running this installs pi test now if i run pi test
so let's create a test folder and i'm going to
in stockpi and the great thing about pi test is
we could say test from int and it's
equals and mzq so i'll try running that test
is the correct value i can stick gxd in
the opposite direction so i'll test test to int i
and when those tests there one two three five
have a pasting passing test suite and this can
so the next step is to get this up on github
pids i'll use the default settings for that
just gives you the commands you need to run
i'm going to git add my readme my
and then i'll paste in these four lines here and
me but the really neat thing about github
to run your tests for you um the way you do that
so rather than create that um by hand i'm going
um my sqlite explain project i happen to know has
here so now if we look in here we now
um yaml and a test yaml this right here is the one
installs the package under four different versions
so i can now do the git add dot
get push and over here github will spot that
start running that test action for me straight
different jobs in github actions one for each of
and it's already started running those it's
versions all four different versions we look
it's called it's installed dependencies it's run
green ticks clicking in and just like that our
and our commit that even gets a little
so i have one last trick up my sleeve i'm going
without running anything on my computer at all
api token on pipi called pids i'm going to
to that pids project and that token and i will
for my github repository so i can do add secret
anytime i push a release to this github
and will publish that release so i'm going to
and i'm going to publish a new release um release
0.1.2 and let's just say added added tests will
action kicks into effect so this is my publish
first because you wouldn't want to publish a
and once the tests have passed it fires
upload script that i showed you earlier so this
and now it's publishing that package up to pipi
that was published entirely through automation
and i have published extensive notes on this at
https://www.youtube.com/watch?v=0SPqMR08VWU