Monitor performance issues & errors in your code

#408: Hatch: A Modern Python Workflow Transcript

Recorded on Wednesday, Mar 1, 2023.

00:00 In recent years, there's been a lot of experimenting with how we work with dependencies and external libraries for our Python code.

00:07 There's pip, piptools, poetry, pdm, pyenv, pipenv, hatch, and other workflows.

00:14 We dove into this deeply back on episode 406, reimagining Python's packaging workflow with a panel.

00:23 And this time, we're back with Ofek Lev to take a deeper look at hatch.

00:27 This is Talk Python to Me, episode 408, recorded March 1st, 2023.

00:34 Welcome to Talk Python to Me, a weekly podcast on Python.

00:49 This is your host, Michael Kennedy.

00:51 Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using @talkpython, both on fosstodon.org.

00:58 Be careful with impersonating accounts on other instances.

01:01 There are many.

01:02 Keep up with the show and listen to over seven years of past episodes at talkpython.fm.

01:08 We've started streaming most of our episodes live on YouTube.

01:11 Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.

01:18 This episode is sponsored by Microsoft for Startups Founders Hub.

01:23 check them out at talkpython.fm/foundershub to get early support for your startup.

01:29 And it's brought to you by Sentry.

01:32 Don't let those errors go unnoticed.

01:34 Use Sentry.

01:35 Get started at talkpython.fm/sentry.

01:38 Ovech, welcome to Talk Python to Me.

01:40 - Thank you, good to be here.

01:42 - It's been a long time, at least a week since you've been on the show.

01:45 (Ovech laughs)

01:46 - Yep, just about a week.

01:47 - Welcome back.

01:48 In that appearance, it was a big panel of many of us talking about Python packaging.

01:54 And you're the author of Hatch and Hatchling and a really interesting take on that tooling story.

02:01 So I thought it'd be fun to go ahead and just dive into that in particular for this episode and get your thoughts on it.

02:07 So I'm looking forward to talking about Hatch.

02:09 - Yeah, sounds fun.

02:10 - Yeah, it will be fun.

02:11 Before we get into it though, a lot of people maybe don't know you out there.

02:15 What's your background?

02:16 How did you get into programming in Python?

02:18 Those sorts of things.

02:19 Let us know.

02:20 I guess originally, this was like maybe 15 years ago now, I was just automating stuff that I was doing every day.

02:27 So for me personally, I have a condition that makes me kind of weak, so all I can use is like a mouse.

02:34 Therefore, I type pretty slow.

02:36 So I was auto-completing like sentences, templating for like sending emails, basically like the traditional developer mindset.

02:45 If you're doing anything more tha n once or twice, just write a script for it.

02:49 I had like dozens or maybe even a hundred scripts just to automate like boring stuff.

02:55 Kind of like the book, which I've never read the book, I would make the boring stuff, but I imagine it's what I was doing.

03:01 That's how I originally got into Python.

03:03 Excellent.

03:04 You were doing the traditional developer thing.

03:06 Why spend 20 minutes doing something when you can spend two weeks automating it?

03:10 Yeah.

03:11 Just kidding.

03:12 Like, I really think that that's a huge value.

03:16 There's so many people out there, probably many people even listen to this podcast, where they don't consider themselves developers, but there's like little things that could be automated that are super annoying.

03:30 You don't look forward to it.

03:31 Just a little bit of programming skill will let you really blaze through those things.

03:36 Plus it also gets you further into Python where, you know, maybe one day you're releasing tools to manage everyone else's Python projects.

03:43 Yeah, for sure.

03:45 You don't know where it's going to go, right?

03:47 >> Yeah, now I work at Datadog, working on agent integrations.

03:51 So it's like, the thing that you physically install on your server host, it ships out of the box with like, almost 200 integrations.

04:00 Like connecting to databases like Postgres, or monitoring like, Windows APIs, or hypervisors like vSphere.

04:10 Pretty much whatever our customers want to monitor, it's our job to like find a way to connect to it and provide useful data.

04:18 So. - Yeah, excellent.

04:19 - A lot of research into every product that we integrate with.

04:23 Sometimes the documentation is kind of sparse.

04:27 So it's lots of investigative work.

04:29 - Yeah, I can imagine.

04:31 That sounds really fun.

04:32 And I can see that as a follow on from the way you got started as well, right?

04:37 Automating a bunch of tasks is not that different from kind of automating integration with a hundred different apps and performance counters and logs and different things, right?

04:48 - Definitely.

04:49 - Cool.

04:50 Is that part of the application performance monitoring type thing?

04:52 Are there--

04:53 - We do that as well.

04:54 That's not my team, but yeah.

04:56 - Okay.

04:57 - That's probably what we do.

04:57 - All right, well, let's go ahead and dive in.

05:01 - Sure.

05:02 - So as I said, if people want to check it out, you were on the Python packaging discussion and over there was a broad conversation with a bunch of core developers and other interested folks, building tools like Hatch and so on, about where are we with packaging?

05:19 Because a little while ago, I remember packaging mostly felt like PIP, instead of tools, maybe just this detail, something like that.

05:29 And then it kind of got unlocked, the separation of like the build backends and stuff.

05:35 And then many people started creating things.

05:37 We had pipenv, we have poetry, we have pdm.

05:42 There's a bunch of different ones and Hatch is amongst them, right?

05:45 - Yeah.

05:46 - Let's set the stage by just talking about, first of all, what do we mean when we're talking about Python packaging?

05:52 And I'll ask you for you, right?

05:54 Like it might mean something different for me than it might mean for you and it might be different for someone else as well.

06:00 But let's just start with, you know, when we talk packaging, is that getting libraries to devs?

06:05 Is that developers deploying their apps to servers?

06:08 Or is that me sending an executable end product to a desktop?

06:13 Like, what does it mean?

06:15 - Yeah, that's a good question.

06:16 I would say all of those are packaging.

06:19 Historically though, we've mostly put our efforts toward the first one, which is basically like a developer making a library and making that really simple for other developers to use that library.

06:33 So in the form of wheels being hosted on PyPI in particular, that's what we put our efforts on, which I think either way you look at it was the right choice to focus on in the beginning.

06:45 'Cause either way, from either first principles or even hindsight looking back, you can't build a community without packages and being able to get packages and distribute packages.

06:58 So I think that was the right choice.

07:01 And I think now we're trying to satisfy other use cases, notably applications, I guess.

07:07 Yeah.

07:07 I mean, we even have an XKCD for it, right?

07:10 True.

07:11 And I don't know how many people know this.

07:13 If you were in the Python REPL, you can type import antigravity and actually it does something.

07:20 So the old XKCD is there's a person flying and the person on the ground looks at us.

07:25 How are you flying?

07:26 Python.

07:27 Just learned it last night.

07:29 Everything's so simple.

07:30 Hello world is just print.

07:32 Hello world.

07:32 The person on the ground says, I don't know, dynamics, hyping white space.

07:36 Come on, join us.

07:38 Programming's fun again.

07:39 Okay.

07:39 But how are you flying?

07:40 I just typed import anti-gravity.

07:42 Right.

07:43 And it's a great joke, but honestly, that is one of those superpowers of Python.

07:49 Is that how many things do we have right now?

07:52 How many packages?

07:53 436,000 packages.

07:55 Like insane.

07:57 It's just insane.

07:58 Yeah, no, it's.

07:59 Yeah, massive community and really all kinds of domains from doing, you know, as we talked about automating scripts, you know, different tasks to doing like computing for, whether, you know, biomedical stuff, you know, even, embedded devices now with like, MicroPython stuff like that.

