Learn Python with Talk Python's 270 hours of courses

#371: pipx - Installable, Isolated Python Applications Transcript

Recorded on Wednesday, Jun 22, 2022.

00:00 I'm sure you're familiar with package managers for your OS, even if you don't use them.

00:04 On macOS, we have Homebrew, Chocolaty on Windows, and Apt, Yum, and others on Linux.

00:09 But if you want to install Python applications, you typically have to fall back to managing them with pip.

00:15 Maybe you install them for your account with the --user flag.

00:19 But with pipX, you get a clean, isolated install for every Python application that you use.

00:26 And if you distribute Python apps, pipX is definitely worth considering as a channel.

00:30 On this episode, we have Chad Smith, creator of pipX, to tell us all about it, how it works, and how to use it.

00:37 This is Talk Python to Me, episode 371, recorded June 22, 2022.

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

01:01 This is your host, Michael Kennedy.

01:03 Follow me on Twitter, where I'm @mkennedy, and keep up with the show and listen to past episodes at talkpython.fm.

01:09 And follow the show on Twitter via at Talk Python.

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

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

01:23 This episode is brought to you by Mergify.

01:26 Take control of and automate your GitHub workflows.

01:29 As well as the Python at Scale Summit conference being held in October.

01:34 Reconnect with your data science colleagues this year.

01:38 Transcripts for this and all of our episodes are brought to you by Assembly AI.

01:42 Do you need a great automatic speech-to-text API?

01:44 Get human-level accuracy in just a few lines of code.

01:47 Visit talkpython.fm/assemblyai.

01:50 Chad, welcome to Talk Python to Me.

01:52 Thanks, Michael.

01:53 It's fantastic to have you here.

01:55 I and many listeners are such a fan of PipX and really just love to have that tool around to allow us to use Python libraries and commands like applications.

02:05 And it's going to be so fun to talk about.

02:07 And if you're out there and you haven't heard of PipX, you're in for a treat.

02:10 So before we get to that, though, let's start with your story.

02:12 How do you get into programming in Python?

02:14 So I got into programming back when the internet was kind of like really popular with GeoCities, like early web development type stuff.

02:21 This is the time when people had like the animated digging Giphy.

02:24 Yeah.

02:25 And like a lot of sites were still permanently under construction.

02:27 Yes.

02:28 And flashing text and stuff like that.

02:30 So I thought that was pretty cool.

02:32 I messed around with some GeoCities pages.

02:33 I wrote a little bit of JavaScript to where you can like hover over text and it will change the image and stuff like that.

02:39 And I kind of messed around with web pages for a while, but I didn't really get too serious with programming, with web development until later, much later.

02:46 So when I got more into programming was in college.

02:49 I went to, I got a degree in aerospace engineering.

02:52 And so we did like kind of like scientific computing.

02:54 We used MATLAB a lot.

02:56 So I used a lot of MATLAB in college.

02:58 And then in my first job, we did a lot of MATLAB.

03:00 So in the aerospace industry for making airplanes and like control systems, we use MATLAB a lot.

03:06 And so I kind of started hacking out MATLAB and making like a bunch of programs and automating stuff, not really going into other programming languages, which were probably better suited for the job.

03:17 I just kind of did everything in MATLAB.

03:19 That's the way I think most people do it is they have a set of tools to pick from that they know how to work with them.

03:25 And they're like, well, which one of these is going to be best?

03:27 And if your programming environment is MATLAB, then, you know, that's not a terrible choice, really.

03:31 Yeah, I got like really into programming MATLAB and then eventually ended up at a job where I got to start doing a little Python.

03:37 Nice.

03:37 What kind of airplanes were you working on?

03:39 First job was on the space shuttle, which was, which has been retired.

03:43 Then I worked on like, I worked for Boeing.

03:44 Of course.

03:45 Oh, that's fantastic.

03:46 Yeah, I worked from the 747, 787.

03:48 So I worked for Boeing.

03:49 So Boeing worked on the space shuttle and as well as obviously a bunch of other planes.

03:54 And then none of the Python work was there, though.

03:56 And the Python stuff started at a startup funded by Google co-founder Larry Page.

04:02 So it was an EVTOL, electric vertical tick off and landing plane.

04:05 So it's like a small plane.

04:06 It was a startup.

04:07 It was a small company.

04:08 And we needed like basically some tools to be made.

04:12 And I didn't really know Python, but I like to just take on new challenges and learn new things.

04:17 So my first experience with Python was with Python 2 and working on a Django app.

04:21 It was an app to track all of the parts and weights and moments of inertia of the aircraft.

04:27 Another project was like called a protocol compiler.

04:30 So all the C code that ran on the avionics was a lot of it was generated.

04:34 A lot of the inter device communication was generated from this common protocol definition.

04:40 And so this was all written in Python.

04:42 So we could generate safety critical C code.

04:44 We could generate documentation about the code.

04:47 We could generate tests where we had like hardware in the loop tests.

04:50 And so that was where I started to run into issues with challenges with packaging and getting dependencies installed on folks computers.

04:57 Because if you wanted to build the flight code, you needed to have a bunch of packages available.

05:02 Right.

05:02 And so, you know, you had to have maybe some foundational thing in order, some libraries and other things.

05:08 And you probably didn't want to teach necessarily C people how to set up Python and virtual environments and all that kind of stuff, right?

05:14 Exactly.

05:14 Or documentation writers.

05:16 Yeah, exactly.

05:17 And yeah, it was a small company.

05:19 So there wasn't really a Python expert in house.

05:20 So we kind of made a lot of the mistakes and I had to go into the infrastructure side too and try to build all that out.

05:27 And so, you know, we started out with, I think we started out with pseudo pip install and that was how we got our things installed.

05:33 Yeah, for sure.

05:34 Well, you talk about this, the small business or a small company you're at and sort of bouncing off the walls and just figuring it out yourself.

05:41 But you were also at Boeing, which is a non-small company for my looking in from the outside.

05:46 Yeah.

05:47 I know a lot of people, they definitely dream of or look to get hired at these really large companies.

05:53 And yeah, I feel like there's a huge advantage to at least spending a little time in a company like this VTOL one you talked about where you're taking on a lot of responsibilities and you're kind of working together to figure out stuff rather than slot it into like a narrow slice of what's getting done.

06:08 What do you think?

06:09 What was your experience in those places?

06:10 Well, so Boeing did offer opportunities to let you kind of like improve processes and stuff like that.

06:16 But the scope of what you're working on at a small company, trying to build a similar product.

06:21 I mean, you have a smaller team with no like legacy or decades of history building stuff.

06:27 You're kind of just inventing it as you go.

06:28 So yeah, there's a ton of stuff to experiment with and take on and learn from.

06:33 Yeah.

06:33 Cool.

06:34 How about now?

06:34 You're at another small company, right?

06:36 Yeah.

06:37 I'm at a small company called Meta.

06:38 I work for the, I work for Reality Labs and I work on developer infrastructure here as well.

06:44 I work on things like language services, debuggers, and VS Code, VS Code extensions.

06:50 Cool.

06:51 Do you have any exposure to the Cinder project or any of the stuff going on over there?

06:55 No, I'm aware of it.

06:56 I think it's super cool, but that's an Instagram thing really.

06:59 And so it's not really something that I use day to day.

07:02 Well, it looks like it's going to become a Python thing in little bits and pieces.

07:05 Yeah.

07:06 The pieces of it are being pulled over.

07:08 Like we just talked about PEP690 and lazy imports, and there's a couple of other things

07:13 people are working to move in.

07:15 So not the whole thing, but some of those features and improvements make it to all of us.

07:19 Yeah.

07:19 That's the great thing about Python is if you come up with a good idea, the community is

07:23 very open and willing to adopt new ideas.

07:26 The best ideas win and can be continuously improving the language.

07:30 Yeah.

07:30 That's pretty fantastic.

07:31 So let's start our conversation here at a little bit higher level than just PIPX.

07:37 And let's just talk about packaging a little bit.

07:40 So let me switch over here to this project.

07:42 So you have over at chadsmith.dev, which is a great domain name.

07:47 And I'm impressed with a name like Chad Smith that you can get it just straight up as your

07:51 domain name.

