Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds.
This is episode 338, recorded May 30th, 2023.
I'm Michael Kennedy.
And I am Brian Okken.
And this episode is brought to you by us, our courses and books and things like that.
Talk to you more about that later.
Also, connect with us on Mastodon or all over on Fauceton,
at mkennedy, at Brian Okken, and at Python Bytes.
And we love it when people join the live show.
If you want to be part of that, you can see the next scheduled upcoming one at pythonbytes.fm/live
and click that notify me and YouTube.
And guess what?
It'll notify you when it's live.
So that's the front matter, Brian.
I think we should start it off with some basics.
What do you think?
Yeah, let's go back to the basics.
Basics of Python packaging.
So actually, this is something near and dear to what I've been paying a lot of attention to lately is packaging.
And just how it's changed.
And it's kind of in the most people have switched over to pyproject.toml now.
And that's really what this is about.
So when you're packaging, especially a pure Python package.
Well, one of the things I like about this is it's not just for pure Python.
But that's the easy part.
If we're using pure Python packaging, you're probably using a pyproject.toml now.
And there has been several write-ups of it.
But some of them are kind of tool-centric.
So I like about this write-up from JQui.
Or JQui?
Not sure.
That talks about just sort of the easy, a fairly standard setup.
So it does talk about the peps in this article.
But you don't really need to know much about that.
You can just kind of skip to how do I do it.
So using the peps and using pyproject.toml, you do have to specify what your build backend is.
So in the top example of this article, it talks about using a flit core.
And that's one I've used a lot of that.
But then what else do you put in there?
So within the rest of the pyproject.toml is mostly metadata.
You can have other stuff, too, like black and everything.
But for your project building, the project metadata, there's not a lot that goes in it.
I mean, it looks like a lot when you just glance.
But it's really, you know, it's your name for the name of the project, the version, description of it.
Your author, I will point out that this is not minimal because it includes the email.
You don't have to include the email.
If you don't want to, you can just put the name.
And where your license and readme and classifiers are.
One of the things I want to highlight is make sure you have the license.
At the very least, have your license classifier listed because that's how the license shows up on the PyPI.
So when PyPI is looking at projects, it looks at the classifier.
And then try to throw in which Python is required and then any of your dependencies that you're using.
And then some links.
I mean, it's really, when you just talk about it as a stream of conscious, it seems like a lot, but it's really not that much.
And you're pretty much done.
You can do a build now with this.
This is-
I think, Brian, before you move on from that, that I just noticed that I really like.
If you do a setup.py, what you've got to put is the readme and details and the descriptions and all those kinds of things, at least a long description.
You've got to actually load the file and inject the content to the file.
And here you just put the file names for the license and for the readme, and it'll just pull those in, right?
That's cool.
It is one of the things I've harassed people about before is it's weird that the readme and license are specified completely different.
So the license has this, like, what, curly braces and then file equals license.
Dictionary-ish.
Yeah, it's a dictionary.
Whereas the readme is just a text string with the name of the readme.
It's odd.
I think that maybe we could have it so the license could just be a string with the license file on it also.
But anyway, there's probably reasons, I'm sure.
The thing that I also want to point out is you can put as many URLs as you want in here.
You can have, like, this example as homepage and bug tracker.
A lot of people just list home that lists the GitHub link.
But you can have your documentation and other stuff.
And all these show up in PyPI also if you're published to PyPI.
And if you don't want to publish to PyPI, one extra is to, that Kim reminds us of, is another classifier I learned about, is private do not upload, which tells PyPI to not upload it.
So this is all great.
And a lot of this also, if you want to watch it in video form, is covered in the sharing is carrying video.
It's a talk I gave in PyCascades.
The video is now online.
We'll put a link in the show notes.
But this document or this article goes through some of the different, make sure that you understand the build step of Python-M build is one way to do it.
There's other ways.
But then it talks about some of the discussion around why pyproduct.toml is there instead of setup.py.
I think we're all convinced, hopefully.
But then also some choices of backends.
So this article used Flit Core to start with.
But there's also Hatchling and setup tools and Poetry Core.
So why would you choose different ones?
And one of the, and it's because there's extra features.
Some of them allow extra tags to go in there.
And the example they're using, and that's one of the reasons why I use Hatch a lot, is you can have include and exclude things to say, you know, the normal stuff that you'd probably include in a source distribution.
Also add the tests, for instance, or something else.
The test is one that, like, distributors, redistributors, like Linux distros, like to have your tests in the source distribution.
So throwing those in there is a good idea.
I'm not sure why they're in there by default.
But anyway, it's a cool discussion.
One of the things I also love is it talks about what happens if you're not just Python.
What if you have to include C?
Well, it doesn't really discuss it too much.
It just points you in the right direction.
So if you have C or C++ extension, there's a Psykit build core that you can use.
I haven't tried any of these.
If you're into Mason, you can use Mason Python.
And then also setup tool supports it.
So there's a direction for that sort of stuff.
Yeah.
Straightforward.
Back to the basics.
I like it.
Yeah.
Definitely demystify some of that.
Henry points out in the audience, the license key will likely change via PEP 649.
And currently, Flit just ignores whatever you put there.
The Trove classifiers are the canonical location for the license.
So just FYI.
Thanks for that, Henry.
He always has such excellent extra information, background information.
And we're so lucky to have some smart people show up on the chat.
So thank you.
Yes, absolutely.
All right.
Let's talk vectors.
So I want to talk about VEX.
And this project comes to us from Olly, who open sourced this, Olly Rice.
Now, before I actually tell you about what VEX is and what it does, let's take a step back
and talk about the PG vector extension for Postgres, the database.
So this is an open source because VEX has to like build on top of this.
So this is an open source vector similarity search extension for Postgres.
So you can do things like given a bunch of points in different dimensions.
This could be XY, could be XYZ, could be, you know, temperature and time.
I don't know.
Right.
It could be whatever you come up with.
It'll give you the exact and approximate nearest neighbors, allow you to query that, like
given some measurement, what other measurement is closest or give me the five measurements
or positions that are closest to this.
Gives you L2 distance.
It'll do the inner product and cosine distance.
So different metrics, if that makes sense.
And any language with a Postgres client can speak to it.
It's pretty cool, right?
Yeah.
So let me see if I can find some examples.
So I can say, get me the nearest neighbor by L2 distance.
And it says the way you would do that directly is you say, select star from items, order by embedding, whatever the value is, is closest to, in this case, the vector value 3, 1, 2.
And then limit 5, just like you do in databases.
You know, give me the first 5.
So order by closest to farthest.
And then just give me 5.
That'll give you the 5 nearest, right?
You could do things like sort by distance.
You can find exact matches.
And you can also do other database things.
Let's see.
Like, give me where the ID is or is not equal to some value, and so on.
All right.
So pretty neat.
Now, that's the pg vector extension just for Postgres.
So you're speaking to it in a special flavor of SQL, sort of.
In Python, you can talk to this using this thing called VEX, okay?
So with VEX, you just pip install it, and then you insert a bunch of vectors, and then you can write queries that are more API-based, I guess, not just direct SQL statements.
So you give it the vector that you want to query against, and then, you know, like how many you want back.
If there's a filter to say, I only want the ones for a certain year, right, filter it down, and then do that query based on distance or whatever.
So pretty cool.
If people are out there doing that kind of work, I think they might find this pretty helpful.
Yeah.
Very.
Oops.
It's not something that I have exact direct use for these days, but, you know, a lot of scientific or geospatial type of things seems relevant.
Yeah.
I've been spending more and more time in SQL queries lately, so anything to help with that is good.
Yeah, absolutely.
Now, one final thing.
It says in here, it says you've got to have, I can't remember which one, talked about getting Postgres.
One of them, yeah, this one says, if you don't have a Postgres database, see some hosting options.
And if you're on Mac, I just want to throw out there really quick, postgresapp.com.
All you do for this one is, it's super awesome, you download it, you unzip it or un-DMG, whatever its packaging format is, and it's just a postgres.app.
You double-click it, Postgres is running.
You close it, Postgres is not running.
It auto-updates itself.
Yeah.
So pretty sweet.
And it's open source, too.
Cool.
Neat.
Yeah.
Yeah, very neat.
I'll be needing that very soon.
Yeah.
So.
Yeah, cool.
Check it out.
Yeah, that one's, that's pretty nice.
Okay.
Now, before we move on, Brian, brought to you by us, this episode is.
So I wanted to remind people to, you know, please check out the brand new Talk Python training apps.
They're rebuilt for iOS and Android.
I really think it's a cool experience for people to take it.
It has offline playback and obviously way better on the mobile and tablet type of things.
And it comes with six free courses that you can just tap on and join the free courses plus anything you might have gotten.
So check that out.
And I want to shout out your book or what do you want to shout out today?
Yeah.
Well, there's, there's, time is running out, but the, yeah, let's, the book is still on a promo.
So Python testing with pytest, there is, what is the promo?
It is spring 2023.
All caps, all one word.
And you get 50% off.
And it's just for like today and tomorrow.
I think it runs out at the end of May.
But anytime you want it, there is a 25, that's 50% off.
But if you want to sign up and get to their email list, you can get 50%, 25% off normally.
So anyway, that's a good thing.
Excellent.
Also really quick follow up.
Henry points out that it was actually PEP 639, not 649.
Not a typo there.
Yeah.
So 639 is improved license clarity with better package metadata.
It's in draft, but hopefully there'll be, it's in draft really?
Anyway, some changes to how you specify the license, which would be good.
All right.
Let's talk about plagues next.
Plagues?
Like, you know, locusts and grasshoppers?
Yes, exactly.
Nice.
No, I like these kind of plagues.
These are awesome tools.
So I've used locusts before.
I think you've used locusts for-
I love locusts.
Yeah.
For load testing.
So good.
So there's a company, AlterX, maybe?
Anyway, they've introduced grasshoppers.
So it's a locust grasshopper.
It's an open source Python library for load testing, but it's built on locusts.
So what's the difference?
So we're linking to an article that discusses the introduction and discusses why they love locusts and everything, which is great.
But they have a check, like grasshopper, what does it add?
Well, it adds a whole bunch of really cool features that you might need if you're load testing and developing a package and keeping track of your load testing over time.
So it has these extra checks in here.
And checks, if I get this right, are things like special validation functions, Boolean functions that can run.
And you can tell different checks whether or not they're passing or failing over time, which is based on your-
I see.
The document had this text in it to make sure it wasn't insane in the response or something.
Yeah, actually, I'm not quite sure.
So I'd have to dig into that more.
But one of the things I really like is these custom trends, which custom trends and timing thresholds and integration with pytest.
Of course, that's awesome.
Time series database integration and reporting.
This all sounds great.
One of the things I really love that's talked about in the readme a little bit more is this idea of, like, tagging your test suite.
So tag-based suites.
So you can see your load test results based on different versions.
So if you're tagging with using version tagging on your repo, you can see what the progression is and how well your application is doing based on different load requirements.
And you can have thresholds.
Like, with this load, you need to have, like, 90% of the speeds of things.
The other thing is some speed thresholds.
Like, you can have multiple timing little functions that have multiple time, multiple HTTP requests.
So an action that really is like a user action often is several interactions.
Like, how fast can somebody log in or something like that?
Or go through the checkout.
That's going to be a multiple sequence thing.
You can time that under load and under stress.
And that's a pretty cool addition.
Or even to load this page, we're going to, it's probably some complicated JavaScript front end.
So it's going to call this API and that API and that API just to load this HTML page.
Yeah, sure.
So you kind of want to treat that as, like, the page is loaded when these seven API calls finish, right?
Something like that.
Yeah.
Because they're not using HTTPX like they should or HTMX like they should.
Also, a nice shout out to a sponsor there, InfluxDB.
So pythonbyes.fm slash InfluxDB.
This is the time series database that it integrates into.
When I looked at this, Brian, I'm like, yeah, but Locus is pretty awesome.
Why would somebody go create another one of these for the Python world when Locus exists?
And then I read it.
It's like, oh, we've extended Locus.
Oh, and here's why.
And they give some pretty good reasons.
Another trend that would be cool.
I don't know if you can actually measure it here, but it talks about custom trends is one of the things you can track.
Things like CPU load and memory load on the server would be really interesting.
Or, you know, maybe CPU load on the database server while we're hammering the web server.
If you could pull those kinds of things in, that would be really cool.
Yeah, maybe you can.
Yeah, maybe.
I kind of get the sense that it might be possible, but let's see.
Not sure.
But very cool.
Yeah, this looks nice.
It's definitely worth checking out.
Some of the check functions, you might be able to, like, abuse that for that purposes, too.
While your load tester is running, check CPU levels and stuff like that.
I don't know.
Yeah, exactly.
So anyway, neat project.
Yeah, that's a good project.
So Grasshopper, right?
Yeah.
Oh, one of the things that they talk about in the...
I wasn't clear on it because I went and looked at PyPI and looked for Grasshopper, and I found the wrong one.
So it's locust-grasshopper.
So that's the GitHub repos under that, and that's what you pip install also is locust-grasshopper.
So just to be clear.
Got it.
I wonder if it's like a superset, probably.
Yeah.
So if I have already written a bunch of locust tests, could I run them, or how easy is it to...
I don't know, but I imagine it's not that bad to convert.
Yeah.
It looks like the code is super similar.
So worst case, you maybe change the base class, but possibly the base class is derived from the locust base class that you use for your test cases or test suites.
Yeah.
Anyway, I haven't played with it yet, but it looks cool.
The readme's got tons of information too.
Good job on loading up the readme with lots of examples.
Indeed.
And before we move on, Kim says, it could possibly hook into telemetry tooling like Prometheus, which would enable metrics from other servers and stuff like that.
Yeah, that's kind of what I was talking about, but not with actually concrete ways of doing it like Prometheus.
So cool.
Neat.
Yeah.
And I want to talk to you about something that is near and dear to this podcast.
We talk about a lot of topics, right, Brian?
Yeah.
And if you go over to Python Bytes and you pick a particular episode and you scroll through here, you can see it is chock full of links.
So one of the things you might want to do, you might want to say, oh, I'm listening to this.
I want to remember not all of them, but just three things that I can come back to.
And if you're on your iThing, your iPhone, iPad, et cetera, or even on your Mac, technically, if you've got an Apple Silicon Mac, you can use this thing called MemoCast.
So MemoCast was created by Daniel Engvall.
It's interesting on its own, but it's also interesting in a way to kind of script iOS with Python, which I hadn't really thought about doing.
So first of all, let me tell you about MemoCast and then you can think how this might apply to you.
So this is a small iOS app that allows you to add links heard about in a podcast as a reminder.
So you can check them off your reminder list, you know, the at reminder app when you're done with them.
So check this out.
Imagine this is reading the website.
Imagine you just as often as I do listen to a podcast such as Python Bytes, a fantastic one.
Thank you.
Using Google Podcasts, walk around, you know, you're doing it while you're out and maybe busy, like mowing the lawn or something.
Right.
And then there's some thing talked about you wish you had more time to check out.
Thankfully, the reference in the show notes, but you'd have to look it up and go through it and copy paste and all that.
So there's a little video here.
Notice this.
Nice.
On this page.
And it shows all you got to do is say share.
Go to the podcast player.
Say share.
Click MemoCast.
And it gives it a second.
Then it has a list of all the links that it's discovered in there.
Isn't that cool, Brian?
That is neat.
Yeah.
I can't really zoom that without the.
I can't really zoom it without the responsive design only making it smaller.
But so how is this possible?
The thing you share it to is you don't share it directly to MemoCast.
You say run in Pythonista.
And so this is a Python script that that Daniel wrote that basically you run it through Pythonista Python 10 on iOS.
It does a guessing request or something called over to our website and parses out all the links and then turns that into a UI that you can interact with.
Cool, right?
That's all done on the phone then?
Yeah.
That's pretty cool.
Yeah.
It's pretty cool.
And so basically this is an example supports Python by Stock, Python, I mean, real Python as the three supportive podcasts.
But you can integrate new ones if you wish.
And you install it once you have Pythonista, which I think costs $10 US one time.
But then you can install it scanning the QR code here with Pythonista and that will download it.
Then you can just turn it into a thing that you can run.
It also talks about how you add new podcasts if you want to add a different one.
But that's somewhat interesting.
I think what's more interesting is he took this Python code and the code is right here to build kind of a scriptable GUI for iOS, which I think is pretty cool.
Yeah, that is nice.
Cool.
So talked about like I did try to do this with Kivy and other stuff.
But let me tell you, the build chain and code signing and all of that is like a nightmare.
And so here you just write a Python script and just run it inside of this app that already exists.
And final bonus before I call all the time on this one.
Daniel also discovered that if you're on a Mac with a Apple Silicon, then you can run Pythonista as an iOS app within macOS.
So you go to the App Store, search for it on Mac and it doesn't come up.
So then you click, say, show me tablet, you know, iPad apps, and then it'll come up.
And then it integrates with your favorite IDE, such as PyCharm, and you can run it.
So you can develop these little things on your Mac with a proper keyboard and everything.
And then just deploy it to Pythonista on iOS.
Yeah, that's pretty cool.
So yeah, people can check that out, MemoCast.
It's kind of cool that it's about our podcast in this way, but it's also more cool that it just kind of shows you how to take Python and leverage Pythonista a little bit more than maybe I realized you could, like an OS integration level.
Yeah, I didn't know you could do that.
That's cool.
I did not either.
Nice.
And I guess before we jump out of here as well, Kim points out on Android, which I have some but not tons of experience with, you can run Python code with QPython should someone want to emulate this for Android.
Thanks, Kim.
Cool.
All right.
Is that all of our topics, Brian?
That is all of our main topics.
Yes.
Of course, we always have extras.
Yeah.
I'm a joke.
Any extras for you, though?
Yeah.
I can kick this off.
So just a few.
A shout out from, oh, who wrote this?
I'm not sure.
Hugo.
Hugo Van Kimenad.
Wrote, help test Python 3.12 beta.
So 3.12 is in beta.
If you are a package maintainer or just your own application, you may as well start testing to make sure that you don't have any surprises.
So this article does talk through basically how to hook up your GitHub actions so that you're testing 3.12 also.
And then whether it's the official Ubuntu latest or the Dead Snakes version, a couple ways to do it.
And then even if you're using Travis CI still, bye.
Anyway, you can do that with that as well.
So that's the first.
Secondly, I wanted to say that at the Python Software Foundation blog, there is a whole bunch of new articles.
I basically wrote up, there's articles writing up all the different things that happened at the Python Language Summit.
I haven't gone through these.
They're just available.
Wanted to shout that out.
It's some interesting stuff, though.
There is.
I just interviewed Brett Cannon over on Talk Python about this.
He gave us the walkthrough of all the presentations and thoughts at the Language Summit.
Okay.
And then from the news from the weird, I don't have much information about this other than on the Python Package Index blog.
They say, hey, PyPI was subpoenaed.
And, you know, this thing happened.
And we complied and talked to lawyers.
And it's weird.
But, you know, it's just odd.
Yeah.
So how about you?
Any extras?
Yeah.
I wonder if this has to do with some of the malware, crypto jacking.
Maybe.
Stuff that was uploaded to it.
And they're like, all right, we're going to try to track down some of these people.
There are certain places that are not allowed to say whether they received a request.
And I think this is not a subpoena.
This is more of a, what is it, FASA?
Like the more international crime investigation laws.
So we'll have a subpoena canaries.
It'll be like the canary will be here unless we are subpoenaed.
Then the canary is gone.
We won't say anything.
But we'll just, this bird won't be on the page or something anymore.
So you can kind of know.
But, yeah, it's kind of cool.
They're being transparent about that.
Yeah.
One of the things that was interesting is that they got asked for addresses, including mailing and residential addresses.
But they don't collect that.
They just, I mean, that information isn't saved.
So it's not there.
Yeah.
I'm sure it's a form.
And like, we would like this information.
Well, we don't have that.
So we'll give you what we got.
Yeah.
Okay.
Nice.
All right.
I got a couple of real quick ones here.
Not Python.
One, I wrote something called, you can ignore this post.
Trying to get a lot of attention, of course.
What it actually was is I just wrote about the github.com/github slash git ignore repo.
Which has all, like when you go to github and you say create a new project and it says, do you want an ignore file?
And it gives you a list.
These are all the ignore files for every language supported there, including Python, which is in here somewhere right there.
And so you can actually see what they all are.
You could even do a PR.
Like we really need to start ignoring.
You know, if there's a new file format, that's like a build output of some new pyproject.tominal tooling.
And it starts to, you know, needs to be ignored.
You could say do a PR against this.
So every repo on GitHub starts to adopt it.
But also if you're doing, say, Python and front end stuff, you could go look for Node.
And you could select one and then copy some stuff out of another to kind of create a combined one.
Right.
So you're not like, well, is it Node or is it Python?
I really want to ignore for.
So anyway, that article is just sort of about that.
Really short.
People can check that out.
I use that all the time because I'm also on GitLab and GitLab doesn't fill those out for you.
Oh, yeah.
I hadn't really thought about it, but you could nab it for other purposes as well, right?
Yeah.
Yep.
And then someone on Masset, I'll point out, you can do nox Python ignore.
And I think it'll generate that file for you and uses that as the backend.
I think.
I think so.
Some of the nox and some incantation will generate an ignore file for you.
And if we have that wrong, somebody will correct us.
They sure will.
And we appreciate it.
And speaking of incantations, are you ready for the joke?
Yes.
Okay.
So here's the joke for developers.
It says, careful where you might end up summoning a demon.
And it has two categories, what you do in programming and what you do in demon summoning.
So first one is you must know a language unspoken by mankind.
Programming.
Check.
Demon summoning.
Check.
Requires that you be exact or suffer dire consequences.
Programming.
Check.
Demon summoning.
Check.
Involves much cursing, swearing of oaths, and pleading with a higher power.
Programming.
Check.
Demon summoning.
Check.
Another one is not understanding the true power you wield or the consequences of your actions.
Programming.
Check.
Demon summoning.
Check.
The only differentiation, which I think is debatable, is candles.
Do you use candles to accomplish this job?
Programming?
No.
Demon summoning?
Yes.
And if you look over on Reddit.
The comments are pretty glorious.
That's funny.
Let me see if I'm finding these good ones just here.
Someone has said something like, I've been trying for hours to get this demon to run, and I just can't get it to work.
That's what I'm writing on.
Well, we're trying.
Damon, not demon, right?
Of course.
Damon.
And then someone else points out, you know, there actually is a candle app platform, which sounds truly demonic to me.
So let me describe.
This is like a real thing.
This is not a joke.
Candlescript.org.
Somebody created this.
Let me lay out the beautiful technologies that Candlescript combines.
Are you ready to use the new open source platform that unifies core features of XSLT, XQuery, XML schema, RelaxNG, BNF, and XQuery update, and more into a single language called Candle?
No, please, no.
XSLT, no.
Yeah, that sounds pretty demonic already.
So I'm a little suspicious of that one.
Yeah, and I think that actual demon summoning, they're probably worried about climate change and probably switching to low carbon lighting.
Yes, yes.
So probably LEDs now instead of actual candles.
Yep, LEDs.
Got to be careful about home automation.
You might complete all the checkboxes.
Yeah, I think sometimes you have to execute a child.
That's funny.
Child processes.
Yeah, they both execute children, right?
I mean, that's a pretty rough one.
Kim, I believe, maybe has done enough XSLT as I have to know that it should never, ever be done.
And says, Candlescript has just triggered my PTSD.
Yeah, funny.
Oh, the battle XML days.
Well, that's it, Brian.
Great show as always.
Thank you for being here.
Well, thank you.
Thanks to you, everyone, for listening and those of you who joined live.