08:20 So it's yeah.

08:21 Users of Python do everything pretty much.

08:24 Yeah.

08:25 - Yeah, I think in the near term, we're gonna be talking about front end web as well with PyScript.

08:31 And PyScript showed the possibilities, but I recently had a show on PyScript intersection with MicroPython, and that starts to be like, well, here's a couple hundred K download, and now you got Python in the front end.

08:46 What do you think about it now?

08:47 But of course, that has its own packaging and distribution story that we're gonna have to think about as well.

08:53 like, well, kind of like node modules.

08:55 Now what do you do with packages that got to run on the front end?

08:57 This is getting weird.

08:58 - Yeah, that kind of goes to, you know, talking about like how hard it is to do packaging when you have, you know, dozens of use cases that we have to satisfy.

09:09 And with us being mostly just volunteers in our free time trying to do everything.

09:14 So yeah, it's fun and also challenging.

09:17 Yeah.

09:18 - Yeah, absolutely.

09:19 Another area, another thing we could consider Could be Conda, right, actually, yeah, I got that pulled over here.

09:25 Could be Conda, right?

09:26 This is a completely different take on pip and wheels.

09:30 - Yeah, Conda is pretty cool.

09:32 I think Conda, if I have my history right, it came about because there really was no packaging story some time ago.

09:40 So Conda, I think was made by Peter Yang, if I remember correctly.

09:45 And he has a whole company now around it, supporting Conda.

09:49 And yeah, it just makes it easy to install very complex stuff.

09:54 So if your package depends on, yeah, you can put in Fortran and Rust and all kinds of stuff and it just magically builds it and you can install it pretty easily.

10:05 Yeah, it's pretty impressive.

10:07 - It is pretty impressive.

10:08 And with wheels now, it's closer, what we do with pip.

10:12 It used to be setup.py would run and whatever it needed to do, it would do.

10:17 But often that would require, "Well, compile this," usually with C back then, but for the scientific libraries, it says, "Well, compile this thing with Fortran," and they compile this thing with Scala.

10:29 You're like, "I have neither of those things "set up as dev tools on my environment.

10:33 "I'm a science student.

10:35 "What am I doing here?" Right, and so that was the angle they were solving, and I think pip and Conda are coming a little bit closer together.

10:43 I think they're not necessarily converging, but they're more similar now than they used to be.

10:47 - Yeah, definitely that is true.

10:49 And yeah, there's talk, I don't know how many people are aware, but the Python forums has a subsection on discourse for packaging.

10:57 So yeah, right now there's actually talks from people at Conda trying to decide how we can kind of provide a more, like a unified experience.

11:07 - That's interesting.

11:08 - 'Cause right now Conda has their own repo, like for all their packages, And PyPI is its own thing outside of Conda.

11:17 So yeah, there's talk about possibly making that like interoperable.

11:23 - Oh yeah, okay, that'd be really interesting.

11:25 Let's see, there was a question out here from Copa.

11:29 Since we're in this realm, like what do you think about Docker as a way of shipping things?

11:33 You know, a lot of times we'll get checkout, get clone, some code on a server, maybe some production branch, and then go through these steps, right?

11:43 pip install requirements or a hatch run type of initialization, or you just get that done in a Docker container and you just hand that out.

11:52 What are your thoughts on Docker as part of this?

11:54 - Yeah, Docker definitely has its use cases.

11:57 Like I guess in lieu of the black file, you can kind of use Docker as a reproducible environment.

12:05 But I still think there's a place for a way to actually build applications outside of Docker, outside of containers in a reproducible fashion.

12:16 I think that's still necessary.

12:17 - I do as well.

12:19 So Docker really, it addresses some of the types of packaging that we discussed really, really well.

12:26 For example, I need to get my running code onto a server, but Docker is less good.

12:32 It's not completely irrelevant, but it's less good at giving a developer a library, right?

12:38 If people that make HTTPX and the people that make fast API, they're not going to build a combo Docker, right?

12:46 There's still a place where you've just got to get the things.

12:49 And that's like a base level closer to where a hatch might be working.

12:52 And also Docker is not fantastic at sending to an end user.

12:55 If I want to build an app that a non-technical non-developer person can use, Docker is the opposite of what they want.

13:03 Yeah, true.

13:04 Yeah.

13:05 I will say there's another use case, which is like, if your machine is like messed up somehow, and some library package isn't working, I've had this happen with my co-workers on their Macs.

13:18 It is nice to be able to just go into a container and start fresh.

13:22 So I've had that happen a few times.

13:24 It is isolated in quite a good way. And that's pretty, pretty excellent.

13:28 So on that packaging panel that we were on, There was a really interesting focus for a little bit talking about, well, what is responsible for what?

13:41 So right now, for example, I might use pip as a way to add tools to Python to a Python project, but I'll have to already have Python there. And in other communities, and even a little bit like Conda, and in this as well, there's tools that will say, what you do is use a tool kind of like pip, But it gets you the runtime.

14:03 It gets, it would get you a version of Python you asked for plus the libraries.

14:07 You know, I think rustup was one of the, the things that was brought up there.

14:13 Right.

14:14 So for people who don't know rustup, it's an installer for system for basically setting up a rust environment for doing rust.

14:22 So.

14:22 pip up Python up.

14:24 I don't know.

14:25 I don't know what we would call it, but do you want to just, you know, maybe give of your thoughts on that? Cause I think you had some comments on that, like inside out, outside in where, if you could start fresh, where were the tools?

14:36 How would that work?

14:37 Yeah, I think if we were to start fresh, I think the way Rust does it is like now the, the gold standard, it's probably the best way to do it, which is how, as you mentioned, Conda, a similar thing where you have a tool that you download and that one tool is in charge of managing the various Python or programming language versions. So if I were to start fresh, you would have a tool like Catch that you would download as an MSI or EXE or some kind of installer similar to Rustup.

15:09 And that tool would manage the various Python versions and environments and packaging. So for Rustup, when you download this, it gives you Rustup, which manages Rust, but then it gives you Cargo, which is a separate command, and that's their package manager.

15:29 Right.

15:30 But in both cases, they live outside of Python.

15:32 Interesting.

15:33 Yeah, Cargo is to Rust as pip is to Python, right?

15:36 That kind of thing.

15:38 Hey folks, let's pause for an ad.

15:40 Remember last time I had this advertisement for Microsoft for Startups?

15:44 Well, I asked the AI to have some fun with it just to show you how powerful what they have on offer really is.

15:50 Here we go.

15:51 Me.

15:52 Can you rephrase that Microsoft Founders Hub ad as a hipster?

15:56 AI, sure.

15:58 Here's a rephrased version of the ad in hipster style.

16:01 Yo, Talk Python fam, this segment is brought to you by the sickest program out there for startup founders, Microsoft for Startups Founders Hub.

16:08 If you're a boss running a startup, you're gonna wanna listen up because this is the deal of a lifetime.

16:13 Microsoft for Founders Hub is your ticket to scaling efficiently and preserving your runway all the while keeping your cool factor intact.

16:20 With over six figures worth of benefits, this program is seriously next level.

16:24 You'll get $150,000 in Azure credits, the richest cloud credit offering on the market, access to the OpenAI APIs in the new Azure OpenAI service, where you can infuse some serious generative AI into your apps, and a one-on-one technical advisory from the Microsoft squad, who will help you with your tech stack and architectural plans.

16:44 This program is open all, whether you're just starting or you're already killing it.

16:47 And the best part, there's no funding requirement.