07:52 Because as Michael Kennedy, all the Irish politicians are all over me.

07:55 I got to go with some crazy variation to come up with it.

07:59 But yeah, that's cool.

08:00 That's a great domain name.

08:01 And over there at slash python-packaging, you've got the big list of Python packaging and distribution

08:06 tools.

08:07 You want to tell us about this?

08:08 Kind of gives you a high level of like, what are the options, right?

08:11 Yeah.

08:11 So a lot of times questions come up about what tools are out there, which tools do what.

08:17 You know, it's a big world in the packaging, in the packaging, in the Python packaging world.

08:21 And I wanted to make something that was not opinionated and just kind of factual.

08:25 Like here's some data, here's some information about these.

08:29 You can decide for yourself.

08:30 It's not trying to persuade you to use this.

08:31 It's not like saying this is my tool.

08:33 This one's the best.

08:33 And this came about from PIPX's documentation where one of the other questions on PIPX was

08:38 like, what is it and how does it compare to other things?

08:40 So I had kind of a list on the documentation and it kept growing.

08:44 And I was thinking, you know, this could be its own thing because I don't want to PIPX

08:47 documentation too big.

08:49 Make it a survey of all the other things that it competes with or could have been put alongside,

08:54 right?

08:55 Yeah.

08:55 So this is an interactive web app table type thing.

08:59 And it pulls data from GitHub's GraphQL API.

09:03 And it lets you kind of like select different features and filter on those.

09:07 You can compare and group tools together.

09:10 So on the top left, you'll see there's like a bunch of little blue words with blue backgrounds

09:15 and you can click on those.

09:16 Yeah.

09:17 And if you click on them, then it'll filter down the table.

09:19 And so if you want to find tools that have, I can install and publish, you can click on

09:23 like install CLI apps and also publish, publish packages.

09:27 Nice.

09:27 This is a great little UI.

09:29 It reminds me of an app I wrote once and I'm having nice nostalgia here.

09:33 It's cool.

09:34 So you can sort of click on these little categories or filters and turn multiple ones on and off.

09:39 So if I want virtual environment management that can install libraries, well, apparently

09:43 there's none of those.

09:44 But if I want to build packages and install CLI apps, well, I guess PDM is my choice, huh?

09:50 Right.

09:51 That's cool.

09:51 So maybe one thing that we could do that would be nice is maybe we could go through and highlight

09:55 some of the more notable packaging solutions or options as we go through here.

10:00 You know, PipX being one of them, we'll get to that a bunch more, but want to maybe give

10:05 us a bit of a rundown?

10:05 Like probably the first really notable one is Conda.

10:08 People are super familiar with that, right?

10:10 On the data science side.

10:12 Yeah.

10:12 So Conda is kind of like a more ambitious way to create environments and it kind of

10:19 makes its own ecosystem.

10:20 I personally haven't used it, but I know it's pretty popular, like you said, with a scientific

10:24 community.

10:24 So it also can be used to make C libraries too.

10:27 Interesting.

10:28 Yeah.

10:28 It's certainly the claim to fame of Conda and Anaconda and Miniconda, all those things

10:33 is you don't have to have the build tools for all the libraries, the transitive closure

10:38 of the libraries you want to use, right?

10:40 My understanding is it's its own packaging system.

10:42 Like you don't pip install from it.

10:44 There's some other parallel ecosystem.

10:46 Right.

10:46 Exactly.

10:47 And I feel like to some degree with wheels, we're a little bit closer than we used to be

10:52 with pip directly, right?

10:54 pip install wheel can just drop in a thing, whereas previously stuff had to happen on your

10:58 machine to finalize that package.

11:00 Yeah.

11:00 Wheels are specific to your Python version, your operating system.

11:05 And so, yeah, that can just be basically unzipped and used.

11:08 Yeah.

11:08 That was fantastic, except for the first couple of weeks of the M1 platform, the Apple Silicon

11:14 M1s.

11:14 You try to install something.

11:16 Nope.

11:16 We don't have a wheel for that platform.

11:18 What do you mean you don't have a wheel?

11:19 Come on.

11:20 I think that's pretty far in the past now.

11:22 I haven't run into that problem for a long time.

11:23 Cool.

11:24 Another one on here that's clearly pretty popular and in this C generating native code category

11:31 is Cython.

11:32 Yeah, Cython is super interesting and it takes advantage of one of the pretty cool features

11:38 of Python itself.

11:39 So Cython can generate C code from your Python code and it generates shared objects and shared

11:47 objects are able to be imported directly from Python.

11:49 So you can make a basically like a wheel that is native code built from your Python code.

11:54 And if you have code that is really run really frequently, like a really hot path, that Python

12:00 is just a little bit too slow for you.

12:02 You can really easily use Cython to convert that into C and make a shared object and then just

12:09 use that, but just that module or just that function that you wanted to speed up.

12:13 There's some interesting examples of that.

12:15 For example, UV loop, which is the fast drop in replacement for asyncio, right?

12:21 That was written in Cython and built on top of libuvc library, I think.

12:26 Right now, here's one of those tight loops where this is the while true or the for in

12:32 loop that does all the magic, right?

12:34 And so doing something like this makes a lot of sense.

12:37 Absolutely.

12:37 Yeah.

12:38 I was surprised how easy it was to use Cython.

12:40 You can just basically run it, point out a file and it just converts it to C.

12:45 And you can import it too.

12:46 It makes the shared object.

12:47 It's just kind of like you just run the command and it's just magically turns into something.

12:51 Hopefully it all works, but it turns into something that runs a lot faster.

12:54 Yeah, it really is neat.

12:56 And if you use the Python type hints, it can get even a little bit better.

12:59 Yeah.

13:00 Or if you go farther, you can import the Cython integer instead of just a regular int and so

13:06 on.

13:06 Yeah.

13:06 And now Cython has typing in Pythons.

13:09 So Cython also has its own kind of parallel language where you write like PyX file and you

13:14 have Cython annotations.

13:15 But now with type hints becoming more prevalent in Python itself, there are also Cython type hints,

13:21 which allows you to write just straight Python code, but Cython still recognizes how to,

13:26 convert it to a statically typed C type.

13:29 Right.

13:29 I think that makes it way more approachable for many people because they don't feel like

13:32 they have to go learn something different.

13:34 They're like, well, if I just put type hints on this, maybe different type hints.

13:37 Yeah.

13:37 And we're good to go.

13:37 Yeah.

13:38 Which is pretty cool.

13:38 Yeah.

13:39 All right.

13:39 That question from the audience from Juergen.

13:41 Hey, Chad.

13:42 What about Buildout?

13:43 Made up your mind on whether to include it?

13:45 What's the story with Buildout in this?

13:48 On the Python packaging table, there were some suggestions in the issue tracker.

13:52 And one of them was around Buildout.

13:54 And it was something I hadn't heard of before.

13:57 I'm still considering whether to add that or not.

14:00 I think I will.

14:01 Leaning towards yes.

14:02 Okay.

14:02 I don't think I've done anything with Buildout.

14:04 Okay.

14:05 Very nice.

14:05 And also, I saw that Py2App could get...

14:09 I don't think Py2App was there, was it?

14:10 It wasn't.

14:11 Yeah.

14:11 So what's the criteria for being on that list, I guess?

14:14 Yeah.

14:14 I just kind of made it as a...

14:16 Started just as the comparison to PIPX where people might be confused or wonder which one

14:21 to choose.

14:22 And then it's kind of just grown organically, just things I thought were interesting or relevant.

14:26 I think they should be something that is still...

14:30 So it's something that people would want to use because there's a lot of changes in the

14:34 packaging landscape and there's a lot of stuff that kind of gets left behind that you really

14:37 wouldn't want to use anymore.

14:38 There's new tools being made.

14:40 There's new standards being defined.

14:41 So I want it to be something that's kind of like modern, relevant, something that's like

14:45 encouraged to be used.

14:46 I was concerned it was a little bit like maybe older and like I hadn't heard of it and you

14:52 haven't heard of it.

14:53 So I wasn't really sure how, you know, if it was something that we should still encourage

14:57 folks to use or not.

14:58 Yeah.

14:59 Here's an interesting...

15:00 Have you checked out the PSF developer survey results this year?

15:04 I have not.

