Latest / Talk Python To Me / #371: pipx - Installable, Isolated Python Applications
Transcript
- 0:00I'm sure you're familiar with package managers for your OS, even if you don't use them.
- 0:04On macOS, we have Homebrew, Chocolaty on Windows, and Apt, Yum, and others on Linux.
- 0:09But if you want to install Python applications, you typically have to fall back to managing them with pip.
- 0:15Maybe you install them for your account with the --user flag.
- 0:19But with pipX, you get a clean, isolated install for every Python application that you use.
- 0:26And if you distribute Python apps, pipX is definitely worth considering as a channel.
- 0:30On this episode, we have Chad Smith, creator of pipX, to tell us all about it, how it works, and how to use it.
- 0:37This is Talk Python To Me, episode 371, recorded June 22, 2022.
- 0:45Welcome to Talk Python To Me, a weekly podcast on Python.
- 1:01This is your host, Michael Kennedy.
- 1:03Follow me on Twitter, where I'm @mkennedy, and keep up with the show and listen to past episodes at talkpython.fm.
- 1:09And follow the show on Twitter via at Talk Python.
- 1:12We've started streaming most of our episodes live on YouTube.
- 1:16Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming shows and be part of that episode.
- 1:23This episode is brought to you by Mergify.
- 1:26Take control of and automate your GitHub workflows.
- 1:29As well as the Python at Scale Summit conference being held in October.
- 1:34Reconnect with your data science colleagues this year.
- 1:38Transcripts for this and all of our episodes are brought to you by Assembly AI.
- 1:42Do you need a great automatic speech-to-text API?
- 1:44Get human-level accuracy in just a few lines of code.
- 1:47Visit talkpython.fm/assemblyai.
- 1:50Chad, welcome to Talk Python To Me.
- 1:52Thanks, Michael.
- 1:53It's fantastic to have you here.
- 1:55I 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.
- 2:05And it's going to be so fun to talk about.
- 2:07And if you're out there and you haven't heard of PipX, you're in for a treat.
- 2:10So before we get to that, though, let's start with your story.
- 2:12How do you get into programming in Python?
- 2:14So I got into programming back when the internet was kind of like really popular with GeoCities, like early web development type stuff.
- 2:21This is the time when people had like the animated digging Giphy.
- 2:24Yeah.
- 2:25And like a lot of sites were still permanently under construction.
- 2:27Yes.
- 2:28And flashing text and stuff like that.
- 2:30So I thought that was pretty cool.
- 2:32I messed around with some GeoCities pages.
- 2:33I wrote a little bit of JavaScript to where you can like hover over text and it will change the image and stuff like that.
- 2:39And 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.
- 2:46So when I got more into programming was in college.
- 2:49I went to, I got a degree in aerospace engineering.
- 2:52And so we did like kind of like scientific computing.
- 2:54We used MATLAB a lot.
- 2:56So I used a lot of MATLAB in college.
- 2:58And then in my first job, we did a lot of MATLAB.
- 3:00So in the aerospace industry for making airplanes and like control systems, we use MATLAB a lot.
- 3:06And 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.
- 3:17I just kind of did everything in MATLAB.
- 3:19That'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.
- 3:25And they're like, well, which one of these is going to be best?
- 3:27And if your programming environment is MATLAB, then, you know, that's not a terrible choice, really.
- 3:31Yeah, I got like really into programming MATLAB and then eventually ended up at a job where I got to start doing a little Python.
- 3:37Nice.
- 3:37What kind of airplanes were you working on?
- 3:39First job was on the space shuttle, which was, which has been retired.
- 3:43Then I worked on like, I worked for Boeing.
- 3:44Of course.
- 3:45Oh, that's fantastic.
- 3:46Yeah, I worked from the 747, 787.
- 3:48So I worked for Boeing.
- 3:49So Boeing worked on the space shuttle and as well as obviously a bunch of other planes.
- 3:54And then none of the Python work was there, though.
- 3:56And the Python stuff started at a startup funded by Google co-founder Larry Page.
- 4:02So it was an EVTOL, electric vertical tick off and landing plane.
- 4:05So it's like a small plane.
- 4:06It was a startup.
- 4:07It was a small company.
- 4:08And we needed like basically some tools to be made.
- 4:12And I didn't really know Python, but I like to just take on new challenges and learn new things.
- 4:17So my first experience with Python was with Python 2 and working on a Django app.
- 4:21It was an app to track all of the parts and weights and moments of inertia of the aircraft.
- 4:27Another project was like called a protocol compiler.
- 4:30So all the C code that ran on the avionics was a lot of it was generated.
- 4:34A lot of the inter device communication was generated from this common protocol definition.
- 4:40And so this was all written in Python.
- 4:42So we could generate safety critical C code.
- 4:44We could generate documentation about the code.
- 4:47We could generate tests where we had like hardware in the loop tests.
- 4:50And so that was where I started to run into issues with challenges with packaging and getting dependencies installed on folks computers.
- 4:57Because if you wanted to build the flight code, you needed to have a bunch of packages available.
- 5:02Right.
- 5:02And so, you know, you had to have maybe some foundational thing in order, some libraries and other things.
- 5:08And 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?
- 5:14Exactly.
- 5:14Or documentation writers.
- 5:16Yeah, exactly.
- 5:17And yeah, it was a small company.
- 5:19So there wasn't really a Python expert in house.
- 5:20So 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.
- 5:27And 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.
- 5:33Yeah, for sure.
- 5:34Well, 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.
- 5:41But you were also at Boeing, which is a non-small company for my looking in from the outside.
- 5:46Yeah.
- 5:47I know a lot of people, they definitely dream of or look to get hired at these really large companies.
- 5:53And 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.
- 6:08What do you think?
- 6:09What was your experience in those places?
- 6:10Well, so Boeing did offer opportunities to let you kind of like improve processes and stuff like that.
- 6:16But the scope of what you're working on at a small company, trying to build a similar product.
- 6:21I mean, you have a smaller team with no like legacy or decades of history building stuff.
- 6:27You're kind of just inventing it as you go.
- 6:28So yeah, there's a ton of stuff to experiment with and take on and learn from.
- 6:33Yeah.
- 6:33Cool.
- 6:34How about now?
- 6:34You're at another small company, right?
- 6:36Yeah.
- 6:37I'm at a small company called Meta.
- 6:38I work for the, I work for Reality Labs and I work on developer infrastructure here as well.
- 6:44I work on things like language services, debuggers, and VS Code, VS Code extensions.
- 6:50Cool.
- 6:51Do you have any exposure to the Cinder project or any of the stuff going on over there?
- 6:55No, I'm aware of it.
- 6:56I think it's super cool, but that's an Instagram thing really.
- 6:59And so it's not really something that I use day to day.
- 7:02Well, it looks like it's going to become a Python thing in little bits and pieces.
- 7:05Yeah.
- 7:06The pieces of it are being pulled over.
- 7:08Like we just talked about PEP690 and lazy imports, and there's a couple of other things
- 7:13people are working to move in.
- 7:15So not the whole thing, but some of those features and improvements make it to all of us.
- 7:19Yeah.
- 7:19That's the great thing about Python is if you come up with a good idea, the community is
- 7:23very open and willing to adopt new ideas.
- 7:26The best ideas win and can be continuously improving the language.
- 7:30Yeah.
- 7:30That's pretty fantastic.
- 7:31So let's start our conversation here at a little bit higher level than just PIPX.
- 7:37And let's just talk about packaging a little bit.
- 7:40So let me switch over here to this project.
- 7:42So you have over at chadsmith.dev, which is a great domain name.
- 7:47And I'm impressed with a name like Chad Smith that you can get it just straight up as your
- 7:51domain name.
- 7:52Because as Michael Kennedy, all the Irish politicians are all over me.
- 7:55I got to go with some crazy variation to come up with it.
- 7:59But yeah, that's cool.
- 8:00That's a great domain name.
- 8:01And over there at slash python-packaging, you've got the big list of Python packaging and distribution
- 8:06tools.
- 8:07You want to tell us about this?
- 8:08Kind of gives you a high level of like, what are the options, right?
- 8:11Yeah.
- 8:11So a lot of times questions come up about what tools are out there, which tools do what.
- 8:17You know, it's a big world in the packaging, in the packaging, in the Python packaging world.
- 8:21And I wanted to make something that was not opinionated and just kind of factual.
- 8:25Like here's some data, here's some information about these.
- 8:29You can decide for yourself.
- 8:30It's not trying to persuade you to use this.
- 8:31It's not like saying this is my tool.
- 8:33This one's the best.
- 8:33And this came about from PIPX's documentation where one of the other questions on PIPX was
- 8:38like, what is it and how does it compare to other things?
- 8:40So I had kind of a list on the documentation and it kept growing.
- 8:44And I was thinking, you know, this could be its own thing because I don't want to PIPX
- 8:47documentation too big.
- 8:49Make it a survey of all the other things that it competes with or could have been put alongside,
- 8:54right?
- 8:55Yeah.
- 8:55So this is an interactive web app table type thing.
- 8:59And it pulls data from GitHub's GraphQL API.
- 9:03And it lets you kind of like select different features and filter on those.
- 9:07You can compare and group tools together.
- 9:10So on the top left, you'll see there's like a bunch of little blue words with blue backgrounds
- 9:15and you can click on those.
- 9:16Yeah.
- 9:17And if you click on them, then it'll filter down the table.
- 9:19And so if you want to find tools that have, I can install and publish, you can click on
- 9:23like install CLI apps and also publish, publish packages.
- 9:27Nice.
- 9:27This is a great little UI.
- 9:29It reminds me of an app I wrote once and I'm having nice nostalgia here.
- 9:33It's cool.
- 9:34So you can sort of click on these little categories or filters and turn multiple ones on and off.
- 9:39So if I want virtual environment management that can install libraries, well, apparently
- 9:43there's none of those.
- 9:44But if I want to build packages and install CLI apps, well, I guess PDM is my choice, huh?
- 9:50Right.
- 9:51That's cool.
- 9:51So maybe one thing that we could do that would be nice is maybe we could go through and highlight
- 9:55some of the more notable packaging solutions or options as we go through here.
- 10:00You know, PipX being one of them, we'll get to that a bunch more, but want to maybe give
- 10:05us a bit of a rundown?
- 10:05Like probably the first really notable one is Conda.
- 10:08People are super familiar with that, right?
- 10:10On the data science side.
- 10:12Yeah.
- 10:12So Conda is kind of like a more ambitious way to create environments and it kind of
- 10:19makes its own ecosystem.
- 10:20I personally haven't used it, but I know it's pretty popular, like you said, with a scientific
- 10:24community.
- 10:24So it also can be used to make C libraries too.
- 10:27Interesting.
- 10:28Yeah.
- 10:28It's certainly the claim to fame of Conda and Anaconda and Miniconda, all those things
- 10:33is you don't have to have the build tools for all the libraries, the transitive closure
- 10:38of the libraries you want to use, right?
- 10:40My understanding is it's its own packaging system.
- 10:42Like you don't pip install from it.
- 10:44There's some other parallel ecosystem.
- 10:46Right.
- 10:46Exactly.
- 10:47And I feel like to some degree with wheels, we're a little bit closer than we used to be
- 10:52with pip directly, right?
- 10:54Pip install wheel can just drop in a thing, whereas previously stuff had to happen on your
- 10:58machine to finalize that package.
- 11:00Yeah.
- 11:00Wheels are specific to your Python version, your operating system.
- 11:05And so, yeah, that can just be basically unzipped and used.
- 11:08Yeah.
- 11:08That was fantastic, except for the first couple of weeks of the M1 platform, the Apple Silicon
- 11:14M1s.
- 11:14You try to install something.
- 11:16Nope.
- 11:16We don't have a wheel for that platform.
- 11:18What do you mean you don't have a wheel?
- 11:19Come on.
- 11:20I think that's pretty far in the past now.
- 11:22I haven't run into that problem for a long time.
- 11:23Cool.
- 11:24Another one on here that's clearly pretty popular and in this C generating native code category
- 11:31is Cython.
- 11:32Yeah, Cython is super interesting and it takes advantage of one of the pretty cool features
- 11:38of Python itself.
- 11:39So Cython can generate C code from your Python code and it generates shared objects and shared
- 11:47objects are able to be imported directly from Python.
- 11:49So you can make a basically like a wheel that is native code built from your Python code.
- 11:54And if you have code that is really run really frequently, like a really hot path, that Python
- 12:00is just a little bit too slow for you.
- 12:02You can really easily use Cython to convert that into C and make a shared object and then just
- 12:09use that, but just that module or just that function that you wanted to speed up.
- 12:13There's some interesting examples of that.
- 12:15For example, uvloop, which is the fast drop in replacement for asyncio, right?
- 12:21That was written in Cython and built on top of libuvc library, I think.
- 12:26Right now, here's one of those tight loops where this is the while true or the for in
- 12:32loop that does all the magic, right?
- 12:34And so doing something like this makes a lot of sense.
- 12:37Absolutely.
- 12:37Yeah.
- 12:38I was surprised how easy it was to use Cython.
- 12:40You can just basically run it, point out a file and it just converts it to C.
- 12:45And you can import it too.
- 12:46It makes the shared object.
- 12:47It's just kind of like you just run the command and it's just magically turns into something.
- 12:51Hopefully it all works, but it turns into something that runs a lot faster.
- 12:54Yeah, it really is neat.
- 12:56And if you use the Python type hints, it can get even a little bit better.
- 12:59Yeah.
- 13:00Or if you go farther, you can import the Cython integer instead of just a regular int and so
- 13:06on.
- 13:06Yeah.
- 13:06And now Cython has typing in Pythons.
- 13:09So Cython also has its own kind of parallel language where you write like pyx file and you
- 13:14have Cython annotations.
- 13:15But now with type hints becoming more prevalent in Python itself, there are also Cython type hints,
- 13:21which allows you to write just straight Python code, but Cython still recognizes how to,
- 13:26convert it to a statically typed C type.
- 13:29Right.
- 13:29I think that makes it way more approachable for many people because they don't feel like
- 13:32they have to go learn something different.
- 13:34They're like, well, if I just put type hints on this, maybe different type hints.
- 13:37Yeah.
- 13:37And we're good to go.
- 13:37Yeah.
- 13:38Which is pretty cool.
- 13:38Yeah.
- 13:39All right.
- 13:39That question from the audience from Juergen.
- 13:41Hey, Chad.
- 13:42What about Buildout?
- 13:43Made up your mind on whether to include it?
- 13:45What's the story with Buildout in this?
- 13:48On the Python packaging table, there were some suggestions in the issue tracker.
- 13:52And one of them was around Buildout.
- 13:54And it was something I hadn't heard of before.
- 13:57I'm still considering whether to add that or not.
- 14:00I think I will.
- 14:01Leaning towards yes.
- 14:02Okay.
- 14:02I don't think I've done anything with Buildout.
- 14:04Okay.
- 14:05Very nice.
- 14:05And also, I saw that Py2App could get...
- 14:09I don't think Py2App was there, was it?
- 14:10It wasn't.
- 14:11Yeah.
- 14:11So what's the criteria for being on that list, I guess?
- 14:14Yeah.
- 14:14I just kind of made it as a...
- 14:16Started just as the comparison to PIPX where people might be confused or wonder which one
- 14:21to choose.
- 14:22And then it's kind of just grown organically, just things I thought were interesting or relevant.
- 14:26I think they should be something that is still...
- 14:30So it's something that people would want to use because there's a lot of changes in the
- 14:34packaging landscape and there's a lot of stuff that kind of gets left behind that you really
- 14:37wouldn't want to use anymore.
- 14:38There's new tools being made.
- 14:40There's new standards being defined.
- 14:41So I want it to be something that's kind of like modern, relevant, something that's like
- 14:45encouraged to be used.
- 14:46I was concerned it was a little bit like maybe older and like I hadn't heard of it and you
- 14:52haven't heard of it.
- 14:53So I wasn't really sure how, you know, if it was something that we should still encourage
- 14:57folks to use or not.
- 14:58Yeah.
- 14:59Here's an interesting...
- 15:00Have you checked out the PSF developer survey results this year?
- 15:04I have not.
- 15:04Yeah.
- 15:04So they have a section on basically which tools related to packaging do you do to use?
- 15:10And they break it down by popularity, which I thought was pretty cool.
- 15:13That's really interesting.
- 15:14Yeah.
- 15:14So for people just listening, it's 81% of the people say they use pip and then 32% of people
- 15:21use VNV.
- 15:21I feel like that's pretty low.
- 15:23Honestly, it should be higher than what's going on there.
- 15:25But you've got 30% of people use containers, 23% use virtual ENV, and then 22% is condo.
- 15:32We've got poetry, pip, ENV, Afflit, PDM, and others are like way down, way down in the list
- 15:38there.
- 15:38Yeah.
- 15:39So anyway, does that strike you as what your mental model you had in mind a little bit?
- 15:43Yeah.
- 15:44Roughly.
- 15:44There's a few surprises in there.
- 15:46But I think all those should be in this table.
- 15:49If they're not, I'm going to have to check out that list and update the table.
- 15:52Sure, sure.
- 15:53Well, you know, maybe not the container stuff, right?
- 15:55Because that's kind of just like I have a virtual machine.
- 15:57I mean, virtual machines are also in there, right?
- 15:59It's like, which I think means I have a virtual machine, so I don't care if I just trash it
- 16:03and just bust its system, like customize its system Python.
- 16:06This portion of Talk Python To Me is brought to you by Mergify.
- 16:12It's an amazing tool to make you and your team way more productive with GitHub.
- 16:16Mergify is all about leveling up your pull requests.
- 16:20Some of the features include automatic merges.
- 16:22You explain the conditions for an automatic merge and Mergify will take care of merging the
- 16:27pull requests as soon as it's ready.
- 16:29Automatic updates.
- 16:30They merge your pull requests serially on top of each other, so there's no way to introduce
- 16:36a regression.
- 16:36Merge queues.
- 16:38Merge the urgent pull requests first.
- 16:41Organize your PR priorities as you wish, and Mergify will merge them in that order.
- 16:45Backports.
- 16:46Mergify will even copy your pull requests to other branches once the PR is merged, shipping
- 16:52your bug fixes in multiple branches automatically.
- 16:55Mergify features allow you to automatize what you would otherwise have to do manually.
- 17:01By saving time, you and your team can focus on projects that matter.
- 17:04Mergify is coordinated with any continuous integration and is fully integrated into GitHub.
- 17:09They even have a startup program that could give your company 12 months of credit to leverage
- 17:15Mergify.
- 17:15That's up to $21,000 in value.
- 17:18Start saving time today by visiting talkpython.fm/Mergify to sign up for a demo and get
- 17:25started, or just click the link in your podcast player show notes.
- 17:28Thank you to Mergify for sponsoring the show.
- 17:30Thank you.
- 17:30For me, when I set up my servers, I don't do that.
- 17:35I actually create a virtual environment for the apps running on that server, or maybe multiple
- 17:39ones, but often it's just running one service.
- 17:41So I just create a virtual environment for it, just for the isolation alone.
- 17:46So it doesn't say, well, you can't use this version of some library because it's being
- 17:49used by some part of the system.
- 17:51You can really cause yourself huge headaches messing with parts of the system.
- 17:55Like one time, I think I tried to rename Python.
- 17:57I think I repointed my Python 3 alias to a different, like a newer version of Python 3,
- 18:02because I wanted to use, I wanted that to just be what it used.
- 18:05And pretty sure my computer didn't start after that.
- 18:07Yeah.
- 18:09While I just have this page up, I just want to also show that PipX does show up over here
- 18:14on tools for installing packages instead of managing it.
- 18:17And yeah.
- 18:18Oh, very cool.
- 18:18Coming along there.
- 18:19Pretty cool.
- 18:20By the way, there is a PEP I saw around not clobbering system installs, where you have like
- 18:25Ubuntu managing its own Python packages, and you install to it, or you uninstall something
- 18:31and kind of like mess up your whole system.
- 18:33There's a PEP out there to address that and to not mix things in there.
- 18:36Oh, that's cool.
- 18:37I feel like almost Ubuntu and those different systems could say, we're going to have our
- 18:41own isolated environment for our stuff.
- 18:43And what you want to do, even if you just run Python straight, that's going to do something
- 18:47else.
- 18:47But yeah, I don't know.
- 18:49I don't know the mechanics of making all that happen.
- 18:51There's a lot of pieces involved there.
- 18:52Yeah.
- 18:52Yeah.
- 18:52The isolation is definitely useful.
- 18:55Okay.
- 18:55Back to the build stuff.
- 18:57Maybe there's a couple of others here.
- 18:59Like we've got the sort of what I would call pip alternatives.
- 19:03We've got FLIT and Poetry, right?
- 19:05Those are maybe, yeah, FLIP and Poetry and pip, E and V. I guess those are all in a similar,
- 19:11I know that I might be painting that with too broad of a brush, but they're all about installing,
- 19:15working with your environments, installing stuff into your environments for apps you're
- 19:19building, right?
- 19:20Yeah.
- 19:20And PyFlow as well.
- 19:21And Hatch.
- 19:22There's quite a few.
- 19:23Yeah.
- 19:23I'm not familiar with Hatch.
- 19:24Tell me about Hatch.
- 19:25I have heard Hatch mentioned, or I think I've seen it around for a while.
- 19:28I never really used it.
- 19:29But then the creator of Hatch recently added a pull request to PipX to use the Hatch backend.
- 19:36So with PEP 5.17 and 5.18, you can basically anything you want, install, build your wheel,
- 19:43build wheels.
- 19:45So you can have different backends to build a wheel.
- 19:48So Hatch has one called Hatch.
- 19:49Right.
- 19:49This is actually now in the packaging, the Python packaging documentation.
- 19:53Like if you go to like the Python packaging website, like I think it's packaging.python.org,
- 19:58there's instructions on how to like build, to build a package, to distribute it.
- 20:02And it uses the Hatch link backend, which is a big achievement now.
- 20:07It's no longer telling you to use setup.py, but it's telling you to use this new tool called
- 20:13build.
- 20:13Right.
- 20:14Which is also on your list right at the top.
- 20:15Yeah.
- 20:16And it's alphabetical.
- 20:17So yeah.
- 20:18Well, it wins with, I guess the A, A, A, A, A, V and V is maybe got a spot to still take
- 20:24the top notch there, but.
- 20:25That's a good idea.
- 20:26Nice.
- 20:26You do also have things like GitHub stars and stuff.
- 20:29Can you sort by them?
- 20:30Yeah, you can, right?
- 20:31I just added the star emoji and I think it screwed up the sorting.
- 20:34So I'll have to work on that.
- 20:35Oh, it sorts by alphabetical then with the start of the star.
- 20:38Yeah.
- 20:39Okay.
- 20:40The challenges we run into.
- 20:41Yeah.
- 20:41Yeah.
- 20:42So this is really cool.
- 20:43Anything else you want to give a shout out to while we're here before we move on?
- 20:46Py03 is super cool.
- 20:48I played around with that.
- 20:49So Py03 is a way to call Rust code from your Python code.
- 20:54So kind of similar to Cython, except it doesn't generate Rust code for you.
- 20:58You just, you have to have something already built in Rust, but it's pretty easy to use.
- 21:02There's a really popular Rust tool called RipGrep, which is like grep, but rewritten in Rust
- 21:06with a nice API and it's super fast.
- 21:09And one thing I tried just to kind of like learn Rust and learn Py03 was to write an API in Python
- 21:17that called into the RipGrep Rust code.
- 21:20Right.
- 21:20Okay.
- 21:21Cool.
- 21:21And that actually worked pretty well.
- 21:22I was pleased with the development process and how fast it all ran.
- 21:28Nice.
- 21:28All right.
- 21:29Let's see.
- 21:29One more bit of follow up on this that Juergen says,
- 21:32Tox will also use Hatchlane with version four, which is pretty cool.
- 21:36Nice.
- 21:36Yeah.
- 21:37I think that it's probably going to gain a lot more traction.
- 21:39Yeah.
- 21:40It sounds like I need to learn about Hatchlane and Hatch.
- 21:42Pretty cool.
- 21:43Another thing that's interesting here that is sort of in the same space that we could talk about
- 21:48is PEP 582.
- 21:51To me, PEP 582 feels a lot like node modules for Python.
- 21:55Sort of that.
- 21:56Where is the, what is it?
- 21:58Project.json and then the node modules folder next to it, right?
- 22:02There's a folder and it has a name.
- 22:04That's where your packages get installed to.
- 22:07And if you run Python commands below it, it will sort of traverse the directory up looking for that
- 22:13to find its effective virtual environment instead of the traditional virtual environment behaviors we all know.
- 22:18Right?
- 22:19Right.
- 22:19Yeah.
- 22:20Yeah.
- 22:20What are your thoughts here?
- 22:21I sort of stumbled across this.
- 22:23I don't remember how I found it, but when I saw it, I was like, oh my gosh, this is incredible.
- 22:28I can't wait for this to land.
- 22:30I'm a big TypeScript developer.
- 22:31I like TypeScript, I like JavaScript.
- 22:33So I can kind of compare the two because I do a lot of work in both.
- 22:36And when I saw this, I was really excited.
- 22:37Right.
- 22:38So you're like, this is the node version for Python.
- 22:40Yeah.
- 22:40There's a lot of headaches with global installs and globally installing packages and conflicting with the OS.
- 22:47And 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:54And so, and it's also a bit, it's part of the environment, right?
- 22:57Like Python packages is this file on a file system.
- 23:01You know, it's there.
- 23:02If you want to start over, you just RMRF the folder and you can start over.
- 23:07So 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:13I did too.
- 23:14Like, oh, this, we're, the next release, the world is different, right?
- 23:18Yeah.
- 23:18And so you can see on the, right.
- 23:21Yeah.
- 23:21And yeah, it says this is targeting version 3.8.
- 23:23It's still in draft status.
- 23:25And that was 2018.
- 23:26So it's four years ago.
- 23:28So one thing I want to mention is, as you mentioned, this is like node modules for Python.
- 23:33And one of the authors of the pet mentioned that he, he doesn't want folks to think of it like that.
- 23:38Although it's not a bad analogy, but it's more like an auto activated virtual environment or automatically recognized.
- 23:44So 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:54Like a fallback as you go up and yeah, yeah, yeah, yeah.
- 23:57I hear you.
- 23:58But to me, it seems like it would simplify a lot of stuff.
- 24:00For 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:10You know what I mean?
- 24:12You don't have to do a bunch of virtual environment stuff.
- 24:14It just, that's the one, right?
- 24:16Yeah.
- 24:16If 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:32But I often encounter people who are new to this and they kind of bounce off it, which is unfortunate.
- 24:37When 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:52You might be setting yourself up for some kind of failure.
- 24:54Right.
- 24:54It could get installed to their system.
- 24:56They might not have permission to install it to the system.
- 24:59There's a lot of stuff going on there.
- 25:00It 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:07If 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:14Right.
- 25:14And then all of a sudden your fail to ban or your firewall or something stops working.
- 25:18You're like, why did that stop working?
- 25:19Or glances or some other tool.
- 25:21You're like, I thought that was part of my machine.
- 25:24Now it doesn't work anymore.
- 25:25And, you know, your little test project or tutorial broke it.
- 25:27Right.
- 25:27Yeah.
- 25:28That's probably suboptimal.
- 25:29Yeah.
- 25:30So this was exciting to me because, you know, you could have pip install something and it would go to this PyPackages directory potentially.
- 25:36You wouldn't really have to worry about any other side effects or any kind of environment that you're affecting.
- 25:41Maybe someday.
- 25:41Yeah.
- 25:42Not for the moment.
- 25:42Yeah.
- 25:43Well, we do have this other tool called PipX that does manage this somewhat for a certain class of problems.
- 25:50Right.
- 25:50But this is more for building packages and applications and stuff.
- 25:54Not so much external tools, but still.
- 25:57Yeah.
- 25:57I think there are different use cases.
- 25:58Because I think this one's more for libraries, building your library or not necessarily the app.
- 26:04Yeah.
- 26:04Well, you pointed out some implementations or experimental things going on with this one.
- 26:10So let's see here.
- 26:11Yeah.
- 26:12So you got PyLock here.
- 26:13This is you, right?
- 26:14Yeah.
- 26:15That's fine.
- 26:15So PyLock is a drop-in replacement that imports packages from this directory.
- 26:20And it's like an experimentation or an experimental implementation of this, right?
- 26:24Right.
- 26:24Yeah.
- 26:24So I called it Python loc was the idea, like local, loc stand for like.
- 26:29Location.
- 26:29Yeah.
- 26:29It stood for like local packages, I was thinking.
- 26:31I don't know.
- 26:32The name's still a thing could be revised, I guess.
- 26:35But I saw the pet, but I thought it was super cool.
- 26:37And I thought, hey, maybe I can hack something together and let people try it.
- 26:40Because I think trying, discussing how something might work and actually using it is kind of like
- 26:45looking at a picture of somewhere you want to take a vacation and actually going there.
- 26:48You know, it's like going to a place versus just kind of like hearing description of it.
- 26:52So if we make something we can play around with, you can see, oh, this, I thought this would
- 26:56be cool, but it actually is way harder to use.
- 26:58Or maybe it's exactly what I thought I wanted and it's great.
- 27:01And, you know, let's accept the pet.
- 27:02So I made this just as a way for folks to easily experiment with this kind of workflow.
- 27:07Yeah.
- 27:08Okay, great.
- 27:09And people can play with it.
- 27:10Although, who knows where this idea is going?
- 27:12I still think it has legs, but yeah, it's been chilling for a while.
- 27:15And then there's PDM.
- 27:17I've heard of people using PDM and does this follow?
- 27:20Yeah, it seems like it follows the same idea, right?
- 27:22Tell us about PDM real quick.
- 27:24Yeah.
- 27:24So PDM is kind of like poetry.
- 27:25I mean, it uses PEP 5A2.
- 27:27So it uses the PyPackages directory.
- 27:30But yeah, it's similar in the idea of poetry or similar tools like PIPenv and all the ones
- 27:37you mentioned, PyFlow.
- 27:38So it creates and modifies the PyProject.toml file.
- 27:43It can add its own metadata to it.
- 27:45It can build packages.
- 27:46It can publish packages.
- 27:48I'd have to consult that table.
- 27:51But yeah, I think it's kind of like an all-in-one tool.
- 27:53And that also uses PEP 5A2.
- 27:55Right, exactly.
- 27:56So it does a lot more.
- 27:58But it does happen to also use this idea, right?
- 28:00Right.
- 28:01And in the discussion on...
- 28:03In the PEP 5A2 discussion on where all the folks are discussing the pros and cons, the developer
- 28:09of PDM mentions that, like what his experience was with it, some of the tweaks he had to make
- 28:15to the PEP to make it work for him.
- 28:17And I saw that there was some interest in it.
- 28:21And also PyFlow is another tool similar to PDM.
- 28:24It's written in Rust.
- 28:25But I saw, I think Brett Cannon was interested in working with those two folks to maybe flesh
- 28:31out PEP 5A2 a little more because they have some real world experience.
- 28:34Okay.
- 28:34Interesting.
- 28:35Yeah.
- 28:35It doesn't sound like the PEP is dead.
- 28:37It sounds like it's stalled is more maybe how I understand it.
- 28:41Yeah.
- 28:41I think one of the...
- 28:42So there were two original authors.
- 28:44One of them is no longer interested in pursuing it.
- 28:46But the other is, I think he's just been a little bit busy and hasn't had time to dedicate
- 28:50to it.
- 28:50But I think there's still potential for it.
- 28:52Sure.
- 28:52Okay, cool.
- 28:54Well, let's move on to the star of the show, PipX.
- 28:57How do you tell people about PipX?
- 29:00PipX is a tool to install and run applications that happen to be written in Python.
- 29:07I was going to say, too, I think of it as like Homebrew or AppGet or Chocolaty or one of these
- 29:13package managers where I just want to get this command or this application on my computer.
- 29:18I don't really care what it's written in.
- 29:20It's probably written in something tough that I have to install weird dependencies for or
- 29:25I got to have some odd compiler and I don't want to deal with it.
- 29:28I just want to...
- 29:29I know it if I type brew install handbrake or something, like I'll have that.
- 29:33Right?
- 29:34That's the way I see PipX is there's all these cool commands and CLIs and utilities in Python
- 29:40and they just happen to be in Python, right?
- 29:43Like we as Python developers care a lot that that's the case, but we just want the commands,
- 29:46right?
- 29:47And with PipX, you can just type PipX, say, install pytest or PipX install Glances or some
- 29:54other cool library.
- 29:55And sure enough, you'll have it installed, right?
- 29:57Yeah, that's the idea.
- 29:58One of the goals is to take away difficulty for end users to install a tool.
- 30:03A lot of times the instructions are like, you know, install with Pip.
- 30:07And like I said, you can have problems with that.
- 30:09That's kind of a loaded instruction sometimes to give people, especially if they're not Python
- 30:12developers.
- 30:13If you as a Python developer, if you see that you wouldn't really have trouble managing that.
- 30:17But as a lot of folks, a lot of folks out there that just want the tool and the instructions
- 30:21are kind of like install, create a virtual environment.
- 30:24Now run the pip from that environment to install this tool.
- 30:27Now search into that bin path and there's your binary.
- 30:31Like that's not really the easiest way to get end users a really cool program that you wrote
- 30:36that happens to be in Python.
- 30:37Right, right.
- 30:38I want to have this program accessible.
- 30:40Oh, wait, did you forget which virtual environment you installed it into?
- 30:43And did you forget to activate that or whatever, right?
- 30:46So this solves a lot of those problems, which is fantastic.
- 30:49Juergen again says, as you said, install and run Python applications.
- 30:53Does this refer only to CLI or even web apps?
- 30:55I'm not sure I understand the question.
- 30:57Certainly CLI apps.
- 30:59I'm not sure what a web app is in terms of this question.
- 31:02Sure.
- 31:02Well, I guess maybe just can it install stuff more broadly?
- 31:05Like if I had something maybe that was built with GUI, for example, G-O-O-E-Y, like that
- 31:11GUI framework, or I have something that was installed or built with some other tool.
- 31:16That when I run it, maybe I don't get a CLI experience.
- 31:20Maybe it installs Flask and opens a browser or something like that, right?
- 31:24I think that's the question.
- 31:25Yeah, absolutely.
- 31:26That's actually where I found the need for PipX most.
- 31:30And the tool I made that happens to be a web app where I have these...
- 31:33So the tool is called GDB GUI, and it's a web app that lets you debug programs with GDB.
- 31:39Right.
- 31:39And so I was ready to read me to tell folks how to get it, how to run it.
- 31:44So people that are trying to debug things with GDB, maybe they're Python developers, but they're
- 31:49definitely C developers or Rust developers, some kind of a native language.
- 31:54So the read me instructions I wrote were, I kind of like struggled with how to tell people
- 31:59to install this.
- 32:00Telling them to install pip with pip was not something I was comfortable with because there
- 32:04are so many dependencies GDB GUI has, and I didn't really want to like break their system.
- 32:08There was kind of two fears.
- 32:09Like one, I didn't want to mess their system up.
- 32:10And two, I didn't know if it would work reliably because there was, maybe they would install
- 32:15something else and mess it up.
- 32:17I searched for a while to find something that could get this installed in a better way.
- 32:22And I'm Pipsy.
- 32:23Okay.
- 32:24So yeah, Pipsy like this.
- 32:26Yeah.
- 32:27Yeah.
- 32:27P-I-P-S-I.
- 32:28Okay.
- 32:28This is basically exactly what I wanted.
- 32:31It gives you a single command that creates a virtual environment, installs package there,
- 32:36and that exposes the binary entry point, which sounds familiar.
- 32:39It is because that's what PipX's origin is from.
- 32:43Right.
- 32:43And in fact, right at the top of the Pipsy read me, it says,
- 32:46Pipsy is no longer maintained.
- 32:47You should check out PipX.
- 32:49Right.
- 32:50The origin of PipX came from one of the issues in Pipsy where someone,
- 32:55we were kind of having trouble getting changes merged to Pipsy.
- 32:59I found it.
- 32:59I was really excited.
- 33:00And I started making a bunch of pull requests on it.
- 33:02And I was having trouble getting things merged.
- 33:04And basically the maintainers, they were okay with having it in maintenance mode,
- 33:08but they didn't really want to do active development with it.
- 33:10And the owner, which was Armin Roedeker, he had sort of unsubscribed from the project.
- 33:16And wasn't really following it.
- 33:17And so he was the only person that was able to give more access to let people become maintainers
- 33:22or so on.
- 33:23So we were able to add ourselves as maintainers.
- 33:26So we were kind of stuck with this tool.
- 33:27We could like, maybe we could fork it.
- 33:28Maybe we could make a new tool.
- 33:30Yeah.
- 33:30So how'd you get from there to PipX?
- 33:32As I said, I was like, I'm into also TypeScript and the JavaScript community.
- 33:36And one of the tools they have there is called NPX, which is pretty similar to PipX.
- 33:41It lets you run CLI apps from Node, who also can have similar challenges because it's an interpreted language.
- 33:47And so I made PipX to kind of add that capability to Python.
- 33:51And 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:57It's very similar to installing it.
- 33:59It's basically installed in a temporary place and runs it versus installing it in a permanent place.
- 34:04And so I added the install capability on PipX.
- 34:06I shared it with some of the folks in the issue tracker.
- 34:08And they were like, this works for me.
- 34:11Let's go use that.
- 34:12And this is it.
- 34:13Yeah.
- 34:14The momentum continued around it and had a lot of really great contributors work on PipX.
- 34:21Yeah, that's great.
- 34:21The GitHub repo says 75 contributors and 5,000 GitHub stars, which is pretty awesome.
- 34:27Yeah.
- 34:28I'm really happy with it.
- 34:31This portion of Talk Python To Me is brought to you by the Python at Scale Summit.
- 34:36The Python at Scale Summit is a conference to highlight innovative big data solutions for Python developers and enterprises.
- 34:43You'll learn about trends in the Python big data ecosystem, share stories about implementing solutions,
- 34:48find out about new innovations, and connect with other data scientists using Python.
- 34:53The Python at Scale Summit will be a hybrid conference with talks, workshops, and training.
- 34:59Of course, there will be networking and social events to connect with other Python professionals, too.
- 35:04Come hear speakers like Matt Rockland from Coiled, Brian Granger from AWS,
- 35:09and many others from amazing organizations such as NASA, Capital One, and BCG.
- 35:14Get back together with your peers and learn how they're scaling their computation and data analysis
- 35:19using Python and the data science stack.
- 35:22Register at talkpython.fm/python dash at dash scale.
- 35:27When you visit the link, be sure to use the code TALKPYTHON, all caps, to get 15% off your tickets.
- 35:34That's code TALKPYTHON at talkpython.fm/python at scale.
- 35:38The link's in your podcast player's show notes.
- 35:40Thanks to the Summit for supporting the podcast.
- 35:43I use it all the time.
- 35:45I personally really like it, and I'm really glad to see other folks are enjoying it as well.
- 35:50Yeah, I use it all the time.
- 35:53It's one of my go-to tools when I want to check out something I know is built with Python as an application,
- 35:58or I get a new machine.
- 35:59We can talk about some of the fun stuff to install in a little bit,
- 36:03but maybe let's first talk about what happens and how do I use PipX?
- 36:08What's the process?
- 36:09You do have a nice animated GIF on the GitHub project so people can see what happens,
- 36:14but maybe walk us through it.
- 36:15Let's say Glances.
- 36:17Glances is a fantastic application that you can use,
- 36:21and if you run it on your machine, it gives you this super rich terminal-based real-time view into your servers.
- 36:29It's much, much better than top or something like that.
- 36:32It also has a web view and whatnot.
- 36:34So that's a thing that people might not care about Python for,
- 36:38but it happens to be written in Python, so it's a perfect thing to PipX install.
- 36:42Exactly.
- 36:43Yeah, so talk us through, if I have PipX install Glances, what happens?
- 36:46Yeah, sure.
- 36:47So the first thing is PipX will try to determine which package you're trying to install.
- 36:53So you can give it just a name Glances, or you can give it basically any pip specifier,
- 36:58any kind of, it can be a Git repository, it can be a wheel, anything pip can install, PipX can install.
- 37:04So first it will make sure that it's a valid package specification.
- 37:07Then it will create a virtual environment in this directory that PipX manages.
- 37:13So it'll make a virtual environment with the name of the package.
- 37:15It'll make a Glances virtual environment.
- 37:17Then it will do some introspection on the, that it will install Glances into the virtual environment.
- 37:23So now we have a virtual environment with Glances installed,
- 37:26but it's not accessible anywhere other than inside that virtual environment.
- 37:29And so the next thing it does is it does some introspection on the virtual environment to say like,
- 37:34what binaries do we have available?
- 37:36And so it would be expecting Glances to be available.
- 37:40And it will then take, it'll find the path to the Glances binary and create a symlink into a directory on your path,
- 37:48on your, on your shell's path.
- 37:49So that when you run that command, it's available.
- 37:51Right.
- 37:52So for example, you need to have, in your little example here was home slash csmith slash dot local slash bin.
- 37:59And then that's the folder where all the symlink stuff gets linked over.
- 38:03You can also do those with entry points, right?
- 38:05It'll find the entry points and make them available.
- 38:07Yeah.
- 38:07So these are cons.
- 38:08These are, these are entry points.
- 38:09These are the console scripts.
- 38:10Okay.
- 38:11So that leads me to a question out in the audience from Ratul.
- 38:14Ratul says, this looks great.
- 38:16Not sure if I missed it, but how do you get your built Python app to be pipx installable?
- 38:21So you said it has to be pip installable, but then I think the other point here,
- 38:27you would have to expose some functionality in a way, and that could be entry points, right?
- 38:31Yeah.
- 38:32So pretty much that is the, essentially the only way is this, is the console script entry point.
- 38:37So you can look this up.
- 38:38It's a kind of well-defined part of the packaging specifications, but you can define a function
- 38:45that you want to call from a console script entry point.
- 38:49Yeah.
- 38:49So in your setup, you would say something like set up tools dot setup entry points equals,
- 38:53and then you give it a list of a command and then basically a module colon function, right?
- 38:59So here's this example that I'll link to in the show notes is, is hello world equals hello
- 39:04world, which is the module name colon say hi, which is a function in hello world.
- 39:09And once you pip install that into a virtual environment, you could just type hello world
- 39:12and it would do whatever it does for that function.
- 39:14But what you're saying is if you install with pip X, it finds these and creates basically
- 39:19binaries that the system can see that it thinks it can run called hello world, for example.
- 39:24Yeah.
- 39:25When you pip install something that has a console script, it makes this like a shell script that
- 39:30calls that function for you.
- 39:32And so these shell scripts just get sim linked out onto your path by pip X.
- 39:37Got it.
- 39:37Yeah.
- 39:37So it's basically doing the install.
- 39:40It's creating the virtual environment automatically behind the scenes.
- 39:43It's installing, doing basically pip install on the package, but that drags in all of the
- 39:49dependencies.
- 39:49But the important thing is every one of these commands, or I guess the thing you pip X install,
- 39:54it can have multiple commands as part of it.
- 39:56It gets its own virtual environment that's isolated, not just from the rest of the system,
- 40:00but all the other pip X things as well.
- 40:02So they're versioned and they live independently, right?
- 40:04Exactly.
- 40:05Yeah.
- 40:05You can have more than one console script too.
- 40:07A lot of times package will have, you know, two or three, four console script entry points
- 40:11and pip X will find all those.
- 40:12Nice.
- 40:13Yeah.
- 40:13One that comes to mind is pi jokes.
- 40:15Are you familiar with pi jokes?
- 40:17Yeah.
- 40:17I've heard you guys talk about that on the podcast before.
- 40:19Yeah.
- 40:19Pi jokes is a good one.
- 40:21So this one has entry points and I always get this through pip X.
- 40:25I just, you know, pip X install pi jokes and you end up with a bunch of, who'd they say
- 40:32pip X, right?
- 40:33And then you can run pi joke or pi jokes.
- 40:36And even as a program API and you get really deep jokes.
- 40:41Like why did the programmer quit their job?
- 40:43Because they didn't get a raise.
- 40:44A raise is in like lists.
- 40:47But you know, it's those types of things, right?
- 40:49You don't necessarily care that pi joke is written in Python.
- 40:52I mean, the name would maybe make you think it should be, but right.
- 40:55You just want to have a command that you can type something and get a funny programmer joke
- 40:58out of it.
- 40:58Right.
- 40:58But maybe we could touch on some of the other things that are more useful than pi joke.
- 41:03Like one you mentioned was the GDB GUI.
- 41:06I gave a shout out to glances because glances, I said, is fantastic.
- 41:10I use glances all the time.
- 41:11It just happens to be written in Python, but I just want it on my server.
- 41:14Maybe another one that pointed out was HTTP pi.
- 41:17HTTP pi, HTTP IE.
- 41:20Do you use this one?
- 41:21I have not used it too much, but I would love to find an opportunity to use it.
- 41:25Prefer it over things like curl.
- 41:27Yeah.
- 41:27I love HTTP pi.
- 41:29It works just like curl in a lot of ways, but the results that it gives you, it gives you
- 41:35syntax highlighting, easy ability to say, just show me the headers and the response, the
- 41:41response headers and stuff that came back and cookies.
- 41:43And it, you know, does highlighting on those.
- 41:46It's really nice.
- 41:47So just pipx install HTTP pi, and then you get HTTP as a command and HTTPS.
- 41:53Here's another one with two entry points, right?
- 41:55So if you just want to say HTTP, you know, 127.0.0.1, you don't have to say HTTP colon slash
- 42:02slash server name.
- 42:03You can just say the command, either HTTP or HTTPS, and it'll, it'll do it.
- 42:07It's just a little bit shorter.
- 42:08Right.
- 42:09So this one, big fan.
- 42:11But what was surprising to me about this is, you know, this is backed by a company, right?
- 42:16There's like a whole bigger organization behind HTTP pi than I realized, I believe.
- 42:22So I was impressed with their website.
- 42:24It was a lot more polished than a lot of other open source projects.
- 42:27So I'm not surprised to hear that they're funded or they're part of a company.
- 42:30Yeah, exactly.
- 42:31At the bottom, it says like job, there's a whole job section.
- 42:34There's apparently four jobs for HTTP pi, which is incredible.
- 42:37At the same time, it's a fantastic tool.
- 42:40Yeah.
- 42:40So, you know, good on them.
- 42:42Let's see.
- 42:43Maybe some of the other ones.
- 42:44I know we had a little bit of list of stuff that could be fun.
- 42:46Pi installer, pi to app.
- 42:48Let's see.
- 42:50Pi installer, pi to app, Cython.
- 42:52A lot of the package management stuff.
- 42:55Poetry, pipenv.
- 42:57Yeah.
- 42:57Anything else you want to give a shout out to?
- 42:59I've got one I want to use as well, but go ahead and do yours.
- 43:01Another program I made, I guess I'll plug my own, one of my other projects, it's called
- 43:06Term Pair.
- 43:06So this is actually kind of a web app.
- 43:09It lets you share your terminal session through the web.
- 43:13But it does it by encrypting all the output and input from your terminal.
- 43:17And so basically you run this command term pair share, and then it will start sharing through
- 43:23this server.
- 43:24And then you can either, you can control it from the web app or you can control it from
- 43:28the terminal.
- 43:28And the process running in the terminal is a Python app.
- 43:32And then, of course, the web app is JavaScript React.
- 43:35Yeah.
- 43:36How interesting.
- 43:37Does it give you your normal shell or is it like a bare bash or Z shell or something?
- 43:42By default, it uses...
- 43:43Like if I do a super configuration of my shell, make it like all blinged out, and then I run
- 43:49this, do I get the same crazy configuration or is it a simpler version?
- 43:52No, it's the exact same thing.
- 43:53It'll just run whatever shell, whatever the shell environment variable is that you're running.
- 43:57It'll just, that's the default command.
- 43:58You can run any command you want.
- 44:00If you want to run Python, you can run Python.
- 44:01It'll share your Python session.
- 44:03You can run anything really.
- 44:05But if you run a shell, that's the most familiar thing, I think, for sharing.
- 44:09Sure.
- 44:09Sure.
- 44:10Interesting.
- 44:11It'll share basically any CLI thing, huh?
- 44:13It spawns a PTY process.
- 44:15And then any output or input just gets written and behaves like any other terminal would.
- 44:21So you can do stuff like, you know, this is HTOP where you're interacting with it.
- 44:25And it's kind of like rewriting lines to the screen.
- 44:28And it's able to handle all that.
- 44:29It might be a nice way to help people who are like, you know, I'm stuck.
- 44:33I can't get this to work.
- 44:34You're in an email exchange or a Zoom meeting or something.
- 44:37You know, run this and give me the link.
- 44:38And I'll just, let me just ask your system a question real quick and see if it does the same.
- 44:42You got to have a lot of trust to give this over to people though, right?
- 44:45Yeah.
- 44:45You know, I made it because it seemed really fun.
- 44:47It was a challenge.
- 44:48It seemed fun.
- 44:50Practically speaking, yeah, I don't know how often it's used.
- 44:53You'd have to totally trust somebody to not.
- 44:55I mean, they have full control over your computer.
- 44:57Sure.
- 44:57It's not that different than going to a Zoom meeting and say, allow so-and-so to share,
- 45:02to control my mouse and keyboard or team viewers or something like that.
- 45:06Yeah, that's true.
- 45:06Yeah.
- 45:06Yeah.
- 45:07But still pretty neat.
- 45:08I don't know.
- 45:08It's just so more visceral.
- 45:09It's right there.
- 45:10You could just RMRF it right there.
- 45:11Yeah.
- 45:12There's another one I want to pull up here.
- 45:14This one, PLS.
- 45:17Do you use PLS?
- 45:18Any?
- 45:18Yeah, I've tried it out.
- 45:19It's pretty cool.
- 45:20I like that you can do so many different things.
- 45:24I like how easy it is to develop applications in Python, where you can just kind of make whatever
- 45:28customizations and hack things up really quickly.
- 45:31Absolutely.
- 45:31So PLS, it's a little hard probably to see over the screen share.
- 45:35It's a replacement for LS.
- 45:36And I know there are many replacements for LS, but this one is cool because it's a developer-friendly
- 45:41one.
- 45:41And so when you interact with it, it will use a lot of different things.
- 45:47For example, it'll show icons for Python logos next to .py files, JavaScript logos next to
- 45:53JS files, and so on.
- 45:55But it will also use git ignore files to decide what shows up in the basic view.
- 46:01It'll show you the git status of the file.
- 46:03When you do a PLS --details, you'll see which files in that listing are modified
- 46:09in git, according to git, and so on.
- 46:11So there's just a ton of fun stuff here that you can check out.
- 46:14I definitely think it's neat.
- 46:15Here's some examples of some of the colors.
- 46:17For example, poetry.lock, because it's git ignored, but still important.
- 46:22It shows up, but it's a very faint color, whereas other files show up with regular colors.
- 46:28So this one is another one that's good to pipx install, right?
- 46:31Because you just need it once for your computer.
- 46:33Yeah, I love those colors too.
- 46:34Great color scheme.
- 46:35Yeah, yeah, absolutely.
- 46:36And apparently you can build little plugins and stuff for it, I think, in Python.
- 46:40I haven't tried to do that.
- 46:41I've just tried to use it as a user.
- 46:43But yeah, that one's a fun one.
- 46:46For a while, I replaced LS with it.
- 46:48That wasn't a super idea, because it behaves weirdly.
- 46:53If you try to LS something and it doesn't exist, you get a traceback exception instead of just doesn't exist or nothing.
- 47:01It's not perfect, but as a thing that you have hanging around, it's definitely quite neat.
- 47:06Yeah, replacing system utilities can get kind of risky.
- 47:09Yeah, you just got to know what you're doing.
- 47:13I'm willing for this to mildly break stuff.
- 47:16But 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:21Or 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:28Yeah.
- 47:28Well, 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:37Give us a look inside real quick, and then maybe we could wrap things up.
- 47:41Any interesting internals of PipX?
- 47:43Let's see.
- 47:44Yeah, yeah.
- 47:44Like notable libraries that it uses or something that's really valuable in there.
- 47:48I was poking around the PyProject.tabble, and there's like argcomplete.
- 47:54Sounded interesting to me.
- 47:56And then a user path is new to me as well.
- 47:59Okay, yeah, yeah.
- 47:59Sure.
- 48:00So argcomplete, I'm a huge fan of.
- 48:02Argcomplete is a package that, so if you use argparse, which is the standard library's argument parsing package,
- 48:10a lot of times you'll want to have like tab completion and tab completion can be really hard to write.
- 48:15And so argcomplete gives you a Python API to tell it how tab completion should work.
- 48:21And 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:29And 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:40And then it gives you that tab completion just like you'd expect.
- 48:43And it also does it across shells.
- 48:45So 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:53And 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:59And then boom, you have tab completion.
- 49:01Right.
- 49:01Yeah.
- 49:02There's a whole section where you talk about how to install completion in here for the shells.
- 49:08So, you know, do you do that for, if you just type PipX space completions, it'll tell you how to do that, right?
- 49:14Right.
- 49:15And argcomplete's useful for, I mean, I actually added it for Knox.
- 49:18I'm a big fan of the tool Knox, which is also PipX installable and Knox.
- 49:23A lot of times you want to, there's only a lot of sessions.
- 49:25You run sessions in Knox and there's a whole bunch of them.
- 49:28And so having a tab completion on that was a feature I really wanted.
- 49:31And I think, I think that's where I first found out about argcomplete.
- 49:33And then I started adding it to other projects after I found out how easy it was to use.
- 49:37Right.
- 49:37You're like, this is not that hard.
- 49:38I want this.
- 49:39Yeah.
- 49:39Yeah.
- 49:40Cool.
- 49:40The other thing that people need to remember to do is to run PipX ensure path, right?
- 49:46Right.
- 49:47Because you talked about, we talked about that .local slash bin in your user profile, at least on macOS.
- 49:52I don't know if that's where it goes.
- 49:53It might go somewhere else in Windows.
- 49:55But you want to make sure that's in your path.
- 49:57So that'll basically modify whatever your active shell profile is to make sure it's in your path, right?
- 50:01That's right.
- 50:02Yeah.
- 50:02And you can also modify where that binary directory is with an environment variable if you want.
- 50:08Okay.
- 50:08How well does this work on Windows as well?
- 50:11Does it work there?
- 50:12Is it like PowerShell friendly and stuff like that?
- 50:14So it does work on Windows.
- 50:15I know that one of the contributors is one of the maintainers is a Windows user.
- 50:19And I don't see a flood of Windows issues coming in about this doesn't work on Windows.
- 50:25So it should work on Windows.
- 50:27Yeah.
- 50:27Yeah.
- 50:27Yeah.
- 50:28Perfect.
- 50:28Okay.
- 50:29And then it can upgrade itself.
- 50:31If you do pip upgrade like --user or something like that.
- 50:35It doesn't install itself.
- 50:36I'm considering making a new installer where pipX installs itself with pipX.
- 50:41I'm not sure I'm going to land that.
- 50:42Right now we install pipX with pip.
- 50:45And so you would just upgrade it normally with like pip upgrade pipX.
- 50:48Sure.
- 50:48Okay.
- 50:49Or it's pip install dash user.
- 50:50Sorry.
- 50:51Another thing that I like about pipX is you can just say pipX.
- 50:54What is it?
- 50:55Upgrade all.
- 50:55Yeah.
- 50:56Or there's a command to just upgrade.
- 50:58You know what?
- 50:58Give me a new version of all my libraries.
- 51:00Which comes back to similar with apt.
- 51:03Similar to homebrew, right?
- 51:05There's a brew update and outdated and just show me the stuff that could be updated.
- 51:09And then we'll just do it.
- 51:10Same with Chocolaty.
- 51:11Just to keep the tools used fresh.
- 51:13It's really nice.
- 51:14Yeah.
- 51:14It kind of goes back to like, I have this program.
- 51:16I don't really care about that.
- 51:18It's written in Python.
- 51:18I just want this thing to work.
- 51:20I want the newest version of it and just kind of make it happen.
- 51:23Right.
- 51:23And but if we reverse that and we're talking to Python developers, as most people listening
- 51:27are, you can empower people to deliver their applications to end users in a way that is
- 51:33much, much, much simpler if they're not Python people, right?
- 51:37Yeah.
- 51:38If they can get PipX on their machine, then getting the rest of their stuff is basically
- 51:42done, right?
- 51:42That's a great point.
- 51:43Yeah.
- 51:43I mean, the distribution story gets a lot easier for your users.
- 51:47If you're a developer and you want to get this in people's hands, having them use PipX
- 51:51is going to cause them less headaches and it's going to cause you less headaches because it's
- 51:54going to be more predictable environment to install in.
- 51:57Because PipX kind of lives in the center of a few things.
- 52:01Like you have wheels, which are pre-built packages specific to your operating system.
- 52:07And you have pip and PipX and virtual environments.
- 52:11And PipX kind of marries them all together in a way where it takes the pre-built, doesn't
- 52:16have to rebuild it on the user's computer.
- 52:17It takes this pre-built thing that works.
- 52:19It puts it in a place that's not going to disturb anything.
- 52:22It's not going to get disturbed either.
- 52:23And then it makes it accessible to the end user.
- 52:25And they don't have to think about any of those pieces to get it on their computer.
- 52:29Yeah.
- 52:30So maybe one of the biggest takeaways is if you're trying to deliver Python applications
- 52:34to people, here's a really good option.
- 52:37If some kind of CLI starter is the way to go, right?
- 52:41I guess if you want, here's how you drag it over to your applications folder and put it in
- 52:44your doc.
- 52:44Maybe that's not the right thing.
- 52:45But you know, for a lot of the type of stuff people are building with Python, it's a great
- 52:49way to get it to end users and keep it up to date.
- 52:52One other thing I'll call out is pipx run.
- 52:55Yes.
- 52:55Yeah.
- 52:55We've talked about install the whole time.
- 52:57But yeah, pipx run is maybe even better for certain things.
- 53:00Yeah.
- 53:00So pipx run will make sure you have a recent version of the tool you're trying to use.
- 53:05So if you want to run some kind of a bootstrap program or some kind of like cookie cutter
- 53:08where you create a new project or something like that, then you'd want it to run with the
- 53:12recent version.
- 53:13pipx run will just kind of make it happen for you.
- 53:16Right.
- 53:16So one of your commands might be, well, first, you're going to set up a virtual environment
- 53:20and then you're going to pip install cookie cutter.
- 53:22Then you're going to run cookie cutter this thing.
- 53:24Right.
- 53:25Right.
- 53:26Well, maybe the step is if you already have pipx, assuming this is a thing that's accessible,
- 53:30pipx sort of install run cookie cutter and you give it that command.
- 53:34Nobody needs or wants cookie cutter after that.
- 53:37They just need cookie cutter to run the skeleton generator for their project.
- 53:41And then their project is kind of free from cookie cutter because you can't update your
- 53:44project afterwards anyway.
- 53:45Right.
- 53:45That's probably a good mental model to have.
- 53:47Yeah.
- 53:48And that's how the JavaScript world uses it.
- 53:50It's kind of like, it's one of the really popular ways.
- 53:52And you'll see the NPX, you know, create React app is a way to start React apps with,
- 53:57with the latest version of that cookie cutter type thing.
- 54:00And so I would love to see more adoption on, on that side in the Python world.
- 54:04Yeah, absolutely.
- 54:05Another one, I guess, let's just real quick, maybe give a shout out to this is the Node.js
- 54:10thing that just got added.
- 54:12Isn't there a way that just came out for installing Node.js as a dependency, not just the bindings?
- 54:19I feel like there just was.
- 54:20Yeah.
- 54:20I saw something about this.
- 54:22Yeah.
- 54:22Actually, I think we just covered it on Python bytes, but I wasn't the one who brought it up.
- 54:26So I don't totally remember.
- 54:27Let's see.
- 54:28There you go.
- 54:28Node.js dash bin.
- 54:29That's it.
- 54:30Gina Houska covered it.
- 54:32And yeah, there it is.
- 54:34Node.js dash bin.
- 54:35So if you've got something that needs to have the Node tools around or, or CLI stuff,
- 54:40you could, you could just pip install Node.js dash bin.
- 54:42So I guess you could also pip and X install Node.js dash bin.
- 54:45Yeah.
- 54:46Maybe if it's a, if it's an entry point, then for sure.
- 54:49Yeah.
- 54:50I haven't thought enough about it, so maybe it doesn't quite fit in there, but it's an interesting,
- 54:53interesting development.
- 54:54All right, Chad.
- 54:55Well, I think we're probably out of time for talking about pipX.
- 54:58Let's maybe wrap things up.
- 55:01Any final thoughts or anything you want to add to this before we get to the final two
- 55:05questions?
- 55:06No.
- 55:06Thanks for having me on and sharing some discussion on pipX.
- 55:10Yeah, absolutely.
- 55:10It's a great tool.
- 55:11All right.
- 55:12Final two questions.
- 55:13If you're going to write some Python code, if you're going to work on pipX or your terminal
- 55:17replicator or whatever you're doing, what editor are you using these days?
- 55:20I use VS Code.
- 55:21Yeah.
- 55:21It sounds like Meta is pretty standardized on that.
- 55:24Is that right?
- 55:24That's our company-wide editor.
- 55:26Do a lot of work on writing extensions for it and making it work for developers in Meta.
- 55:30Yeah.
- 55:30Cool.
- 55:31And then we've talked about a ton of PyPI packages, but one you want to give a particular
- 55:36shout out to?
- 55:37Yeah.
- 55:37So this one is not pipX installable, but I think it's super cool.
- 55:40MK docstrings.
- 55:41And this is a way to generate documentation from your code.
- 55:45I think it's similar to Sphinx.
- 55:47I haven't really used Sphinx too much, but I find MK docstring is really user-friendly.
- 55:51It's all marked down.
- 55:52And I think it's really like a good looking UI that it generates for you.
- 55:58I think it's really easy to use and it gives you a nice end result too.
- 56:00Cool.
- 56:01Fantastic.
- 56:01Good recommendation.
- 56:02All right.
- 56:03Final call to action.
- 56:04People want to play with PipX, develop Python apps that can be installed through PipX and
- 56:10so on.
- 56:10What do they do?
- 56:11How do they get started?
- 56:11How do they get started developing apps for PipX?
- 56:14So you can use any of those tools to get a piproject.toml file and have a publishable package and make
- 56:21sure you have a console script entry point.
- 56:24Really, all you have to do is have a console script entry point for your package and then
- 56:28PipX will take care of it for you.
- 56:31Yeah.
- 56:31It's worked with everything that I've tried it with.
- 56:33So it seems pretty solid.
- 56:35Great.
- 56:35Yeah.
- 56:35Awesome.
- 56:36All right.
- 56:36Well, thanks again for being here and for working on PipX.
- 56:39It's a great project.
- 56:42This has been another episode of Talk Python To Me.
- 56:44Thank you to our sponsors.
- 56:46Be sure to check out what they're offering.
- 56:48It really helps support the show.
- 56:49Mergify is an amazing tool to make you and your team way more productive with GitHub.
- 56:54It's all about leveling up your pull requests.
- 56:56With automatic merges, auto updates, PRQ prioritization, and backports, you'll tame your
- 57:02PRs once and for all.
- 57:04Get started at talkpython.fm/mergeify.
- 57:07Sign up for the Python at Scale conference to connect with your data science colleagues
- 57:12and learn about trends in the Python big data ecosystem.
- 57:15Share stories about implementing solutions and find out about innovations in our space.
- 57:20Visit talkpython.fm/python dash at dash scale.
- 57:25That's talkpython.fm/python at scale.
- 57:27And use code talkpython to get 15% off your ticket.
- 57:31Want to level up your Python?
- 57:33We have one of the largest catalogs of Python video courses over at Talk Python.
- 57:37Our content ranges from true beginners to deeply advanced topics like memory and async.
- 57:42And best of all, there's not a subscription in sight.
- 57:45Check it out for yourself at training.talkpython.fm.
- 57:48Be sure to subscribe to the show.
- 57:50Open your favorite podcast app and search for Python.
- 57:53We should be right at the top.
- 57:54You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 57:59and the direct RSS feed at /rss on talkpython.fm.
- 58:03We're live streaming most of our recordings these days.
- 58:07If you want to be part of the show and have your comments featured on the air,
- 58:10be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 58:15This is your host, Michael Kennedy.
- 58:16Thanks so much for listening.
- 58:18I really appreciate it.
- 58:19Now get out there and write some Python code.
- 58:21I'll see you next time.