16:50 All it takes is five minutes to apply, and you'll be reaping the benefits in no time.

16:54 Check it out and sign up for Microsoft for Startup Founders Hub at talkpython.fm/foundershub.

16:59 Peace out and keep listening.

17:01 Thank you, Hipster Michael.

17:02 And thank you, Microsoft for Startups, Founders Hub for sponsoring the show.

17:06 I think that's pretty helpful because one of the problems is, well, you need to pip and saw this thing.

17:13 Oh, do you have the wrong version of Python?

17:16 Well, you gotta, you know, there's a lot of steps back and there's no immediately obvious command other than completely from scratch, install a new Python.

17:24 >> Yeah.

17:25 >> There's a tools that manage that, right?

17:26 Like pyenv can work, although I've had trouble with it.

17:30 >> Yeah, I've had issues with that.

17:31 Yeah, I think it would be less error-prone in this hypothetical way, where the tool doesn't mess with your shell in a global manner.

17:41 It just has its own paths to Python and just does everything by itself.

17:47 >> That's interesting. That starts to maybe make it easier to to solve the, I want to ship you an executable binary, is if the tool were in charge of, I create this working directory where part of the things I've installed is all of Python and all the packages you've asked me for, I can see how that pretty quickly becomes something I'll bundle that up and hand it to somebody and give them an entry point.

18:11 - Definitely, I could help that situation.

18:14 I think there's not really a standard way to build an EXE from like a Python package.

18:21 There are a few tools, like PyOxidizer is one newer option.

18:25 PyInstaller, CXFreeze, I think was the thing that I've used before.

18:31 So, there's a few options.

18:32 - Yeah, I've used Py2App, and that's actually worked really well.

18:35 I've used PyInstaller, and it's worked mostly well, except for I've had weird situations where on Windows it's great, but on Mac it has a dangling terminal.

18:44 In addition to the GUI, I'm like, what are we supposed to do with that?

18:48 How do we make it go away?

18:49 Like, you know, here's the command.

18:50 Like, no, it's not going away.

18:51 I don't know why.

18:52 And if there was a more official sort of core dev organized way, that would make me super happy.

18:59 I'm not so much for official or unofficial.

19:02 My view is like, if it works, it works.

19:05 So as long as it's satisfying, you know, all the use cases, that's what I would push for.

19:10 So I think right now, based on what I've used personally, I think PyOxidizer would be the the best choice for distributing standalone apps.

19:19 - Interesting, okay.

19:21 All right, cool, well, let's move on and start talking about Hatch.

19:26 So, first off, why'd you build it, right?

19:30 We had Pip.

19:31 (laughing)

19:32 Why do we need Hatch?

19:33 And I don't know exactly the timeframe of when it came out, so maybe we had other things like poetry, or why'd you go and create this?

19:41 - So Hatch, I did, it was kind of an owner project back in the end of 2016 or early 2017.

19:49 I wasn't pleased with the tooling in Python.

19:54 I think very similar to the author of poetry.

19:57 That's kind of why he made poetry.

19:59 So I wanted something that kind of matched my mental model of how development would go with building packages and managing environments automatically, stuff like that.

20:10 When I made it though, there weren't very many standards for packaging and everything was kind of in limbo at that point, which kind of discouraged me from continuing because I was like, okay, in a six months or a year or two, I'm going to have to rewrite to follow standards.

20:29 So I kind of just stopped development for a few years until everything was standardized.

20:35 And then I rewrote it about a year and a half ago with this new version and new docs.

20:43 So that's kind of the history of it.

20:45 Yeah.

20:45 I saw that there's a.

20:46 Hatch.yaml and a pyproject.yaml, and you can use either of them.

20:51 Was your hatch.yaml the original and then Pyproject.yaml gain traction and you're like, all right, well, we'll, we'll integrate with that as well.

20:58 No, I had to came, hatch.yaml came with the rewrite.

21:01 It's mostly for environments.

21:03 Sometimes when you define lots of environments, it's very verbose.

21:08 Like at my workplace, I saw a hatch file that was like over a thousand lines.

21:13 So bringing that in Py project wouldn't be very nice.

21:17 So that's why I have a second file to isolate certain things.

21:20 Yeah.

21:20 That makes sense.

21:21 Like, just like maybe you don't want to write your entire application in an app.py, but maybe have multiple files.

21:27 Yeah.

21:27 Something like that.

21:27 All right.

21:28 Well, out in the audience, we've got some kind words.

21:31 Like I switched to hatch and pip tools from poetry and love it.

21:34 That's pretty awesome.

21:35 Yeah.

21:36 And then probably before I forget, because it was right at the top of the conversation, Marwan asks, is there a time estimate for when a hatch might support things like lock files?

21:47 That's a good question.

21:48 so my goal is by PyCon to write the plugin interface for locking.

21:57 So the first version we use pip tools, actually, that would be the first plugin for lock files.

22:04 But I won't be writing like an actual lock file spec.

22:08 I'll just be using an existing pool.

22:10 The new hypothetical lock file is kind of blocked on Brett because he has most context and knowledge about that.

22:18 So yeah, I'm waiting on Brett basically.

22:21 Got it.

22:21 Brett Cannon, that'd be Brett Cannon.

22:23 Yes.

22:24 Python developer extraordinaire.

22:25 We all know.

22:26 Okay.

22:27 Very cool.

22:27 Other thing before we dive into it here, I see that you have a, some rough action going there.

22:33 I just had Charlie on the show not too long ago to talk about Ruff.

22:37 It's pretty impressive.

22:39 When did you adopt that?

22:40 I was an early adopter.

22:41 I guess a few months ago now.

22:42 Yeah.

22:43 What's your experience?

22:44 >> It's fantastic.

22:44 It's kind of like a meme to say it now, but it's true.

22:48 Like it's so fast.

22:49 It's almost like you wonder if it's doing anything.

22:52 Like it's-

22:54 >> That was my first thought.

22:55 When I ran it, I'm like, wait a minute, maybe I didn't give it any files or something, because I ran it on Talk Python Training, which is like 20,000 lines of Python code and it just went bam like that.

23:04 I'm like, maybe it didn't take that because that seems like that should take a moment at least somehow.

23:09 Yeah.

23:10 Okay.

23:10 So you recommend it?

23:11 Yeah.

23:12 All in one location and it supports like so many options as well, which is nice.

23:19 Yeah, indeed.

23:19 Cool.

23:20 Cool.

23:20 All right.

23:21 Well, let's start with a high level overview.

23:24 And then what I want to do is I want to walk through creating a project with this And I've got questions and thoughts as I kind of experience Hatch, not for the first time, but for a somewhat of a newbie perspective.

23:36 So I think we'll do that.

23:37 But let's start with the high level features.

23:40 So the Hatch project is, I guess, conceptually two different projects.

23:44 Hatch itself is the command line.

23:47 So doing publishing and environment management, versioning, stuff like that.

23:54 Then Hatchling is the build system, similar to a split or set of tools.

24:00 So that's where the build system is.

24:02 from, you can use it independently, right?

24:06 You don't have to be doing anything with Hatch to use Hatchling basically to replace setup.py, right?

24:13 Yeah.

24:13 You can replace the setup.py with the pyproject.toml.

24:16 Yeah.

24:17 And most people do use Hatchling and not use Hatch.

24:21 So yeah, Hatchling is much more popular than Hatch itself.

24:25 Okay.

24:26 So for a config, it's a bit more simple than set of tools.

24:30 The default logic makes more sense for, for new users, especially.

24:37 It's hard to mess up packaging with Hatchling.