15:04 Yeah.

15:04 So they have a section on basically which tools related to packaging do you do to use?

15:10 And they break it down by popularity, which I thought was pretty cool.

15:13 That's really interesting.

15:14 Yeah.

15:14 So for people just listening, it's 81% of the people say they use pip and then 32% of people

15:21 use VNV.

15:21 I feel like that's pretty low.

15:23 Honestly, it should be higher than what's going on there.

15:25 But you've got 30% of people use containers, 23% use virtual ENV, and then 22% is condo.

15:32 We've got poetry, PIP, ENV, Afflit, PDM, and others are like way down, way down in the list

15:38 there.

15:38 Yeah.

15:39 So anyway, does that strike you as what your mental model you had in mind a little bit?

15:43 Yeah.

15:44 Roughly.

15:44 There's a few surprises in there.

15:46 But I think all those should be in this table.

15:49 If they're not, I'm going to have to check out that list and update the table.

15:52 Sure, sure.

15:53 Well, you know, maybe not the container stuff, right?

15:55 Because that's kind of just like I have a virtual machine.

15:57 I mean, virtual machines are also in there, right?

15:59 It's like, which I think means I have a virtual machine, so I don't care if I just trash it

16:03 and just bust its system, like customize its system Python.

16:06 This portion of Talk Python to Me is brought to you by Mergify.

16:12 It's an amazing tool to make you and your team way more productive with GitHub.

16:16 Mergify is all about leveling up your pull requests.

16:20 Some of the features include automatic merges.

16:22 You explain the conditions for an automatic merge and Mergify will take care of merging the

16:27 pull requests as soon as it's ready.

16:29 Automatic updates.

16:30 They merge your pull requests serially on top of each other, so there's no way to introduce

16:36 a regression.

16:36 Merge queues.

16:38 Merge the urgent pull requests first.

16:41 Organize your PR priorities as you wish, and Mergify will merge them in that order.

16:45 Backports.

16:46 Mergify will even copy your pull requests to other branches once the PR is merged, shipping

16:52 your bug fixes in multiple branches automatically.

16:55 Mergify features allow you to automatize what you would otherwise have to do manually.

17:01 By saving time, you and your team can focus on projects that matter.

17:04 Mergify is coordinated with any continuous integration and is fully integrated into GitHub.

17:09 They even have a startup program that could give your company 12 months of credit to leverage

17:15 Mergify.

17:15 That's up to $21,000 in value.

17:18 Start saving time today by visiting talkpython.fm/Mergify to sign up for a demo and get

17:25 started, or just click the link in your podcast player show notes.

17:28 Thank you to Mergify for sponsoring the show.

17:30 Thank you.

17:30 For me, when I set up my servers, I don't do that.

17:35 I actually create a virtual environment for the apps running on that server, or maybe multiple

17:39 ones, but often it's just running one service.

17:41 So I just create a virtual environment for it, just for the isolation alone.

17:46 So it doesn't say, well, you can't use this version of some library because it's being

17:49 used by some part of the system.

17:51 You can really cause yourself huge headaches messing with parts of the system.

17:55 Like one time, I think I tried to rename Python.

17:57 I think I repointed my Python 3 alias to a different, like a newer version of Python 3,

18:02 because I wanted to use, I wanted that to just be what it used.

18:05 And pretty sure my computer didn't start after that.

18:07 Yeah.

18:09 While I just have this page up, I just want to also show that PipX does show up over here

18:14 on tools for installing packages instead of managing it.

18:17 And yeah.

18:18 Oh, very cool.

18:18 Coming along there.

18:19 Pretty cool.

18:20 By the way, there is a PEP I saw around not clobbering system installs, where you have like

18:25 Ubuntu managing its own Python packages, and you install to it, or you uninstall something

18:31 and kind of like mess up your whole system.

18:33 There's a PEP out there to address that and to not mix things in there.

18:36 Oh, that's cool.

18:37 I feel like almost Ubuntu and those different systems could say, we're going to have our

18:41 own isolated environment for our stuff.

18:43 And what you want to do, even if you just run Python straight, that's going to do something

18:47 else.

18:47 But yeah, I don't know.

18:49 I don't know the mechanics of making all that happen.

18:51 There's a lot of pieces involved there.

18:52 Yeah.

18:52 Yeah.

18:52 The isolation is definitely useful.

18:55 Okay.

18:55 Back to the build stuff.

18:57 Maybe there's a couple of others here.

18:59 Like we've got the sort of what I would call pip alternatives.

19:03 We've got FLIT and Poetry, right?

19:05 Those are maybe, yeah, FLIP and Poetry and PIP, E and V. I guess those are all in a similar,

19:11 I know that I might be painting that with too broad of a brush, but they're all about installing,

19:15 working with your environments, installing stuff into your environments for apps you're

19:19 building, right?

19:20 Yeah.

19:20 And PyFlow as well.

19:21 And Hatch.

19:22 There's quite a few.

19:23 Yeah.

19:23 I'm not familiar with Hatch.

19:24 Tell me about Hatch.

19:25 I have heard Hatch mentioned, or I think I've seen it around for a while.

19:28 I never really used it.

19:29 But then the creator of Hatch recently added a pull request to PipX to use the Hatch backend.

19:36 So with PEP 5.17 and 5.18, you can basically anything you want, install, build your wheel,

19:43 build wheels.

19:45 So you can have different backends to build a wheel.

19:48 So Hatch has one called Hatch.

19:49 Right.

19:49 This is actually now in the packaging, the Python packaging documentation.

19:53 Like if you go to like the Python packaging website, like I think it's packaging.python.org,

19:58 there's instructions on how to like build, to build a package, to distribute it.

20:02 And it uses the Hatch link backend, which is a big achievement now.

20:07 It's no longer telling you to use setup.py, but it's telling you to use this new tool called

20:13 build.

20:13 Right.

20:14 Which is also on your list right at the top.

20:15 Yeah.

20:16 And it's alphabetical.

20:17 So yeah.

20:18 Well, it wins with, I guess the A, A, A, A, A, V and V is maybe got a spot to still take

20:24 the top notch there, but.

20:25 That's a good idea.

20:26 Nice.

20:26 You do also have things like GitHub stars and stuff.

20:29 Can you sort by them?

20:30 Yeah, you can, right?

20:31 I just added the star emoji and I think it screwed up the sorting.

20:34 So I'll have to work on that.

20:35 Oh, it sorts by alphabetical then with the start of the star.

20:38 Yeah.

20:39 Okay.

20:40 The challenges we run into.

20:41 Yeah.

20:41 Yeah.

20:42 So this is really cool.

20:43 Anything else you want to give a shout out to while we're here before we move on?

20:46 Py03 is super cool.

20:48 I played around with that.

20:49 So Py03 is a way to call Rust code from your Python code.

20:54 So kind of similar to Cython, except it doesn't generate Rust code for you.

20:58 You just, you have to have something already built in Rust, but it's pretty easy to use.

21:02 There's a really popular Rust tool called RipGrep, which is like grep, but rewritten in Rust

21:06 with a nice API and it's super fast.

21:09 And one thing I tried just to kind of like learn Rust and learn Py03 was to write an API in Python

21:17 that called into the RipGrep Rust code.

21:20 Right.

21:20 Okay.

21:21 Cool.

21:21 And that actually worked pretty well.

21:22 I was pleased with the development process and how fast it all ran.

21:28 Nice.

21:28 All right.

21:29 Let's see.

21:29 One more bit of follow up on this that Juergen says, Tox will also use Hatchlane with version four, which is pretty cool.

21:36 Nice.

21:36 Yeah.

21:37 I think that it's probably going to gain a lot more traction.

21:39 Yeah.

21:40 It sounds like I need to learn about Hatchlane and Hatch.

21:42 Pretty cool.

21:43 Another thing that's interesting here that is sort of in the same space that we could talk about

21:48 is PEP 582.

21:51 To me, PEP 582 feels a lot like node modules for Python.

21:55 Sort of that.

21:56 Where is the, what is it?

21:58 Project.json and then the node modules folder next to it, right?

22:02 There's a folder and it has a name.

22:04 That's where your packages get installed to.

22:07 And if you run Python commands below it, it will sort of traverse the directory up looking for that

