- Podcasts
- Python Bytes
- #396 uv-ing your way to Python
About this episodeTopics covered in this episode: uv venv --python & uv python Python 3.12.5 released Compile and use dependencies for multiple Python…
- uv venv --python & uv python
- Python 3.12.5 released
- Compile and use dependencies for multiple Python versions in Tox
- Catalog of Dark Patterns
- Extras
- Joke
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
#396 uv-ing your way to Python
Hello and welcome to Python Bytes, where we deliver Python news and headlines directly to your earbuds. This is episode 396, recorded August 13, 2024. I'm Michael Kennedy. And I'm Brian Okken. And this episode is brought to you by Scout APM. Thank you to Scout for their continued support of the show.
Check out their link in the show notes. We'll tell you more about them later. If you want to follow us on the socials, you can find us all over on Mastodon. Links at the top of the show notes. And we are on X, although less active than we are on Mastodon, I would say. When we catch the live show, you can do that at pythonbytes.fm/live.
Okay. Good. That's all I meant by it. Okay. All right. Well, let's kick it off with your first item. Okay. I want to talk, I think I already, I covered uv, a uv article yesterday, a lot yesterday. Yeah. Last week. Well, it's the summertime. You got to be real careful about your uv index and put it on your, oh, wait, no, not that.
This is from Juan Luis Cano Rodriguez. Awesome name and cool profile picture. Anyway. So uv, what is, we like to bash on packaging, but it's just continually getting better. And especially with people like Brett Cannon trying to continue to make it better. It's going to, and people at uv at Astral making uv better.
But what, so what is this about? This article, I didn't really want to completely cover the article, but there's some pretty cool stuff here. So bootstrapping, getting a project started is difficult sometimes or knowing what to do. And, and I've been using a uv for making virtual environments, but, and it's really fast at that.
But I took another look at it. There's been some updates that I didn't know it did some, some cool stuff. So one of the highlights here is uv Python. It manages Python versions. And I'm like, what it does what? So I went and checked it out. And you can, so you don't even have to, so you can go down and say uv Python install and it installs Python versions for you.
And it's really fast, but you don't have to. And I'll tell you why in just a sec. You can, you can install it like that, but you can also say uv Python list and it lists all the Python versions that it can find on your system. But if you say uv, V, E, and V, so creating a virtual environment, you can give it a Python flag with a, with a number.
And then you can say uv managed. Yeah. Only managed or managed system or only system. Gotcha. Awesome. Yeah. Yeah. Python preference. But if you say managed, which is supposedly the default, but I had to pass it in anyway, it just does it. So I'm like, this is cool. And I installed like six versions of Python on my Mac yesterday in seconds.
And just, just to have fun to create virtual environments. And, and it's just neat. So I only really need a Python with, I usually use Python within virtual environments. So being able to just install one into a virtual environment is cool. So what else can we do? So the, there's other things that uv can do that, like it can initialize a pyproject.toml for you.
And it sets up, if you do a knit, it sets up pyproject.toml and a readme and a source layout. It doesn't do a lot, but it gets you started. The, the thing that I thought was neat is add. So you can add dependencies to your pyproject.toml with uv add. And so you don't have to look up the syntax for it.
The other cool thing about it is you can give it the dev flag. You can say uv add --dev. Like you can say --dev py test. And it'll add py test to your development dependencies, which is neat. So I guess I was going to say packaging is not solved with uv. But maybe, maybe it is. There's some pretty cool stuff.
This is awesome. Yeah. If you look up, if you say uv help, there's a whole bunch of experimental, experimental items through here. So there's run, a knit add. A lot of these are experimental features. Tree is cool. You can do a project dependency tree using uv. So there's a lot of stuff that I used to use other tools for that uv is doing.
Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. Yeah. And so the reason that Charlie and team chose uv pip as part of the CLI interface as a sub-command was so that they had space to do all these other things. So if you just said uv install, well, is that install the Python thing? Is that install a package?
Oh, yeah. Yeah. Right. Right. And so they put that in there as almost like a namespace for all their commands and stuff. And how much new stuff is under these experimental sections? Starting to feel like, okay, this is what they had in mind, right? Yeah. Yeah. So the experimental part makes me nervous to put it into my normal everyday workflow a little bit.
But for personal workflow stuff, why not play with it? Yeah. As you're going through this and seeing this title, Python Packaging is great. UV is all you need. I think it's all I use these days. I don't think I use anything else. There are some systems that the whole, especially with certain firewalls, that I know you can get around it with uv, but there are some systems that I work on where I have trouble working with uv, but pip works fine.
So, but I wonder if I, you know what? It's possible that my uv is over a week out of date and it doesn't know, right? Something like that. I don't know. Anyway, 312.5 is out. And if you scroll through, I'm linking to the release notes. Sometimes it's hard to find like what is actually changed in say 312.4 to 312.5.
And so there are a lot of releases and changes in just this minor point release. So we've got a bunch of tests that are fixed. How about that, Brian? That's great. Yeah. Two different security improvements, patches, I guess. You know, they're not, don't think they have CVEs. So there must not be too bad.
Like audit, like missing audit events around certain behaviors. Like, okay, so you couldn't audit it properly, but it's not, it's not a, you know, all your bases are belong to us sort of thing. A bunch of stuff in the library. So for example, a new version of pip. So for just a moment, just briefly, when you create a virtual environment, I won't say your pip is out of date.
It knows it's something's gone terribly wrong and it shuts down. Right. But the Python, cpython seg faults, then it just goes poof and goes away. So there's a ton of stuff like this. So I just wanted to call, call people's attention to all the changes here. And there's even some that look like performance.
We have the technology. We can rebuild it. Okay. Can you even imagine going back to the time before f-strings? It was a dark time. It was a dark time. My percent, my percent key still has no, no, characters on it. No, just kidding. Yeah. Yeah. Indeed. Okay. And before we go on to the next one, you were probably going to give us some really awesome segue there, but let's talk about, Scott APM before we move on.
If you do lazy loading in your ORM, then you say, Oh no, why is it so slow? Why are you doing 200 database queries for what should be one? So you can find out things like that. And it links it back directly to source code. So you can spend less time in the debugger and healing logs and just finding the problems and moving on.
And you'll love it because it's built for developers by developers. It makes it easy to get set up. Seriously, you can do it in less than four minutes. So that's awesome. And the best part is the pricing is straightforward. You only pay for the data that you use with no hidden overage fees or per seat pricing.
And I just learned this, Brian. They also have, they provide the pro version for free to all open source projects. So if you're an open source maintainer and you want to have Scout APM for that project, just shoot them a message or something on their pricing page about that. So you can start your free trial and get instant insights today.
And it's kind of a neat idea. I use Tox for incorporating it with GitHub Actions a lot to be able to, well, and just locally to be able to test multiple Python versions and multiple versions of different libraries, how they work together. Tox is great for things like that. But one of the things that I didn't think about was doing pinning, like compiling pinned list or lock lists for dependencies for multiple Python versions.
And so this article walks you through kind of why you would want to do that, but then also how to. And the little trick here, which I think is cool, is that Tox uses an environment name called the env name. And so there is a way to be able to specify, use that to look at different, the Tox environment that it created, because it creates a little virtual environments when it's running.
But the neat thing about that is you can use it other places. And the idea around this was to go ahead and use this article uses pip-tools, but really, I think you could use anything. But to target a compile, like a pip-tools compile and, and send it to using pip compile and using pyproject.toml as the base file, and then outputting to a requirements in env name, which is, or a env.text or a, like a env-dev.text.
And then also, I also like to have a requirements dash whatever. So even if I had them all filed into a directory, I usually put something like requirements dash 312.txt or something like that. But having that be able to specify it from the project allows you, allows the little trick to be able to say, oh, here's an example of with the requirements dash.
I like that a little bit better. But to, to have a requirements target within Tox, so that you can use that to compile your project, compile those. And while they're running, you're, instead of like in CI or something, can grab those. And instead of generating a, just whatever it can find, it's a pinned or a locked set of, set of dependencies.
And I want to, I'd like to be, I think I'll play with this. But if anybody else has time to play with this and see if they can get it working with uv, I'd love to see the outcome. So. Yeah, that's awesome. I imagine you can, because if it was using pip-tools, you know, it's got the pip compile behaviors.
It shouldn't be that hard. Yeah. Yeah. It's awesome. Yeah. This looks great. I love it. What do you got for us? You let's, let's close it out with dark. I did tell you it was the 13th, didn't I? Yeah. So I present to you a, this is not exactly a Python thing, but I feel like this is a, anyone who builds web apps or other types of apps and interacts with, you know, users sort of thing.
So superset, if you will, I present to you a catalog of dark patterns for software. Dun, dun, dun. Dun, dun, dun. It says discover a variety of dark pattern examples sorted by category to help you better understand deceptive design practices. So there's some that you probably would know like bait and switch.
And each one of these has at least one concrete, like case study of evil, badness of darkness, let's say. So the bait and switch one, which says this tactic lures users with an enticing offer only to change the terms unexpectedly. So they've got a lift 60% off. Wouldn't you like 60% off of your next ride?
Just click here and sign up, right? And then once actually your next two rides, it says right here. Yeah. But then actually, as you try to apply it, it turns out it only counts towards 60% off the first $10. So if you like went to the airport, it was 50 bucks. It's like, well, you know, it's still 44.
Yeah. Perfect. so that's not ideal. No. To me, the classic bait switch is the cable companies for internet or, or anything like, don't you want to add like a home phone, like digital phone? And then you can add like the sports package and it's only $5 more for the first, you know, for the first, six months.
And then it's like $150 more. So I had one just like yesterday. I had an email from my cell phone provider that said, since you've been here, like so many numbers of years, we're going to give you 10% off. I'm like, that's cool. And I clicked on it and it was 10% off any of your case pair purchases.
Like, so shady. So shady. So that, I mean, people probably know that one, but there's other ones that are, interesting. Like one that I really like is the roach motel. Okay. So, you know, what is that? Oh, it's this dark pattern usually used for subscriptions, making it easy to sign up, but nearly impossible to cancel.
So please come down to our office during hours of four and three. Exactly. Exactly. Exactly. And if you don't get through the line of people backed up trying to get out of it, then, you'll, you'll, do bad. Try again the next week. So there's a bunch of these. I'll do one more just that people go play with them.
Disguised ads. Oh, I thought it was disgusting ads. Disguised ads. Okay. Disguised ads, which are themselves disgusting, but the pattern is disguised. So Microsoft edge, for example, and I feel like Google, this is towards Google Chrome, like a thing towards, I feel like it's also kind of reverse a lot of like Google does that as well.
Like, wouldn't you rather use this instead when you search for something? Anyway, I'll give you the example that's on the page. So you may encounter not one, but two dark pattern patterns when attempting to get Google Chrome onto your computer. When you have Microsoft edge, this happens when you have a empty install of windows.
The second one is confirm shaming. And so this is like a good case here. So if you go over to google.com/chrome in edge and you go to the down, you go to the, like the, where you get to download it. It literally has a built into the browser popup that comes out of the menu bar. No, that dress bar rather says, I hate saving money.
Said no one ever. Microsoft edge is the best browser for online shopping. Just by literally visiting the Chrome page, you get this popup. It's like integrated, not into the HTML, but into the UI of the browser. That's so funny. Yeah. So that's, that's shady. That's one. I kind of love the boldness of that though, actually.
But I know. And then if you go to, go to Bing, I believe this, which is the default search engine and you just search for Chrome, you get some results. And then there's like this other part. Oh no, this is actually in the start, the start menu. This is in the start menu. So if you type Chrome, you like try to run Chrome.
Oh dear. Half of the whole start menu says, try Bing wallpaper. Switch to the browser recommended by Microsoft. Download edge. Yeah. Oh my God. Yeah. So what's cool is it says, look here, like it kind of highlights the various patterns that are here. And then like other companies that do similar patterns.
It'd be good growth act. Cause then you could appear under every category. That'd be like some like link. Pre-advertising. Exactly. Yeah. Anyway. Yeah. This is what I got for you. Kind of interesting. Nice. Extras. You got any extras you want to share? The extra I wanted to shout out was, was just, I've been, I've been, I think I have my recording done for, for HelloPiTest.
The only thing left to record is the summary at the end. The, I want, well I have the, there's a few things I want to like one extra video and record, but I want to edit everything first. I'm in the process of editing and keeping track of everything so that at the end I can go, Hey, we went through all these things.
So I want to make sure. Actually the thing that I have left is I want to review all of the command line flags that I use in the course. I don't remember all the ones I've used. So I'm writing down as I'm editing. So nice. That's awesome. But I'm on track for August 19th. A few people have ordered already.
Thank you so much. Everyone that's ordered so far. So love you. My wife loves you. We went out to got coffee or off of money we got from this. So beautiful. Yeah. Available for pre-order now. Yeah. what you got? I have just a couple of things. Django 5.1 released though. Big deal here is easier guardrails for authentication.
The second oldest ticket is now fixed with a long awaited query string template tag. So these things are all good. And let's see. What's there now? I thought there might've been a CVE or something in here, but I don't think so. I saw Django CVE not too long ago, security deal, but it doesn't seem like it's addressed with this one.
So it must've been fixed previously. All right. So that, and then here's the bookend. We started with a 312.5 being available. Well, how about Python 313 looking forward with release candidate one is out. So this happened a little bit ago, but if you're out there and they say, please test, you have a package, especially a popular one, please test it with Python 313 ahead of time.
So we can do stuff about it. And you're like, oh, it's betas. I'm not going to take the trouble. I'm not going to worry about it. Well, it's now officially stable in terms of features, right? They're not going to add or remove things ideally unless they absolutely have to. So you should be able to properly start putting energy into testing and playing with this one.
UV team out there listening. Astral, come on Astral. What are you doing? Exactly. Let's, let's get, let's turn uv Python into like, this is how I get the freshest Python, which is actually one of the things that's a little tricky. Like homebrew, it takes a week for that stuff to show up and other stuff.
Yeah. A week. Yeah. Who wants week old coffee? No, no. Your threads are totally stale, but. It's a, it's a goofy episode, man. It is. All right. I know you got the joke for us this week. So. Okay. Well, actually, before we get onto this, I was just thinking because you, you wanted, when you were talking about Django, I thought of a new, of a, a dorky joke.
Cause it's lowercase. Ars technica, had an article parody site. Clown strike refuses to bow down to cloud strikes, bogus DMCA takedown. so there's an article here. I wanted to check it out myself. so if you go to, clown strike dot LOL. and we'll refresh it. see if it, it starts out looking like crowd strike, but it has a little goofy hat on it.
and then if you put, I'm not going to play the music now, but, if you play music, it's got like some, some goofy little music that goes along with it. And there's a clown. That's it. That's just, it's just funny. but, now if you click on the left, it tells you about all this. Well, it tells you the ARS technica article, but it also talks about this story about how they had these takedown, crowd strike tried to take them down and it's just silly.
And it has to be like updated within hours of you learning new information. I don't know. It's, it's tough. It's apparently it's one of the best antivirus systems out there that actually works. And isn't just, you know, you wouldn't talk dark patterns. Like a lot of this antivirus clean your computer stuff is really shit shady, but boy, did they cause a problem that I would not want to be in their shoes.