24:41 Yeah.

24:41 Excellent.

24:41 So I could have just some random Python project that I've put together with a pyproject.toml I wrote by hand, and I could just put Hatchling in as the build subsystem to make the wheels and whatnot.

24:53 One benefit of hatching a hatch too, basically everything is a plugin.

24:58 So you can have a builder that does like the mypyC, which we have, you can have a metadata hook where you insert project URLs from some arbitrary location.

25:12 Pretty much everything you can plug into and modify.

25:16 Yeah, excellent. All right.

25:18 - And then a robust environment management.

25:20 - Yeah, so for this, this you can think of as a, as Tox or Knox, similar in spirit to that.

25:29 The difference is Knox and Tox kind of treat environments as applications where an environment is tied to a command and you run an environment.

25:40 Whereas in Hatch, you have environments that you define and then within that, you have scripts that you can run.

25:47 So you can have a style environment that might be able to rent with one script or run the formatter to change the code with another script and environment itself.

26:00 Isn't actually like, like an app you can run arbitrary commands, right?

26:06 Like I could run hatch test or something like that.

26:10 Yeah.

26:11 And passing flags.

26:12 Yeah.

26:12 Okay.

26:13 And then often people who published packages to PyPI, they've done this with Twine or some tool like that.

26:21 And Hatch has that capability as well.

26:23 Right?

26:24 Right.

26:24 Yeah.

26:24 To yeah.

26:25 PyPI or some private, you know, corporate owned index.

26:31 I think those are probably getting to be more popular than they used to be with all the supply chain silliness.

26:38 Yeah, that's true.

26:38 Yeah.

26:39 Do you have any visibility into how people are using it, whether it's public or private or as far as hatch.

26:44 Yeah.

26:45 Well, how they're using the hatch to publish.

26:47 Do you have any visibility, whether they're publishing the PyPI yet or to some kind of private index?

26:52 Based on the issues I have.

26:53 Open like future requests.

26:55 Most are talking about private indices.

26:58 Actually.

26:59 Interesting.

26:59 Yeah, it's probably, those are the ones where the edge cases live.

27:02 You know, the standard one place is dialed in and well, what if mine's on using active directory for authentication as I publish it, like it's doing what Artifactory is quite popular as well.

27:15 - Yeah, yeah, that absolutely is.

27:17 Another thing that was interesting is you have the ability to do version management, as we'll see in just a minute.

27:22 You can say like, what version is my package?

27:25 Increment the build, do a major version increment, or put it into a release candidate mode.

27:31 - Yeah, and this is Plugable as well.

27:34 So there's one plugin that's popular that wraps setup tools SCM, which doesn't actually depend on setup tools anymore.

27:42 It's just a name that's still called that.

27:44 So that pulls your version from Git or Mercurial or Subversion.

27:50 And you can source the versions that way as well.

27:53 Interesting.

27:53 Yeah, I really liked that.

27:54 I think that's a neat aspect.

27:56 And then configurable project generation, same defaults.

28:01 Yeah, I don't have too many options with this yet, but you can make it a flat layout or like a source directory.

28:09 There's an option to add tests, which puts more stuff in your pyproject.toml.

28:16 You can add a CLI, which has a very simple template for GitHub actions.

28:22 And then there's a flag for a CLI that would give you a click and set up a command line for your package.

28:32 I don't know how directly related this is to anything that Hatch does, but the usage of the pyproject.toml and then building it as a package, something you could install gives you a really nice way to create a global CLI.

28:45 Right.

28:45 Which is the entry points in the pyproject.toml.

28:48 Yeah.

28:48 That's what that CLI flag does.

28:50 Yeah.

28:50 It's very nice.

28:51 Okay.

28:51 Yeah.

28:52 Then also you say it's two to three times faster than equivalent tools.

28:55 That's great.

28:56 It really just one trick.

28:58 It just, I make the code not as readable by using lazy imports everywhere.

29:04 I've just put lazy imports and that's why it's faster.

29:08 Yeah.

29:09 Because there's a lot of execution paths that only use some of the imports in effect.

29:12 Right.

29:12 Yeah.

29:13 Going back to the scripts, Jonathan points out, I love the custom scripts within Hatch.

29:17 It makes creating build pipelines way easier and moves most of the logic within the Hatch configure rather than spreading them around multiple files, which is, that's pretty cool.

29:25 Yeah.

29:25 That's what I do as well.

29:26 Cool.

29:26 I even use Hatch for non-Python projects just for the scripting ability.

29:32 Yeah.

29:32 Cool.

29:33 Well, I mean, Python traditionally had been used for a lot of that, you know, called it glue code, right?

29:38 A lot of, well, I really want to do these other things with these other systems and scripts, but let me kind of orchestrate that in Python.

29:44 And that's, it sounds a bit, a bit like that.

29:46 Let's do a little walkthrough.

29:48 I think, I think that'll be fun.

29:49 But first of all, I think this is just MK docs, but thank you for pointing it out.

29:54 That your documentation and your website here have hotkeys.

29:59 Yeah.

29:59 MKDocs with the material theme, which is very nice.

30:03 >> Yeah. So it turns out if I just press a dot, it goes to the next page and if I comment, it goes to the previous page and it doesn't sound like much, but actually it's really nice.

30:11 It is really nice.

30:12 >> Before we read this front page, one other thing to note to go back to the top, just because I'm very happy with it.

30:18 The logo was actually generated by Dolly, the AI.

30:22 >> Okay.

30:23 >> Yeah.

30:23 >> Fantastic.

30:24 >> Yeah. Generate the logo and then I had a brother of a friend from work, I like actually touch it up.

30:30 So it's a really cool logo. I like it.

30:32 I didn't catch on that it was made by Dolly, but now I see that.

30:35 I've been doing a lot with mid journey and I think these AI tools are, I think they're a little bit fraught with maybe a few moral issues about like, well, did you really train it on stuff that you were allowed to train on?

30:47 But putting that aside, if they exist, you know, assuming just they exist, they're really neat.

30:51 And there's really amazing stuff you can do with them.

30:53 Yeah. Yeah. Cool.

30:55 I guess maybe a quick sidebar there is if you were a project maintainer out there and you don't really have an a logo Drop in on dolly or a mid journey and spend half an hour and you probably will but I I just think There are so many people that build web apps out there that don't put hotkeys into them And it's it is not that hard and it is such a nice experience And it brings you so much closer to a native app type of experience So, please put put some hotkeys out there for us All right.

31:23 So pressing dot takes us to the first one.

31:24 So installing hatch.

31:26 Obviously you can pip install it.

31:28 However, you offer some interesting other areas I want to talk about.

31:32 First of all, my favorite pipX, I love pipX.

31:36 If you've got a tool that you don't directly import into your code that does stuff against your Python apps, boy, pipX is almost always a good choice.

31:46 What do you think?

31:47 Oh yeah, pipX is awesome.

31:48 Yeah.

31:49 Yeah, it just allows you to provide isolated apps for command line apps.

31:55 Yeah.

31:55 It manages everything and you don't even have to think about it.

31:58 So.

31:59 Yep.

31:59 It just creates its own little environment.

32:01 You can say upgrade all my installed CLI tools.

32:03 It's like package manager if the thing that it's managing is built with Python.

32:08 It's great.

32:08 I had chat on the creator of PIPX a while ago.

32:11 So people, if they want to hear more about it, they can listen to that show.

32:13 Homebrew, good.

32:14 Conda brew.

32:16 Mac ports is interesting.

32:17 But the one that stood out to me was Mamba.