22:13 to find its effective virtual environment instead of the traditional virtual environment behaviors we all know.

22:18 Right?

22:19 Right.

22:19 Yeah.

22:20 Yeah.

22:20 What are your thoughts here?

22:21 I sort of stumbled across this.

22:23 I don't remember how I found it, but when I saw it, I was like, oh my gosh, this is incredible.

22:28 I can't wait for this to land.

22:30 I'm a big TypeScript developer.

22:31 I like TypeScript, I like JavaScript.

22:33 So I can kind of compare the two because I do a lot of work in both.

22:36 And when I saw this, I was really excited.

22:37 Right.

22:38 So you're like, this is the node version for Python.

22:40 Yeah.

22:40 There's a lot of headaches with global installs and globally installing packages and conflicting with the OS.

22:47 And so having that extra step to always activate a virtual environment or create one or delete one or recreate a new one, it can get tedious.

22:54 And so, and it's also a bit, it's part of the environment, right?

22:57 Like Python packages is this file on a file system.

23:01 You know, it's there.

23:02 If you want to start over, you just RMRF the folder and you can start over.

23:07 So when I saw this, I was really excited and acceptance of it would be imminent and we'd be using Py packages very soon.

23:13 I did too.

23:14 Like, oh, this, we're, the next release, the world is different, right?

23:18 Yeah.

23:18 And so you can see on the, right.

23:21 Yeah.

23:21 And yeah, it says this is targeting version 3.8.

23:23 It's still in draft status.

23:25 And that was 2018.

23:26 So it's four years ago.

23:28 So one thing I want to mention is, as you mentioned, this is like node modules for Python.

23:33 And one of the authors of the pet mentioned that he, he doesn't want folks to think of it like that.

23:38 Although it's not a bad analogy, but it's more like an auto activated virtual environment or automatically recognized.

23:44 So he wanted to think of it like that because he didn't want to have nested Py packages where we can have this complicated nesting of each package has its own Py packages.

23:54 Like a fallback as you go up and yeah, yeah, yeah, yeah.

23:57 I hear you.

23:58 But to me, it seems like it would simplify a lot of stuff.

24:00 For example, if I have a cookie cutter template and I want to just make sure that that project has its own environment, the cookie cutter could just create this folder at the top level and you're kind of good to go.

24:10 You know what I mean?

24:12 You don't have to do a bunch of virtual environment stuff.

24:14 It just, that's the one, right?

24:16 Yeah.

24:16 If you've got working with people who are new to Python, you can just say here, unzip this and run it and you know, it'll start out empty, but maybe the first step is to verify all the stuff is there, but you don't have to, you know, there's just that, that bootstrapping to get started, which as you gain experience, it's no big deal.

24:32 But I often encounter people who are new to this and they kind of bounce off it, which is unfortunate.

24:37 When you come across a project or when, especially someone newer to the language comes across a project and they see instructions are pip install this thing, it's really kind of a loaded instruction to give someone because you might be basically breaking things in the process.

24:52 You might be setting yourself up for some kind of failure.

24:54 Right.

24:54 It could get installed to their system.

24:56 They might not have permission to install it to the system.

24:59 There's a lot of stuff going on there.

25:00 It also might install a version of a package that another tool requires a different version of because it'll just kind of update it with what it needs.

25:07 If there's an outdated version or something, it'll just give you a newer version, which may inadvertently break some other tool that depends on that older version for some reason.

25:14 Right.

25:14 And then all of a sudden your fail to ban or your firewall or something stops working.

25:18 You're like, why did that stop working?

25:19 Or glances or some other tool.

25:21 You're like, I thought that was part of my machine.

25:24 Now it doesn't work anymore.

25:25 And, you know, your little test project or tutorial broke it.

25:27 Right.

25:27 Yeah.

25:28 That's probably suboptimal.

25:29 Yeah.

25:30 So this was exciting to me because, you know, you could have pip install something and it would go to this PyPackages directory potentially.

25:36 You wouldn't really have to worry about any other side effects or any kind of environment that you're affecting.

25:41 Maybe someday.

25:41 Yeah.

25:42 Not for the moment.

25:42 Yeah.

25:43 Well, we do have this other tool called PipX that does manage this somewhat for a certain class of problems.

25:50 Right.

25:50 But this is more for building packages and applications and stuff.

25:54 Not so much external tools, but still.

25:57 Yeah.

25:57 I think there are different use cases.

25:58 Because I think this one's more for libraries, building your library or not necessarily the app.

26:04 Yeah.

26:04 Well, you pointed out some implementations or experimental things going on with this one.

26:10 So let's see here.

26:11 Yeah.

26:12 So you got PyLock here.

26:13 This is you, right?

26:14 Yeah.

26:15 That's fine.

26:15 So PyLock is a drop-in replacement that imports packages from this directory.

26:20 And it's like an experimentation or an experimental implementation of this, right?

26:24 Right.

26:24 Yeah.

26:24 So I called it Python loc was the idea, like local, loc stand for like.

26:29 Location.

26:29 Yeah.

26:29 It stood for like local packages, I was thinking.

26:31 I don't know.

26:32 The name's still a thing could be revised, I guess.

26:35 But I saw the pet, but I thought it was super cool.

26:37 And I thought, hey, maybe I can hack something together and let people try it.

26:40 Because I think trying, discussing how something might work and actually using it is kind of like

26:45 looking at a picture of somewhere you want to take a vacation and actually going there.

26:48 You know, it's like going to a place versus just kind of like hearing description of it.

26:52 So if we make something we can play around with, you can see, oh, this, I thought this would

26:56 be cool, but it actually is way harder to use.

26:58 Or maybe it's exactly what I thought I wanted and it's great.

27:01 And, you know, let's accept the pet.

27:02 So I made this just as a way for folks to easily experiment with this kind of workflow.

27:07 Yeah.

27:08 Okay, great.

27:09 And people can play with it.

27:10 Although, who knows where this idea is going?

27:12 I still think it has legs, but yeah, it's been chilling for a while.

27:15 And then there's PDM.

27:17 I've heard of people using PDM and does this follow?

27:20 Yeah, it seems like it follows the same idea, right?

27:22 Tell us about PDM real quick.

27:24 Yeah.

27:24 So PDM is kind of like poetry.

27:25 I mean, it uses PEP 5A2.

27:27 So it uses the PyPackages directory.

27:30 But yeah, it's similar in the idea of poetry or similar tools like PIPenv and all the ones

27:37 you mentioned, PyFlow.

27:38 So it creates and modifies the PyProject.toml file.

27:43 It can add its own metadata to it.

27:45 It can build packages.

27:46 It can publish packages.

27:48 I'd have to consult that table.

27:51 But yeah, I think it's kind of like an all-in-one tool.

27:53 And that also uses PEP 5A2.

27:55 Right, exactly.

27:56 So it does a lot more.

27:58 But it does happen to also use this idea, right?

28:00 Right.

28:01 And in the discussion on...

28:03 In the PEP 5A2 discussion on where all the folks are discussing the pros and cons, the developer

28:09 of PDM mentions that, like what his experience was with it, some of the tweaks he had to make

28:15 to the PEP to make it work for him.

28:17 And I saw that there was some interest in it.

28:21 And also PyFlow is another tool similar to PDM.

28:24 It's written in Rust.

28:25 But I saw, I think Brett Cannon was interested in working with those two folks to maybe flesh

28:31 out PEP 5A2 a little more because they have some real world experience.

28:34 Okay.

28:34 Interesting.

28:35 Yeah.

28:35 It doesn't sound like the PEP is dead.

28:37 It sounds like it's stalled is more maybe how I understand it.

28:41 Yeah.

28:41 I think one of the...

28:42 So there were two original authors.

28:44 One of them is no longer interested in pursuing it.

28:46 But the other is, I think he's just been a little bit busy and hasn't had time to dedicate

28:50 to it.

28:50 But I think there's still potential for it.

28:52 Sure.

28:52 Okay, cool.

28:54 Well, let's move on to the star of the show, PipX.

28:57 How do you tell people about PipX?

29:00 PipX is a tool to install and run applications that happen to be written in Python.

29:07 I was going to say, too, I think of it as like Homebrew or AppGet or Chocolaty or one of these

29:13 package managers where I just want to get this command or this application on my computer.

29:18 I don't really care what it's written in.

29:20 It's probably written in something tough that I have to install weird dependencies for or

29:25 I got to have some odd compiler and I don't want to deal with it.

29:28 I just want to...

29:29 I know it if I type brew install handbrake or something, like I'll have that.

29:33 Right?

29:34 That's the way I see PipX is there's all these cool commands and CLIs and utilities in Python

29:40 and they just happen to be in Python, right?

29:43 Like we as Python developers care a lot that that's the case, but we just want the commands,

29:46 right?

29:47 And with PipX, you can just type PipX, say, install pytest or PipX install Glances or some

29:54 other cool library.

29:55 And sure enough, you'll have it installed, right?

29:57 Yeah, that's the idea.

29:58 One of the goals is to take away difficulty for end users to install a tool.

30:03 A lot of times the instructions are like, you know, install with Pip.

30:07 And like I said, you can have problems with that.

30:09 That's kind of a loaded instruction sometimes to give people, especially if they're not Python

30:12 developers.

30:13 If you as a Python developer, if you see that you wouldn't really have trouble managing that.

30:17 But as a lot of folks, a lot of folks out there that just want the tool and the instructions

30:21 are kind of like install, create a virtual environment.

30:24 Now run the pip from that environment to install this tool.

30:27 Now search into that bin path and there's your binary.

30:31 Like that's not really the easiest way to get end users a really cool program that you wrote

30:36 that happens to be in Python.

30:37 Right, right.

30:38 I want to have this program accessible.

30:40 Oh, wait, did you forget which virtual environment you installed it into?

30:43 And did you forget to activate that or whatever, right?

30:46 So this solves a lot of those problems, which is fantastic.

30:49 Juergen again says, as you said, install and run Python applications.

30:53 Does this refer only to CLI or even web apps?

30:55 I'm not sure I understand the question.

30:57 Certainly CLI apps.

30:59 I'm not sure what a web app is in terms of this question.

31:02 Sure.

31:02 Well, I guess maybe just can it install stuff more broadly?

31:05 Like if I had something maybe that was built with GUI, for example, G-O-O-E-Y, like that

31:11 GUI framework, or I have something that was installed or built with some other tool.

31:16 That when I run it, maybe I don't get a CLI experience.

31:20 Maybe it installs Flask and opens a browser or something like that, right?

31:24 I think that's the question.

31:25 Yeah, absolutely.

31:26 That's actually where I found the need for PipX most.

31:30 And the tool I made that happens to be a web app where I have these...

31:33 So the tool is called GDB GUI, and it's a web app that lets you debug programs with GDB.

31:39 Right.

31:39 And so I was ready to read me to tell folks how to get it, how to run it.

31:44 So people that are trying to debug things with GDB, maybe they're Python developers, but they're

31:49 definitely C developers or Rust developers, some kind of a native language.

31:54 So the read me instructions I wrote were, I kind of like struggled with how to tell people

31:59 to install this.

32:00 Telling them to install pip with pip was not something I was comfortable with because there

32:04 are so many dependencies GDB GUI has, and I didn't really want to like break their system.

32:08 There was kind of two fears.

32:09 Like one, I didn't want to mess their system up.

32:10 And two, I didn't know if it would work reliably because there was, maybe they would install

32:15 something else and mess it up.

32:17 I searched for a while to find something that could get this installed in a better way.

32:22 And I'm Pipsy.

32:23 Okay.

32:24 So yeah, Pipsy like this.

32:26 Yeah.

32:27 Yeah.

32:27 P-I-P-S-I.

32:28 Okay.

32:28 This is basically exactly what I wanted.

32:31 It gives you a single command that creates a virtual environment, installs package there,

32:36 and that exposes the binary entry point, which sounds familiar.

32:39 It is because that's what PipX's origin is from.

32:43 Right.

32:43 And in fact, right at the top of the Pipsy read me, it says, Pipsy is no longer maintained.

32:47 You should check out PipX.

32:49 Right.

32:50 The origin of PipX came from one of the issues in Pipsy where someone, we were kind of having trouble getting changes merged to Pipsy.

32:59 I found it.

32:59 I was really excited.

33:00 And I started making a bunch of pull requests on it.

33:02 And I was having trouble getting things merged.

33:04 And basically the maintainers, they were okay with having it in maintenance mode,

33:08 but they didn't really want to do active development with it.

33:10 And the owner, which was Armin Roedeker, he had sort of unsubscribed from the project.

33:16 And wasn't really following it.

33:17 And so he was the only person that was able to give more access to let people become maintainers

33:22 or so on.

33:23 So we were able to add ourselves as maintainers.

33:26 So we were kind of stuck with this tool.

33:27 We could like, maybe we could fork it.

33:28 Maybe we could make a new tool.

33:30 Yeah.

33:30 So how'd you get from there to PipX?

33:32 As I said, I was like, I'm into also TypeScript and the JavaScript community.

33:36 And one of the tools they have there is called NPX, which is pretty similar to PipX.

33:41 It lets you run CLI apps from Node, who also can have similar challenges because it's an interpreted language.

33:47 And so I made PipX to kind of add that capability to Python.

33:51 And then I added the ability, since it does kind of like, it makes a virtual environment, it finds the binary in it and it runs it.

33:57 It's very similar to installing it.

33:59 It's basically installed in a temporary place and runs it versus installing it in a permanent place.

34:04 And so I added the install capability on PipX.

34:06 I shared it with some of the folks in the issue tracker.

34:08 And they were like, this works for me.

34:11 Let's go use that.

34:12 And this is it.

34:13 Yeah.

34:14 The momentum continued around it and had a lot of really great contributors work on PipX.

34:21 Yeah, that's great.

34:21 The GitHub repo says 75 contributors and 5,000 GitHub stars, which is pretty awesome.

34:27 Yeah.

34:28 I'm really happy with it.

34:31 This portion of Talk Python to Me is brought to you by the Python at Scale Summit.

34:36 The Python at Scale Summit is a conference to highlight innovative big data solutions for Python developers and enterprises.

34:43 You'll learn about trends in the Python big data ecosystem, share stories about implementing solutions,

34:48 find out about new innovations, and connect with other data scientists using Python.

34:53 The Python at Scale Summit will be a hybrid conference with talks, workshops, and training.

34:59 Of course, there will be networking and social events to connect with other Python professionals, too.

35:04 Come hear speakers like Matt Rockland from Coiled, Brian Granger from AWS,

35:09 and many others from amazing organizations such as NASA, Capital One, and BCG.

35:14 Get back together with your peers and learn how they're scaling their computation and data analysis

35:19 using Python and the data science stack.

35:22 Register at talkpython.fm/python dash at dash scale.

35:27 When you visit the link, be sure to use the code TALKPYTHON, all caps, to get 15% off your tickets.

35:34 That's code TALKPYTHON at talkpython.fm/python at scale.

35:38 The link's in your podcast player's show notes.

35:40 Thanks to the Summit for supporting the podcast.

35:43 I use it all the time.

35:45 I personally really like it, and I'm really glad to see other folks are enjoying it as well.

35:50 Yeah, I use it all the time.

35:53 It's one of my go-to tools when I want to check out something I know is built with Python as an application,

35:58 or I get a new machine.

35:59 We can talk about some of the fun stuff to install in a little bit, but maybe let's first talk about what happens and how do I use PipX?

36:08 What's the process?

36:09 You do have a nice animated GIF on the GitHub project so people can see what happens,

36:14 but maybe walk us through it.

36:15 Let's say Glances.

36:17 Glances is a fantastic application that you can use, and if you run it on your machine, it gives you this super rich terminal-based real-time view into your servers.

36:29 It's much, much better than top or something like that.

36:32 It also has a web view and whatnot.

36:34 So that's a thing that people might not care about Python for, but it happens to be written in Python, so it's a perfect thing to PipX install.

36:42 Exactly.

36:43 Yeah, so talk us through, if I have PipX install Glances, what happens?

36:46 Yeah, sure.

36:47 So the first thing is PipX will try to determine which package you're trying to install.

36:53 So you can give it just a name Glances, or you can give it basically any pip specifier,

36:58 any kind of, it can be a Git repository, it can be a wheel, anything pip can install, PipX can install.