32:19 I'm like, wait, what's Mamba?

32:21 So it's interesting.

32:24 I hadn't heard of that, but yeah.

32:25 - Yeah, I don't use Conda that much, but as far as I know, there's a few different distributions of Conda.

32:32 So there's Anaconda, which gives you like over a gigabyte installed, like massive scientific computing.

32:40 There's Miniconda, and Miniconda gives you just the bare minimum Conda CLI with like package management and that's what most people use, I think.

32:50 But now there's Mamba, which is like mini-conda, but it pulls from conda-forge by default and conda-forge is sort of like our PyPI where anybody can contribute their own packages.

33:05 So I think that's the main difference.

33:07 And yeah, it is faster and it was rewritten.

33:11 And that's what Mamba is.

33:13 It's a re-implementation of Conda, the Conda Package Manager and C++.

33:18 Doing parallel downloading and other bits of that, which is interesting.

33:23 Cool.

33:24 Well, I don't use either all that much, but it's still kind of cool to see there.

33:29 So you could Mamba install Hatch if that was your workflow as well, right?

33:33 Okay.

33:34 So installing it pretty easy.

33:36 If you were to do it, if somebody gave you a blank machine and said, set this up to use Hatch, what would you do?

33:42 - For now I would do PipX.

33:44 - Okay.

33:45 - In the future, like we talked about in the beginning, I plan to have like an actual executable that does the work, like Python does.

33:53 But until then, then probably PipX.

33:56 - Okay, so maybe then it would be Homebrew and Winget and apps, things like the higher level OS ones, okay.

34:03 This portion of Talk Python to Me is brought to you by Sentry.

34:09 Is your Python application fast Or does it sometimes suffer from slowdowns and unexpected latency?

34:16 Does this usually only happen in production?

34:18 It's really tough to track down the problems at that point, isn't it?

34:22 If you've looked at APM, application performance monitoring products before, they may have felt out of place for software teams.

34:28 Many of them are more focused on legacy problems made for ops and infrastructure teams to keep their infrastructure and services up and running.

34:36 Sentry has just launched their new APM service.

34:40 And Sentry's approach to application monitoring is focused on being actionable, affordable, and actually built for developers.

34:47 Whether it's a slow running query or latent payment endpoint that's at risk of timing out and causing sales to tank, Sentry removes the complexity and does the analysis for you, surfacing the most critical performance issues so you can address them immediately.

35:01 Most legacy APM tools focus on an ingest everything approach, resulting in high storage costs, noisy environments, and an enormous amount of telemetry data, most developers will never need to analyze.

35:14 Sentry has taken a different approach, building the most affordable APM solution in the market.

35:19 They've removed the noise and extract the maximum value out of your performance data while passing the savings directly onto you, especially for Talk Python listeners who use the code Talk Python.

35:30 So get started at talkpython.fm/sentry and be sure to use their code, Talk Python, all lowercase, so you let them know that you heard about them from us.

35:40 My thanks to Sentry for keeping this podcast going strong.

35:44 All right, so the way we get started, if we just say Hatch New, and I thought one of the things I don't normally do here on the podcast, but I think it might be fun is just to kind of go through these steps here to see what it's like to get a sense, 'cause then I can ask questions.

36:02 So I'll say Hatch New calcy, I'll call my little app Calcy, And tell us about what we get when we run that.

36:09 - Sure, so it makes your package as you named it with about.py and init.py.

36:16 The init.py obviously makes it, turns that directory into a Python package.

36:22 The about.py stores the version by default.

36:26 And that's where it reads it by default.

36:29 It gives you, oh yeah, go ahead.

36:30 - Well, I was just gonna say, one of the things I can type now is hatch version and it gives me, basically pulls out the version of about.py, right?

36:38 - Yeah, you can, if you do the same command again, but pass in the arg like minor, then it can bump it as well.

36:46 - Yeah, so the old version is what it says, is 001, new version is 010.

36:51 Could I say build and get 11, something like that?

36:54 No, what would I type to change the last one?

36:56 - RC, you should do RC.

36:58 - Okay.

36:58 - It's documented to allow arguments as well.

37:01 - Got it, yeah, sure.

37:02 - So yeah, then it also gives you a test directory that doesn't have any predefined tests, but you can add tests to it.

37:09 And then the most important part is the pyproject.toml, which has your metadata and your other config.

37:17 - So it's got the build system set to be Hatchling, and then it's got all the project settings, like who is the author, what are the requirements, and all that stuff, right?

37:26 - And from the author, it would have gotten that from Git.

37:30 The default comes from Git, so that's why it has the right stuff for you.

37:34 And then down here is testing.

37:36 So some coverage stuff and environments.

37:40 - When I typed Hatch new, could I have made it ask me those questions like, who are you and stuff?

37:44 - There is an interactive mode, yeah.

37:46 - Okay, yeah.

37:48 Yeah, so you also, as part of this pyproject.toml, you create some of these commands.

37:54 These are the scripts you were talking about a little bit, right?

37:56 Like you've got the test and other options you can run.

37:59 - This default example down there has environment, which is just default, which is a little bit special.

38:06 It just means you have to add a prefix on the command line.

38:10 And so there's two scripts by default, a cov, so you could do like a hatch run cov, and it will run pytest with coverage.

38:19 And then another command is no cov.

38:21 - Yeah, I can do hatch test, hatch run test.

38:25 Is that a thing as well?

38:26 - There is no test command.

38:27 You could do pytest, so if you do hatch run pytest, you could, yeah.

38:31 - Yeah, excellent, that's really cool.

38:33 - Yeah, so it basically creates the structure for you and the workflow that we just discussed would be if I've got a folder and I wanna start from absolute scratch, I want to create the entire directory structure through Hatch, but there's also a way I can go to an existing one and kinda convert it to Hatch or upgrade it to Hatch, right?

38:56 - Me and other contributors have done it so much that most of the edge cases are gone, So it can take pretty much any setup.py and turn it into a hatch pyproject.toml.

39:10 And it's pretty good now.

39:11 - Okay, and because it doesn't actually need hatch the CLI, the environment tool to do that, to run and build, you could just use that to get your pyproject.toml out and use hatch.ling as a build engine, right?

39:27 But still just keep going.

39:28 - Yeah, exactly.

39:29 - Okay, so people are sitting out there like, I really should be using pyproject.toml, but you know, inertia, I don't really want to do it.

39:36 Like, Hatch new init might do it, right?

39:39 - Yeah, yeah, that's an option.

39:41 Before you time out, if you do which Python, which maybe I can just illustrate, and if you do Hatch run, which Python 3, it will show you that it's actually in a managed virtual environment.

39:54 - Okay.

39:55 So it's created a virtual environment over in, at least for me, library application support, hatch and so on, based on the project name.

40:02 And then it has some big long deal on the end.

40:04 - It's just a, yeah, it's just a checksum.

40:07 - Okay, what is that checksum based on?

40:09 The reason I ask is what do I change to make this no longer work?

40:13 (laughing)

40:15 - So I do that because it's possible that somewhere else on your machine, you might have another project, maybe a fork of Calcy with the same name.

40:25 So I have to add hash. - Likely, it's a very popular library, so it's likely.

40:28 - That's likely.

40:30 - That's why I do that, yeah.

40:31 - I see, okay.

40:32 That's like a hash of the path to where the project is or something.

40:35 Okay. - Yep.

40:36 - A lot of projects, a lot of management tools work this way, Conda works this way, for example, where there's some other place where the virtual environments live.

40:44 Is there a way, another workflow that's pretty common is to have the virtual environment in a VENV folder at the root of the project.