37:04 So first it will make sure that it's a valid package specification.

37:07 Then it will create a virtual environment in this directory that PipX manages.

37:13 So it'll make a virtual environment with the name of the package.

37:15 It'll make a Glances virtual environment.

37:17 Then it will do some introspection on the, that it will install Glances into the virtual environment.

37:23 So now we have a virtual environment with Glances installed, but it's not accessible anywhere other than inside that virtual environment.

37:29 And so the next thing it does is it does some introspection on the virtual environment to say like,

37:34 what binaries do we have available?

37:36 And so it would be expecting Glances to be available.

37:40 And it will then take, it'll find the path to the Glances binary and create a symlink into a directory on your path,

37:48 on your, on your shell's path.

37:49 So that when you run that command, it's available.

37:51 Right.

37:52 So for example, you need to have, in your little example here was home slash csmith slash dot local slash bin.

37:59 And then that's the folder where all the symlink stuff gets linked over.

38:03 You can also do those with entry points, right?

38:05 It'll find the entry points and make them available.

38:07 Yeah.

38:07 So these are cons.

38:08 These are, these are entry points.

38:09 These are the console scripts.

38:10 Okay.

38:11 So that leads me to a question out in the audience from Ratul.

38:14 Ratul says, this looks great.

38:16 Not sure if I missed it, but how do you get your built Python app to be pipx installable?

38:21 So you said it has to be pip installable, but then I think the other point here,

38:27 you would have to expose some functionality in a way, and that could be entry points, right?

38:31 Yeah.

38:32 So pretty much that is the, essentially the only way is this, is the console script entry point.

38:37 So you can look this up.

38:38 It's a kind of well-defined part of the packaging specifications, but you can define a function

38:45 that you want to call from a console script entry point.

38:49 Yeah.

38:49 So in your setup, you would say something like set up tools dot setup entry points equals,

38:53 and then you give it a list of a command and then basically a module colon function, right?

38:59 So here's this example that I'll link to in the show notes is, is hello world equals hello

39:04 world, which is the module name colon say hi, which is a function in hello world.

39:09 And once you pip install that into a virtual environment, you could just type hello world

39:12 and it would do whatever it does for that function.

39:14 But what you're saying is if you install with pip X, it finds these and creates basically

39:19 binaries that the system can see that it thinks it can run called hello world, for example.

39:24 Yeah.

39:25 When you pip install something that has a console script, it makes this like a shell script that

39:30 calls that function for you.

39:32 And so these shell scripts just get sim linked out onto your path by pip X.

39:37 Got it.

39:37 Yeah.

39:37 So it's basically doing the install.

39:40 It's creating the virtual environment automatically behind the scenes.

39:43 It's installing, doing basically pip install on the package, but that drags in all of the

39:49 dependencies.

39:49 But the important thing is every one of these commands, or I guess the thing you pip X install,

39:54 it can have multiple commands as part of it.

39:56 It gets its own virtual environment that's isolated, not just from the rest of the system,

40:00 but all the other pip X things as well.

40:02 So they're versioned and they live independently, right?

40:04 Exactly.

40:05 Yeah.

40:05 You can have more than one console script too.

40:07 A lot of times package will have, you know, two or three, four console script entry points

40:11 and pip X will find all those.

40:12 Nice.

40:13 Yeah.

40:13 One that comes to mind is pi jokes.

40:15 Are you familiar with pi jokes?

40:17 Yeah.

40:17 I've heard you guys talk about that on the podcast before.

40:19 Yeah.

40:19 Pi jokes is a good one.

40:21 So this one has entry points and I always get this through pip X.

40:25 I just, you know, pip X install pi jokes and you end up with a bunch of, who'd they say

40:32 pip X, right?

40:33 And then you can run pi joke or pi jokes.

40:36 And even as a program API and you get really deep jokes.

40:41 Like why did the programmer quit their job?

40:43 Because they didn't get a raise.

40:44 A raise is in like lists.

40:47 But you know, it's those types of things, right?

40:49 You don't necessarily care that pi joke is written in Python.

40:52 I mean, the name would maybe make you think it should be, but right.

40:55 You just want to have a command that you can type something and get a funny programmer joke

40:58 out of it.

40:58 Right.

40:58 But maybe we could touch on some of the other things that are more useful than pi joke.

41:03 Like one you mentioned was the GDB GUI.

41:06 I gave a shout out to glances because glances, I said, is fantastic.

41:10 I use glances all the time.

41:11 It just happens to be written in Python, but I just want it on my server.

41:14 Maybe another one that pointed out was HTTP pi.

41:17 HTTP pi, HTTP IE.

41:20 Do you use this one?

41:21 I have not used it too much, but I would love to find an opportunity to use it.

41:25 Prefer it over things like curl.

41:27 Yeah.

41:27 I love HTTP pi.

41:29 It works just like curl in a lot of ways, but the results that it gives you, it gives you

41:35 syntax highlighting, easy ability to say, just show me the headers and the response, the

41:41 response headers and stuff that came back and cookies.

41:43 And it, you know, does highlighting on those.

41:46 It's really nice.

41:47 So just pipx install HTTP pi, and then you get HTTP as a command and HTTPS.

41:53 Here's another one with two entry points, right?

41:55 So if you just want to say HTTP, you know, 127.0.0.1, you don't have to say HTTP colon slash

42:02 slash server name.

42:03 You can just say the command, either HTTP or HTTPS, and it'll, it'll do it.

42:07 It's just a little bit shorter.

42:08 Right.

42:09 So this one, big fan.

42:11 But what was surprising to me about this is, you know, this is backed by a company, right?

42:16 There's like a whole bigger organization behind HTTP pi than I realized, I believe.

42:22 So I was impressed with their website.

42:24 It was a lot more polished than a lot of other open source projects.

42:27 So I'm not surprised to hear that they're funded or they're part of a company.

42:30 Yeah, exactly.

42:31 At the bottom, it says like job, there's a whole job section.

42:34 There's apparently four jobs for HTTP pi, which is incredible.

42:37 At the same time, it's a fantastic tool.

42:40 Yeah.

42:40 So, you know, good on them.

42:42 Let's see.

42:43 Maybe some of the other ones.

42:44 I know we had a little bit of list of stuff that could be fun.

42:46 Pi installer, pi to app.

42:48 Let's see.

42:50 Pi installer, pi to app, Cython.

42:52 A lot of the package management stuff.

42:55 Poetry, pipenv.

42:57 Yeah.

42:57 Anything else you want to give a shout out to?

42:59 I've got one I want to use as well, but go ahead and do yours.

43:01 Another program I made, I guess I'll plug my own, one of my other projects, it's called

43:06 Term Pair.

43:06 So this is actually kind of a web app.

43:09 It lets you share your terminal session through the web.

43:13 But it does it by encrypting all the output and input from your terminal.

43:17 And so basically you run this command term pair share, and then it will start sharing through

43:23 this server.

43:24 And then you can either, you can control it from the web app or you can control it from

43:28 the terminal.

43:28 And the process running in the terminal is a Python app.

43:32 And then, of course, the web app is JavaScript React.

43:35 Yeah.

43:36 How interesting.

43:37 Does it give you your normal shell or is it like a bare bash or Z shell or something?

43:42 By default, it uses...

43:43 Like if I do a super configuration of my shell, make it like all blinged out, and then I run

43:49 this, do I get the same crazy configuration or is it a simpler version?

43:52 No, it's the exact same thing.

43:53 It'll just run whatever shell, whatever the shell environment variable is that you're running.

43:57 It'll just, that's the default command.

43:58 You can run any command you want.

44:00 If you want to run Python, you can run Python.

44:01 It'll share your Python session.

44:03 You can run anything really.

44:05 But if you run a shell, that's the most familiar thing, I think, for sharing.

44:09 Sure.

44:09 Sure.

44:10 Interesting.

44:11 It'll share basically any CLI thing, huh?

44:13 It spawns a PTY process.

44:15 And then any output or input just gets written and behaves like any other terminal would.

44:21 So you can do stuff like, you know, this is HTOP where you're interacting with it.

44:25 And it's kind of like rewriting lines to the screen.

44:28 And it's able to handle all that.

44:29 It might be a nice way to help people who are like, you know, I'm stuck.

44:33 I can't get this to work.

44:34 You're in an email exchange or a Zoom meeting or something.

44:37 You know, run this and give me the link.

44:38 And I'll just, let me just ask your system a question real quick and see if it does the same.

44:42 You got to have a lot of trust to give this over to people though, right?

44:45 Yeah.

44:45 You know, I made it because it seemed really fun.

44:47 It was a challenge.

44:48 It seemed fun.

44:50 Practically speaking, yeah, I don't know how often it's used.

44:53 You'd have to totally trust somebody to not.

44:55 I mean, they have full control over your computer.

44:57 Sure.

44:57 It's not that different than going to a Zoom meeting and say, allow so-and-so to share,

45:02 to control my mouse and keyboard or team viewers or something like that.

45:06 Yeah, that's true.

45:06 Yeah.

45:06 Yeah.

45:07 But still pretty neat.

45:08 I don't know.

45:08 It's just so more visceral.

45:09 It's right there.

45:10 You could just RMRF it right there.

45:11 Yeah.

45:12 There's another one I want to pull up here.

45:14 This one, PLS.

45:17 Do you use PLS?

45:18 Any?

45:18 Yeah, I've tried it out.

45:19 It's pretty cool.

45:20 I like that you can do so many different things.

45:24 I like how easy it is to develop applications in Python, where you can just kind of make whatever

45:28 customizations and hack things up really quickly.

45:31 Absolutely.

45:31 So PLS, it's a little hard probably to see over the screen share.

45:35 It's a replacement for LS.

45:36 And I know there are many replacements for LS, but this one is cool because it's a developer-friendly

45:41 one.

45:41 And so when you interact with it, it will use a lot of different things.

45:47 For example, it'll show icons for Python logos next to .py files, JavaScript logos next to

45:53 JS files, and so on.

45:55 But it will also use git ignore files to decide what shows up in the basic view.

46:01 It'll show you the git status of the file.

46:03 When you do a PLS --details, you'll see which files in that listing are modified

46:09 in git, according to git, and so on.

46:11 So there's just a ton of fun stuff here that you can check out.

46:14 I definitely think it's neat.

46:15 Here's some examples of some of the colors.

46:17 For example, poetry.lock, because it's git ignored, but still important.

46:22 It shows up, but it's a very faint color, whereas other files show up with regular colors.

46:28 So this one is another one that's good to pipx install, right?

46:31 Because you just need it once for your computer.

46:33 Yeah, I love those colors too.

46:34 Great color scheme.

46:35 Yeah, yeah, absolutely.

46:36 And apparently you can build little plugins and stuff for it, I think, in Python.

46:40 I haven't tried to do that.

46:41 I've just tried to use it as a user.

46:43 But yeah, that one's a fun one.

46:46 For a while, I replaced LS with it.

46:48 That wasn't a super idea, because it behaves weirdly.

46:53 If you try to LS something and it doesn't exist, you get a traceback exception instead of just doesn't exist or nothing.

47:01 It's not perfect, but as a thing that you have hanging around, it's definitely quite neat.

47:06 Yeah, replacing system utilities can get kind of risky.

47:09 Yeah, you just got to know what you're doing.

47:13 I'm willing for this to mildly break stuff.

47:16 But if you make it like you said that one time you couldn't turn on your computer, then you're in a bad spot.

47:21 Or if you could at least get back and edit your profile, your shell profile, and turn those back to normal, then you're probably okay.

47:28 Yeah.

47:28 Well, maybe real quickly, you could give us just if there's any interesting internal, there's some interesting tools or stuff that happens behind the scenes with PipX.

47:37 Give us a look inside real quick, and then maybe we could wrap things up.

47:41 Any interesting internals of PipX?

47:43 Let's see.

47:44 Yeah, yeah.

47:44 Like notable libraries that it uses or something that's really valuable in there.

47:48 I was poking around the PyProject.tabble, and there's like argcomplete.

47:54 Sounded interesting to me.

47:56 And then a user path is new to me as well.

47:59 Okay, yeah, yeah.

47:59 Sure.

48:00 So argcomplete, I'm a huge fan of.

48:02 Argcomplete is a package that, so if you use argparse, which is the standard library's argument parsing package,

48:10 a lot of times you'll want to have like tab completion and tab completion can be really hard to write.

48:15 And so argcomplete gives you a Python API to tell it how tab completion should work.

48:21 And so in PipX's case, if you're going to do something like PipX, like uninstall a package, you have to give a name of a package that's been installed.

48:29 And so with argcomplete, you can say like PipX uninstall tab, and then argcomplete, you give argcomplete a list or like a way to get a list of packages that can be uninstalled.

48:40 And then it gives you that tab completion just like you'd expect.

48:43 And it also does it across shells.

48:45 So like writing it for just bash is enough to do, but then you also have to write like different completions for fish or something like that.

48:53 And so argcomplete lets you not think about that and just use your argparse as you normally would with just like a couple extra arguments.

48:59 And then boom, you have tab completion.

49:01 Right.

49:01 Yeah.

49:02 There's a whole section where you talk about how to install completion in here for the shells.

49:08 So, you know, do you do that for, if you just type PipX space completions, it'll tell you how to do that, right?

49:14 Right.

49:15 And argcomplete's useful for, I mean, I actually added it for Knox.

49:18 I'm a big fan of the tool Knox, which is also PipX installable and Knox.

49:23 A lot of times you want to, there's only a lot of sessions.

49:25 You run sessions in Knox and there's a whole bunch of them.

49:28 And so having a tab completion on that was a feature I really wanted.

49:31 And I think, I think that's where I first found out about argcomplete.

49:33 And then I started adding it to other projects after I found out how easy it was to use.

49:37 Right.

49:37 You're like, this is not that hard.

49:38 I want this.

49:39 Yeah.

49:39 Yeah.

49:40 Cool.

49:40 The other thing that people need to remember to do is to run PipX ensure path, right?

49:46 Right.

49:47 Because you talked about, we talked about that .local slash bin in your user profile, at least on macOS.

49:52 I don't know if that's where it goes.

49:53 It might go somewhere else in Windows.

49:55 But you want to make sure that's in your path.

49:57 So that'll basically modify whatever your active shell profile is to make sure it's in your path, right?

50:01 That's right.

50:02 Yeah.

50:02 And you can also modify where that binary directory is with an environment variable if you want.

50:08 Okay.

50:08 How well does this work on Windows as well?

50:11 Does it work there?

50:12 Is it like PowerShell friendly and stuff like that?

50:14 So it does work on Windows.

50:15 I know that one of the contributors is one of the maintainers is a Windows user.

50:19 And I don't see a flood of Windows issues coming in about this doesn't work on Windows.

50:25 So it should work on Windows.

50:27 Yeah.

50:27 Yeah.

50:27 Yeah.

50:28 Perfect.

50:28 Okay.

50:29 And then it can upgrade itself.

50:31 If you do pip upgrade like --user or something like that.

50:35 It doesn't install itself.

50:36 I'm considering making a new installer where pipX installs itself with pipX.

50:41 I'm not sure I'm going to land that.

50:42 Right now we install pipX with pip.

50:45 And so you would just upgrade it normally with like pip upgrade pipX.

50:48 Sure.

50:48 Okay.

50:49 Or it's pip install dash user.

50:50 Sorry.

50:51 Another thing that I like about pipX is you can just say pipX.

50:54 What is it?

50:55 Upgrade all.

50:55 Yeah.

50:56 Or there's a command to just upgrade.

50:58 You know what?

50:58 Give me a new version of all my libraries.

51:00 Which comes back to similar with apt.

51:03 Similar to homebrew, right?

51:05 There's a brew update and outdated and just show me the stuff that could be updated.

51:09 And then we'll just do it.

51:10 Same with Chocolaty.

51:11 Just to keep the tools used fresh.

51:13 It's really nice.

51:14 Yeah.

51:14 It kind of goes back to like, I have this program.

51:16 I don't really care about that.

51:18 It's written in Python.

51:18 I just want this thing to work.

51:20 I want the newest version of it and just kind of make it happen.

51:23 Right.

51:23 And but if we reverse that and we're talking to Python developers, as most people listening