40:52 Is there a way when I create my project to say, I want a local ENV?

40:57 not at project creation time, but there is a way in either HatchConfig or in pyproject.toml, they are able to change that.

41:06 Yeah, which is documented on the site.

41:08 - Yeah, the HatchConfig is one of the things I would do.

41:13 There's a lot of cool CLI tools where you can ask it to show me the details of whatever it is.

41:19 So what would I put, say, into the config to say create my VENV locally and call it what is it this dirs ENV?

41:28 >> Yeah, dirs.env.

41:30 >> Yeah, dirs.env. What would I put in there?

41:32 >> You would have a subtable for virtual and then have the path be just dot venv basically.

41:40 >> Right. Okay. So like a dot slash, whatever you want to call it locally.

41:43 >> Yeah.

41:44 >> Is this, I guess I could do hatch find config or config find, I guess.

41:50 >> Config find.

41:51 >> Config find. Right. So this is a global, Like how do my projects get started using hatch for my machine, not a per project deal, right?

42:00 Yeah.

42:00 That's cool. So kind of like get config. Once I set up my machine, if I say, well, I like my virtual environments like this, then I'll be okay. Right?

42:09 Yeah, it makes it easier to distribute tooling. Like for if you're managing like some corporate environment where you're using hatch for everything, then it's nice to have a config that you can modify just as a machine level.

42:24 then every project will do the same.

42:27 Just as a team to say, look, we always want tests.

42:30 We always want this other thing that we call it that we always want this default library.

42:34 Sorry, we want this default license, right?

42:37 We don't want MIT, we want, you know, corp.inc or whatever license that we use.

42:43 So quick question from ZL out there, I think is relevant.

42:46 Is this useful for application development, not libraries?

42:50 Say if I'm building like a flask app or a fast API app, like would, would this be relevant?

42:55 Yeah. So especially with the environment management, that's kind of what applications we use anyway. The missing feature of course, like the other person asked is the lock files.

43:06 For any app you're going to want to be able to reproducibly build the app. So right now there's not a way built in other than using an environment with like pip tools or something.

43:18 So I'm going to add that plugin interface soon.

43:21 Interesting.

43:22 Does pip-tools work with pyproject.toml?

43:24 It does now.

43:24 Yeah, it does.

43:25 Yeah.

43:26 I've only used it with requirements.in and then generate the requirements.txt.

43:30 But yeah, they added that last summer.

43:32 I think I'm so behind the times on this.

43:34 You know, these workflows, I, I, I'm sort of joking, but also not.

43:38 These workflows, you kind of get into like, well, here's how I build these apps.

43:41 Here's how I manage my requirements.

43:43 And then you just tunnel.

43:45 I think a lot of people just go, okay, well, that's working for me.

43:47 I'm doing that.

43:48 You know, I, yeah.

43:50 Yeah.

43:50 Yeah.

43:51 And then, so if I want to like, so for example, when I asked which Python.

43:56 It said the one from homebrew you've installed silly.

43:59 Of course, that's your global Python.

44:01 I want to activate a virtual environment.

44:04 If I can, when I get into like this application mode, I would do a hatch shell.

44:08 Right.

44:09 Yes.

44:09 And because I have an awesome, Oh my posh.

44:12 You can see my prompt here's now taking on the calcy 3.11.2 environment as part of my prompt.

44:18 So, yeah, that's the one.

44:20 So it's, it's working now.

44:22 If I ask just straight up, which Python is that virtual environment one, right.

44:25 And I can do pip list and so on, but there's also ways I think I recall in hatch to like show me my dependencies and get a list of, yeah, show.

44:36 DEP show.

44:37 Yeah.

44:37 Is it showed up?

44:38 Table, table.

44:39 Okay.

44:41 I only have right now two dependencies, pytest and pytest-cov.

44:46 Yeah.

44:46 Interesting.

44:46 Or I could do requirements.

44:49 Yep, and I would spit out the...

44:50 The same but it's not at the table, right?

44:52 Just plain text.

44:53 Yeah, just like requirements.txt.

44:54 Got it. Okay.

44:55 Yeah, excellent.

44:57 What do you recommend?

44:58 So there's the hatch run commands, which will use the environment, or you could just go into the shell and run it.

45:03 Or, if I'm sneaky and I put my virtual environment in there, I might have something that automatically detects that environment and picks it up.

45:13 So for example, PyCharm might go, you know what, I see a VENV folder, we'll use that and, and just grab it and not care about hatch directly. Right. That's actually one of the reasons I was asking about putting it locally is it's kind of a hassle to find that thing and tell your editor, go find it over here. Whereas it automatically finds the top level of project variants, you know?

45:37 Yeah. So you can do, as we talked about sitting in the current directory, like a dot venv and yeah, Python, VS code, they'll, they'll pick it up because it is just a virtual environment at the end of the day. Nothing too special. So yeah, it will work out of the box.

45:53 Yeah. And klutz out there in the audience has got us covered. pip-tools command is pip compile, rebuild output file, such and such pyproject.txt from pyproject.toml. Yeah. Cool. Nice. Yeah. And and variations on that, I suspect.

46:09 So one thing that I was thinking about this that I expected Hatch to do, and maybe it does, and maybe it doesn't, I just don't know, is suppose I want to use requests for calcy.

46:19 Like, calcy can't run locally.

46:22 It needs its calculator API service that it's going to connect to.

46:25 So it needs a request or HTTPS or something.

46:27 Yeah.

46:28 Is there a way with Hatch to say, I have a new requirement, set that up, put it in the PyProject TOML, install it?

46:33 That's going to come with the lock file plugin.

46:36 I figured it wouldn't make sense to add those commands until I knew how locking would work.

46:43 'Cause adding and removing always hits the locking logic.

46:48 And since there wasn't locking, it didn't make sense to me to add those commands.

46:53 So it's going to come soon.

46:55 So right now you would just modify your pyproject.toml until those are added.

47:00 - And then I think there's a way where Hatch looked at your PyProject Toml and said, okay, you're going to need.

47:06 These dependencies, right?

47:08 When you run it, I thought it installed the dependencies that were in the PyProject Toml, even if it won't edit it.

47:15 Like if I put something in there and I try to run it, it'll say, oh, you need this.

47:18 Yeah.

47:18 It'll sync automatically.

47:19 Oh, what command do I use to do that one?

47:21 Either a run command or the shell command.

47:25 I see.

47:25 Oh, even the shell will do it, huh?

47:27 You do hatch run pip list, for example.

47:30 Yep.

47:30 Okay.

47:30 Now in pyproject.

47:32 Toml and like requests maybe too.

47:35 Yeah.

47:36 Right now I have requests and like friends of requests.

47:38 Yeah.

47:39 Yep.

47:39 Yeah.

47:40 Okay.

47:40 That's pretty cool.

47:41 Nice.

47:42 And then I'm looking forward to the lock stuff because I absolutely love pip tools.

47:46 I think it is a glorious way.

47:49 I used for a while, I used panda bot at get up and it drives me crazy.

47:54 It's like so noisy.

47:55 I've got like 30 PRS a week.

47:58 I'm like, you know, could you just.

48:00 package this up and so now I just start periodically, I just go, "Okay, I'm going to use pip tools and just ask, how has the world changed?" and then update my stuff in a more sane way.

48:10 >> It was a bit noisy for us too.

48:12 At work, we have a custom dependency update logic as well.

48:17 I think there is an open feature request for a dependent bot to chunk the updates, but I don't know if it has happened yet.

48:23 >> Yeah, I've seen one of those for a couple of years and there was like 100 plus one.

48:28 Me too, me too, like I gotta review these things.

48:31 (laughing)

48:32 You know what I mean?

48:33 And I don't know if it's there.

48:34 It's not there on my projects, it's still.

48:36 I'll get 20, I'll do a pip compile update and I'll push that and I'll get like 20 messages.

48:42 These are no longer required.

48:43 I'm like, okay, thanks.

48:44 Could you just batch them?

48:47 You know, anyway.

48:48 Okay, so Calcy is coming along here.

48:50 Let's just imagine that it does good stuff.

48:52 I haven't even written any code for it, but it depends upon requests, so that's a start.

48:56 So the next step going kind of forking on the various possible definitions of what packaging is a next step for this thing might be I want to put it on to PyPI or create a wheel I can share.

49:06 So Hatch also supports that, right?

49:08 Yeah.

49:09 So first you have to create the artifacts.

49:12 So you would do Hatch build and that would build Metafault, both the source distribution and the wheel.

49:19 Okay.

49:20 Just like the other tools, there's going to be a dist D I S T that now has those.

49:26 And if you run a hatch publish, that would put it on PyPI by default.

49:32 And it would prompt you for your username.

49:36 I'm not entering that.

49:38 Yeah.

49:38 I don't want to own calc on PyPI.

49:40 No, just kidding.

49:41 But yeah, I don't think I have it configured, so it wouldn't really do anything, but it would, it would go and put it on PyPI, right?

49:46 Yeah.

49:47 Potentially.

49:47 Yeah.

49:48 That's pretty straightforward.

49:49 forward. You also point out in the docs that CI, build wheel and some, and things like TOX, they, you know, you could be the build, just Hatchling could be the build system for that, right?

50:01 Hatch does like a lot. So you can use, you know, parts. Say you wanted to only use environment management to replace like TOX or NOX, you could do that. If you wanted to only use Hatchling with like CI build wheel or other tools, you You could do that.

50:17 If you wanted to only use the version management, you could do that.

50:21 It's kind of choose whatever you want.

50:24 Yeah, you're not locked in.

50:25 - Yeah, so the last thing I could do is publish, but I'm not really gonna go.

50:30 - Yeah, yeah.

50:31 - There's also a way to set in the config file.

50:33 You said that if I set into the config file under the publish index, disable true, well, you can make it confirm rather than just straight up publishing it, right?

50:43 - Yeah, that was a feature request.

50:44 Yep, so.

50:45 - Yeah, cool.

50:46 Another thing that I've always stumbled on when I do this, at least with Twine, is I'll have some project, I've done this, I've published a version, later I'll come back to it, I'll make some changes, I'll increment the version.

50:59 I used to have to do that manually, but now I can just do a hatch version and then something like, I could build one again, minor.

51:08 There we go.

51:11 It'll automatically change it and that changes the code, which is great.

51:13 So now if I do a hatch build, which is really nice, it'll create a new one.

51:19 But if I look in my project, I've got the old one and the new one and you can't republish the old one, I don't think.

51:24 So what happens if I just say publish now and I've already got 0.1.0 out there?

51:29 Yeah, so you can do hatch build -c for clean, and it should clean it first.

51:36 Okay, that's cool.

51:37 Because then I can just say hatch publish and not worry about conflicts.

51:40 that exists already on PyPI, it will ignore us.

51:44 It'll put a warning, but it won't fail the command.

51:48 I think Twine by default does fail.

51:50 - I think it does as well.

51:51 - And has a pass if blank.

51:52 So I do the inverse because that was frustrating to me too.

51:56 So I do the opposite, yeah.

51:58 - Perfect, I love it.

52:00 Okay, yeah, that's a really cool aspect.

52:03 And so, yeah, that was, I guess, walking through that.

52:08 I think it was neat to just kind of explore it together.

52:09 So thanks for talking me through that.

52:11 - Yeah, the past month I've been pretty busy at work, but I'm gonna pick up development again next week for Hatch.

52:18 There's a bunch of open feature requests I have to crank out.

52:23 - Yeah, that's a pretty popular project on GitHub with 3.7 thousand stars.

52:27 So I suspect there's some user feedback.

52:30 - Yep, and so I guess the main next features are the lock file plugin mechanism, And also people are asking about workspaces, which is basically like, kind of like editable installs, but more built in and fundamental.

52:47 So I'm going to add that especially useful for monorepos.

52:51 Oh, right.

52:52 Okay.

52:52 Cause you, you don't necessarily want to hatch build all of Google or, or whatever, right?

52:58 Right.

53:00 Right.

53:00 So workspaces, like a view into the monorepo that I said, I know there's like 500 projects here and they all have their things, but I want the web app and the data layer.

53:11 That's it.

53:12 Something like that.

53:13 Exactly.

53:14 Yeah.

53:14 Okay.

53:14 That sounds useful.

53:16 Yeah.

53:16 And I'm modeling it after cargo workspaces and rust.

53:21 I worked with that recently and I think they have pretty good config and like a model of how local development works.

53:28 So, yeah, that sounds really great.

53:30 I do my preview of what Hatch will look like.

53:33 It's basically cargo workspaces.

53:36 Nice.

53:37 Jonathan out there says--

53:39 that sounds like music to his ears-- definitely waiting on the workspaces feature for our mono repo work.

53:44 Nice.

53:45 And then also Ryan is asking you, any chance there could be a package build target?

53:51 I'm using PEX via TOX currently.

53:54 Yes, that's possible.

53:55 One thing that's great about plugins is I don't have to do every feature.

54:00 anybody can do that.

54:02 So we do have a few to the docs and go to the top, plugins.

54:07 Plugins.

54:07 Where are you?

54:08 Yeah.

54:08 Home.

54:09 Yeah.

54:09 Again, builder builder.

54:11 Yeah.

54:11 And then reference.

54:13 Yep.

54:13 And then, yeah, so known third party.

54:15 So here's some examples of third party builder plugins.

54:19 So the build command that you ran, it has a option to output a target.

54:25 if they named target other than we will and sdist.

54:29 So you can write an arbitrary builder and build those targets.

54:34 So yeah.

54:35 - Okay, it's probably not super hard to do, I'm guessing, to just like basically bundle up the commands to build the pex.

54:41 - Yep, and just implement the interface and that's all you gotta do.

54:44 - Yeah, excellent.

54:45 Good to hear.

54:46 I vote for the lock file management, the dependency management.

54:51 I'm excited to hear that that's coming.

54:52 - Yep, that's coming next.

54:54 Are you thinking of building on something like pip-tools or doing your own?

54:58 I wouldn't feel confident doing my own without feedback from like other folks that have been in this for longer.

55:07 Like Brett Cannon, I think he wrote the first black file pip attempt last year.

55:12 For various reasons it got rejected, but I think his next attempt will happen.

55:18 I just don't know when.

55:19 Excellent.

55:20 a suggestion, a Cython builder would be cool.

55:23 Maybe a MyPYC.

55:25 I don't know, there's a lot of--

55:26 - That one exists actually.

55:28 - Oh, the mypyC one does?

55:29 Okay, I do remember seeing.

55:30 - Yeah, if you go back to the plugins, I know the docs are a lot, sorry.

55:35 Back one, build hook.

55:36 - Okay.

55:37 - And then reference, and it's listed under third-party, hatch mypyC.

55:42 I maintain that one actually.

55:43 - Okay, nice.

55:44 - Actually, I have black builds with that now.

55:47 - Nice.

55:48 What about the Jupyter builder?