51:27 are, you can empower people to deliver their applications to end users in a way that is

51:33 much, much, much simpler if they're not Python people, right?

51:37 Yeah.

51:38 If they can get PipX on their machine, then getting the rest of their stuff is basically

51:42 done, right?

51:42 That's a great point.

51:43 Yeah.

51:43 I mean, the distribution story gets a lot easier for your users.

51:47 If you're a developer and you want to get this in people's hands, having them use PipX

51:51 is going to cause them less headaches and it's going to cause you less headaches because it's

51:54 going to be more predictable environment to install in.

51:57 Because PipX kind of lives in the center of a few things.

52:01 Like you have wheels, which are pre-built packages specific to your operating system.

52:07 And you have pip and PipX and virtual environments.

52:11 And PipX kind of marries them all together in a way where it takes the pre-built, doesn't

52:16 have to rebuild it on the user's computer.

52:17 It takes this pre-built thing that works.

52:19 It puts it in a place that's not going to disturb anything.

52:22 It's not going to get disturbed either.

52:23 And then it makes it accessible to the end user.

52:25 And they don't have to think about any of those pieces to get it on their computer.

52:29 Yeah.

52:30 So maybe one of the biggest takeaways is if you're trying to deliver Python applications

52:34 to people, here's a really good option.

52:37 If some kind of CLI starter is the way to go, right?

52:41 I guess if you want, here's how you drag it over to your applications folder and put it in

52:44 your doc.

52:44 Maybe that's not the right thing.

52:45 But you know, for a lot of the type of stuff people are building with Python, it's a great

52:49 way to get it to end users and keep it up to date.

52:52 One other thing I'll call out is pipx run.

52:55 Yes.

52:55 Yeah.

52:55 We've talked about install the whole time.

52:57 But yeah, pipx run is maybe even better for certain things.

53:00 Yeah.

53:00 So pipx run will make sure you have a recent version of the tool you're trying to use.

53:05 So if you want to run some kind of a bootstrap program or some kind of like cookie cutter

53:08 where you create a new project or something like that, then you'd want it to run with the

53:12 recent version.

53:13 pipx run will just kind of make it happen for you.

53:16 Right.

53:16 So one of your commands might be, well, first, you're going to set up a virtual environment

53:20 and then you're going to pip install cookie cutter.

53:22 Then you're going to run cookie cutter this thing.

53:24 Right.

53:25 Right.

53:26 Well, maybe the step is if you already have pipx, assuming this is a thing that's accessible,

53:30 pipx sort of install run cookie cutter and you give it that command.

53:34 Nobody needs or wants cookie cutter after that.

53:37 They just need cookie cutter to run the skeleton generator for their project.

53:41 And then their project is kind of free from cookie cutter because you can't update your

53:44 project afterwards anyway.

53:45 Right.

53:45 That's probably a good mental model to have.

53:47 Yeah.

53:48 And that's how the JavaScript world uses it.

53:50 It's kind of like, it's one of the really popular ways.

53:52 And you'll see the NPX, you know, create React app is a way to start React apps with,

53:57 with the latest version of that cookie cutter type thing.

54:00 And so I would love to see more adoption on, on that side in the Python world.

54:04 Yeah, absolutely.

54:05 Another one, I guess, let's just real quick, maybe give a shout out to this is the Node.js

54:10 thing that just got added.

54:12 Isn't there a way that just came out for installing Node.js as a dependency, not just the bindings?

54:19 I feel like there just was.

54:20 Yeah.

54:20 I saw something about this.

54:22 Yeah.

54:22 Actually, I think we just covered it on Python bytes, but I wasn't the one who brought it up.

54:26 So I don't totally remember.

54:27 Let's see.

54:28 There you go.

54:28 Node.js dash bin.

54:29 That's it.

54:30 Gina Houska covered it.

54:32 And yeah, there it is.

54:34 Node.js dash bin.

54:35 So if you've got something that needs to have the Node tools around or, or CLI stuff,

54:40 you could, you could just pip install Node.js dash bin.

54:42 So I guess you could also pip and X install Node.js dash bin.

54:45 Yeah.

54:46 Maybe if it's a, if it's an entry point, then for sure.

54:49 Yeah.

54:50 I haven't thought enough about it, so maybe it doesn't quite fit in there, but it's an interesting,

54:53 interesting development.

54:54 All right, Chad.

54:55 Well, I think we're probably out of time for talking about pipX.

54:58 Let's maybe wrap things up.

55:01 Any final thoughts or anything you want to add to this before we get to the final two

55:05 questions?

55:06 No.

55:06 Thanks for having me on and sharing some discussion on pipX.

55:10 Yeah, absolutely.

55:10 It's a great tool.

55:11 All right.

55:12 Final two questions.

55:13 If you're going to write some Python code, if you're going to work on pipX or your terminal

55:17 replicator or whatever you're doing, what editor are you using these days?

55:20 I use VS Code.

55:21 Yeah.

55:21 It sounds like Meta is pretty standardized on that.

55:24 Is that right?

55:24 That's our company-wide editor.

55:26 Do a lot of work on writing extensions for it and making it work for developers in Meta.

55:30 Yeah.

55:30 Cool.

55:31 And then we've talked about a ton of PyPI packages, but one you want to give a particular

55:36 shout out to?

55:37 Yeah.

55:37 So this one is not pipX installable, but I think it's super cool.

55:40 MK docstrings.

55:41 And this is a way to generate documentation from your code.

55:45 I think it's similar to Sphinx.

55:47 I haven't really used Sphinx too much, but I find MK docstring is really user-friendly.

55:51 It's all marked down.

55:52 And I think it's really like a good looking UI that it generates for you.

55:58 I think it's really easy to use and it gives you a nice end result too.

56:00 Cool.

56:01 Fantastic.

56:01 Good recommendation.

56:02 All right.

56:03 Final call to action.

56:04 People want to play with PipX, develop Python apps that can be installed through PipX and

56:10 so on.

56:10 What do they do?

56:11 How do they get started?

56:11 How do they get started developing apps for PipX?

56:14 So you can use any of those tools to get a piproject.toml file and have a publishable package and make

56:21 sure you have a console script entry point.

56:24 Really, all you have to do is have a console script entry point for your package and then

56:28 PipX will take care of it for you.

56:31 Yeah.

56:31 It's worked with everything that I've tried it with.

56:33 So it seems pretty solid.

56:35 Great.

56:35 Yeah.

56:35 Awesome.

56:36 All right.

56:36 Well, thanks again for being here and for working on PipX.

56:39 It's a great project.

56:42 This has been another episode of Talk Python to Me.

56:44 Thank you to our sponsors.

56:46 Be sure to check out what they're offering.

56:48 It really helps support the show.

56:49 Mergify is an amazing tool to make you and your team way more productive with GitHub.

56:54 It's all about leveling up your pull requests.

56:56 With automatic merges, auto updates, PRQ prioritization, and backports, you'll tame your

57:02 PRs once and for all.

57:04 Get started at talkpython.fm/mergeify.

57:07 Sign up for the Python at Scale conference to connect with your data science colleagues

57:12 and learn about trends in the Python big data ecosystem.

57:15 Share stories about implementing solutions and find out about innovations in our space.

57:20 Visit talkpython.fm/python dash at dash scale.

57:25 That's talkpython.fm/python at scale.

57:27 And use code talkpython to get 15% off your ticket.

57:31 Want to level up your Python?

57:33 We have one of the largest catalogs of Python video courses over at Talk Python.

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

57:42 And best of all, there's not a subscription in sight.

57:45 Check it out for yourself at training.talkpython.fm.

57:48 Be sure to subscribe to the show.

57:50 Open your favorite podcast app and search for Python.

57:53 We should be right at the top.

57:54 You can also find the iTunes feed at /itunes, the Google Play feed at /play,

57:59 and the direct RSS feed at /rss on talkpython.fm.

58:03 We're live streaming most of our recordings these days.

58:07 If you want to be part of the show and have your comments featured on the air,

58:10 be sure to subscribe to our YouTube channel at talkpython.fm/youtube.

58:15 This is your host, Michael Kennedy.

58:16 Thanks so much for listening.

58:18 I really appreciate it.

58:19 Now get out there and write some Python code.

58:21 I'll see you next time.

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