55:50 What does that do?

55:51 - So recently, Jupyter switched their entire extension ecosystem to Hatchling, actually.

55:59 So now the standard way to do Jupyter stuff is with Hatchling, and that's the plugin that everything happens with.

56:07 - Nice, okay, cool.

56:08 Probably makes you feel good to see major projects like that using your tools.

56:12 - I'm happy that people are finding value in it, and every time someone says, "Oh, it's so easy to use," Yeah, it makes me happy.

56:20 - Yeah, indeed.

56:21 - I like stuff that can do a lot, but is very simple.

56:25 That's my purpose.

56:26 - Yeah, I think I might play with the config, the global config to see how close I can make it match my current workflow and make it kind of coexist what I'm doing.

56:34 So that'd be fun.

56:35 Awesome.

56:37 All right, well, I think we're about out of time.

56:40 Anything else you want to throw out there while we're talking about your project?

56:44 - If anybody wants to contribute, there's lots of open issues.

56:49 I have had lots of really nice contributors.

56:52 They almost finished adding type hinting everywhere.

56:55 Like in the beginning I had zero type hinting, and then a bunch of contributors helped out with that, and that was almost fully my part.

57:04 So.

57:05 - Cool, yeah, I saw you had 40 contributors, so that's really cool.

57:08 - Yeah.

57:08 - Maybe one other quick comment that I'd like to ask you about here is, I see the domain this is on is hatch.pypa, as in Python Packaging Authority, .io.

57:19 how'd it end up on pypa.io versus yeah, hatch.dev or whatever.

57:25 This is just the standard domain for all the packages.

57:29 So if you type in pip rather than hatch and get rid of the latest part, it'll go right to the pip docs.

57:36 Right, right, right.

57:36 Well, I was thinking more about like, how did it become sort of official?

57:40 I announced hatch 1.0, like the rewrite that happened last year sometime.

57:46 And then the same day, maybe the next day, I forget who, put somebody in the discord was asking if I wanted to join the Pypa and I was like, well, sure.

57:57 That makes sense.

57:58 So then there was a vote on a mailing list and it was unanimous that they agreed and then after I think seven or 10 days, then we transferred the repo and it was hosted on the new domain.

58:12 Oh yeah.

58:12 And it's also under the GitHub organization of Pypa.

58:15 That's right.

58:15 Excellent.

58:16 All right.

58:17 Well, really nice project.

58:19 Congrats on all the uptake and.

58:21 Thanks.

58:21 Yeah.

58:22 It looks like people are enjoying it.

58:23 So two quick questions before you get out of here.

58:26 I didn't get to ask you this on the panel one, because one we're over time and two, there was a bunch of people in order just another 10 minute debate.

58:33 First of all, notable PyPI package, something that you've come across.

58:36 Like, Oh, this is super cool.

58:37 People should know about package X.

58:39 Anything come to mind?

58:40 I guess it's a bit cliche because right now it's actually pretty popular, but I would still evangelize Textool.

58:48 Textool is like a new application for building T-UIs, which is like textual, not user interfaces.

58:56 I've actually been doing a project at work that uses this, and it's very nice.

59:02 It's pretty awesome.

59:03 - It's kind of nuts what this thing does.

59:05 - Yeah.

59:06 - This is like the higher order UI framework built on Rich by Will McGugan and team, and you get like fly out docking panels. It's crazy.

59:17 >> Yeah. It's like if the web could be in a terminal.

59:22 >> True.

59:23 >> Something like that.

59:23 >> It's true. I plan to actually use this for a hatch when I have time.

59:28 On the creation, the interactive creation of a new project, on the left-hand side, you would have the inputs and then it would render the pyproject.toml on the right-hand side and markdown.

59:41 >> Oh, that's super cool.

59:42 >> In a few months.

59:42 Yeah.

59:43 Fun.

59:43 And then if you're going to work on hatch, what editor are you using these days?

59:48 I have PyCharm for large projects when I'm doing like one-off scripts, then VS code.

59:55 Okay, cool.

59:57 All right.

59:57 So this may be a question I got to start asking people.

01:00:00 I don't know.

01:00:00 PyCharm is, and all the JetBrains IDs I believe are starting to promote a, what they call the new UI, which I think is more, much more like VS code.

01:00:11 Are you the old school style or are you the new UI style?

01:00:15 I've not seen that yet.

01:00:16 Actually.

01:00:17 There's a gear in the upper right.

01:00:18 If you click on it, it'll say new UI.

01:00:20 To me, I'm still I'm old school.

01:00:21 I love the old one.

01:00:22 I mean, I'm using PyCharm, not VS code for a reason.

01:00:25 So I don't want it to look more like VS code for my style.

01:00:29 Right.

01:00:29 But I know other people prefer the opposite.

01:00:30 I wouldn't mind using VS code.

01:00:32 There's one missing feature that is like a blocker where I just want to use VS code full time, which is it can't yet do vertical tabs.

01:00:42 There's an open feature for years.

01:00:44 And I guess technically there's some kind of challenge to implementing that.

01:00:49 So right now, if you have like a hundred times, it doesn't look very nice.

01:00:53 It's all horizontal.

01:00:54 It's just a bunch of X's.

01:00:55 Yeah.

01:00:57 I can't select them.

01:00:58 I just closed them.

01:00:59 Yeah.

01:00:59 Yeah.

01:00:59 I got it.

01:01:00 Okay.

01:01:00 Very cool.

01:01:01 All right.

01:01:02 Well, congrats with Hatch and thanks for coming on the show.

01:01:06 - Yeah, thank you very much.

01:01:08 Nice talking to you.

01:01:09 - Yeah, you too, bye bye.

01:01:09 - All right, bye bye.

01:01:11 - This has been another episode of Talk Python to Me.

01:01:15 Thank you to our sponsors.

01:01:16 Be sure to check out what they're offering.

01:01:17 It really helps support the show.

01:01:19 Don't miss out on the opportunity to level up your startup game with Microsoft for Startups Founders Hub.

01:01:24 Get over six figures in benefits, including Azure credits and access to open AIs, APIs.

01:01:29 Apply now at talkpython.fm/foundershub.

01:01:32 Take some stress out of your life.

01:01:34 get notified immediately about errors and performance issues in your web or mobile applications with Sentry.

01:01:40 Just visit talkpython.fm/sentry and get started for free.

01:01:45 And be sure to use the promo code, talkpython, all one word.

01:01:49 Want to level up your Python?

01:01:50 We have one of the largest catalogs of Python video courses over at Talk Python.

01:01:54 Our content ranges from true beginners to deeply advanced topics like memory and async.

01:01:59 And best of all, there's not a subscription in sight.

01:02:02 Check it out for yourself at training.talkpython.fm.

01:02:05 Be sure to subscribe to the show, open your favorite podcast app, and search for Python.

01:02:09 We should be right at the top.

01:02:11 You can also find the iTunes feed at /iTunes, the Google Play feed at /play, and the Direct RSS feed at /rss on talkpython.fm.

01:02:20 We're live streaming most of our recordings these days.

01:02:23 If you want to be part of the show and have your comments featured on the air, be sure to subscribe to our YouTube channel at talkpython.fm/youtube.

01:02:32 This is your host, Michael Kennedy.

01:02:33 Thanks so much for listening.

01:02:34 I really appreciate it.

01:02:35 Now get out there and write some Python code.

01:02:38 (upbeat music)

01:02:40 [Music]

01:02:55 (upbeat music)

Back to show page
Talk Python's Mastodon Michael Kennedy's Mastodon