Latest / Talk Python To Me / #127: Shipping software to users
Transcript
- 0:00To make software useful, honestly, to even make it real, you have to ship it.
- 0:03Building that web app? Then get ready to deploy it. Building a tool set for data scientists?
- 0:08How are you going to send them that application? Did you manage to get a cool GUI app going in
- 0:12Python using PySign? It's time to have your users start downloading it. Python is an amazing
- 0:17ecosystem, but one of the frailer parts of it has been shipping or deploying software,
- 0:21especially to end users. In this episode, you'll meet Cliff. Join the two of us as we discuss
- 0:26where we are and where we're going with shipping Python code. This is Talk Python To Me,
- 0:32episode 127, recorded June 12, 2017. Welcome to Talk Python To Me, a weekly podcast on Python,
- 0:53the language, the libraries, the ecosystem, and the personalities. This is your host,
- 0:58Michael Kennedy. Follow me on Twitter where I'm @mkennedy. Keep up with the show and listen to past
- 1:02episodes at talkpython.fm and follow the show on Twitter via at talkpython. This episode has been
- 1:09brought to you by Rollbar and Datadog. Be sure to check out what they're offering during their
- 1:14segments. It helps support the show. Hey, everyone. Two things I want to share quickly before we jump
- 1:19into the conversation with Cliff. First, when we started talking with him about what he's up to
- 1:23day to day, at the time of the recording, he couldn't announce the company name or say too much
- 1:28about what he was doing. But they have since launched, and their name is Pilot. Pilot does
- 1:33bookkeeping for startups using a combination of expert human bookkeepers and software automation.
- 1:38It's a software service that does your books, not an app for you to do your own books. So you can find
- 1:44out more about them by visiting pilot.com. And while you're there, you can imagine that
- 1:49Glyph has definitely shipped some Python code to it. Next, I have a new course to announce. I just
- 1:54released RESTful and HTTP APIs in Pyramid. This course will teach you the mechanics of building
- 2:01amazing APIs in Python, of course. But you also learn the theory of RESTful HTTP services in general,
- 2:07how to design them, when and how to use HTTP verbs and status codes, content negotiation,
- 2:13and even a little SQLAlchemy. Check the course out at talkpython.fm/REST. That's R-E-S-T.
- 2:19Now let's talk about shipping some software. Glyph, welcome to Talk Python.
- 2:23It's great to be here.
- 2:24Yeah, it's a real honor to have you on the show. You've done so much cool stuff. And
- 2:28I'm surprised our paths haven't crossed more, but I'm glad they're crossing today.
- 2:32Same here. And I gotta say, I know you're always so complimentary of your guests, and it's an
- 2:37honor to be on the show. But I gotta say, you podcasters do some real good for the Python
- 2:42community yourselves. I feel like I'm talking to a rock star here, too.
- 2:45Well, thank you so much.
- 2:47It's just a great way to access the culture of the elite in the Python community, the luminaries.
- 2:54I know a lot of people listen to this show and really get a sense of what the culture of the
- 2:59community is like from it. So we all appreciate what you do for the community.
- 3:03Thank you so much. I definitely see that as like one of the major services that we provide,
- 3:10you know, just to get the backstory. Like everybody knows about requests. They know about
- 3:15Twisted. They know about all these things, but you know, they just know the API. They don't know
- 3:19the story and the people. So as much as we can share that, that's awesome. Speaking of stories,
- 3:23how do you get into programming?
- 3:25Well, that's a very long one. A lot of people, you know, there's a sort of stereotypical story
- 3:30of like, well, I had an Altair when I was a kid and I learned basic. And so I had a kind of
- 3:36oddball version of that, which is that my father, who's a fairly prominent software developer himself,
- 3:42he was an APL programmer when I was a kid.
- 3:45APL blows me away, by the way.
- 3:47Yeah. Have you ever actually seen like a full APL program?
- 3:50I've seen little snippets and it's incredible. Could you just describe what the syntax looks like
- 3:54to everyone? Cause it's really not standard.
- 3:56Imagine that you were an astronaut on the moon at an archeological dig and you found a tablet
- 4:02that was a programming language from an alien civilization. That's what APL looks like. It's
- 4:08a combination of geometric symbols and Greek letters. And I think there might be some Hebrew letters in
- 4:14there. It is a very odd sort of programming language in that it comes off this
- 4:20evolutionary branch that did not have a lot of other languages on it. And it's definitely not
- 4:26the main one, you know, the sort of algal derived C, C++ type programming languages that we're all
- 4:33used to these days.
- 4:34Yeah. It's really a great description, like an alien one. When people ask me to describe it,
- 4:39I think of it's like, if Egyptians used hero graphics to like program, like this would be APL basically.
- 4:47Yeah, very much so. so, and of course, when I started learning to program at eight years old,
- 4:52that was not what I was looking for.
- 4:53Did you try to learn APL at that age?
- 4:55Dad tried to teach me. That's might not be the same thing. So I sort of learned a little bit of APL
- 5:01just enough to, start trying to write a text adventure, Zork style video game.
- 5:07So, I learned how to do the very first thing, which was variable assignment. So that when you would type
- 5:13West, it would print out the description of the room to the West. And that's kind of where I stayed
- 5:20in terms of programming sophistication for the next decade or so. Oh, well, maybe not decade,
- 5:24maybe around eight years. But I, so I started off trying, I didn't want to learn a program. I just
- 5:29wanted to be able to do just enough to make these Zork style video games. And I could not, without
- 5:37learning to code, obviously I couldn't actually get anywhere. So I went from there, which was APL 68K
- 5:42on the Amiga to HyperCard on the Mac. And, HyperCard was, I don't know, probably some of your
- 5:51listeners are familiar, but maybe not all of them. HyperCard was a English like scripting environment
- 5:57where you weren't writing a program, like a textual thing. You would launch HyperCard and you'd start
- 6:04editing these documents, which were a combination of like buttons and text fields, as well as little
- 6:09scripts that were attached to each of them. And so I spent a long time very, very tediously kind
- 6:15of teaching myself to code by accident because I had chosen this environment because it was the one
- 6:20where you didn't have to know how to code. And finally, after years of resisting this, I discovered
- 6:26what a variable was. I discovered that you could like have a value that didn't have to be like put
- 6:33into a text field or stored as a buttons label. Like you could just actually have a abstract notion
- 6:38of a value. And that sort of blew my mind. But, and one of the reasons I'm telling the story is like,
- 6:44I feel like that archetype that we have of the kid who learned basic and was programming since they were
- 6:51like five years old, kind of discourages other people from getting into coding. They feel like,
- 6:56Oh, I couldn't do this. It takes forever.
- 6:58I'm too old to get started.
- 6:59Yeah. Like you have to do this from it's, it's like a language learning. You can only do it when
- 7:05you're really young. And I, despite having a story where I did learn to code pretty young, I feel like
- 7:11it's important to emphasize. I screwed it up as hard as I could. And I really like squandered every
- 7:16opportunity to learn anything useful until I was at least 16. At which point I actually started to
- 7:24learn to code. I learned some C++, and then I learned some Java and started actually making games
- 7:30because it was pretty hard to do it without actually knowing how to do any of the coding part of coding.
- 7:36So I went from there where I was doing a bunch of kind of hobby projects and game development. I got a
- 7:42job at a small software company in New Jersey and had a terrible, terrible experience writing their
- 7:50flagship application in Java. We were reporting it from an old legacy, a database system to Java.
- 7:57And I went wrong with that experience. What didn't go wrong. It was a interesting lesson in depending on
- 8:06proprietary software you don't pay for. The major thing that went wrong was the Java runtime environment
- 8:13on the Mac at the time would leak about three quarters of a megabyte of memory every time you opened a
- 8:19window. And since this was a closed source runtime and our entire application was based around these
- 8:25windows that would open and close, you would lose just megabytes of memory at a time. And, it was
- 8:31many like as a cocky 19 year old, I didn't know anything about doing metrics or setting performance targets or
- 8:39anything like that. So we got several months into the project and I of course had been reassuring
- 8:43everyone the whole time, like, this is going to go great. This is going to be fantastic. It's going to
- 8:47be so much better. We got close to what should have been the end date of the project and it turned into
- 8:52frantic bug hunt, trying to figure out where these problems were coming from in our code. And it turned
- 8:58out they were coming from the Java runtime.
- 9:00Oh yeah. And so you're, you're thinking, what are we doing wrong? Let's, let's double check it one
- 9:05more time and there's nothing you can do, right?
- 9:06Right. It's never the compiler until one day it actually is the compiler. And then you're in a
- 9:11really bad situation. So I spent a while trying to debug that. I really, I did like Java as a
- 9:17programming language, but I left that job shortly thereafter, just because I felt like dying of shame
- 9:23after convincing everyone this is going to be great. And then, you know, that was a huge disaster.
- 9:28So as a formative experience that taught me that maybe I should be looking for systems that have an
- 9:34open source component, that if there's a horrible, horrible bug, I can kind of get down into the
- 9:38runtime and fix it myself. And that's one of the things that led me to discover Python.
- 9:42At the time between jobs, I was kind of working on this text adventure. Once again, this is a
- 9:48recurring theme in my program. I bet you're a fan of muds and these types of things.
- 9:53Oh yeah. No, I was definitely played one or two in my time.
- 9:57Nice. Me too.
- 9:58And so, yeah, so I was developing this thing and I had written it all in Java and it was a giant,
- 10:03massive multi-threading, like four or five threads per connection. This was, many of your listeners,
- 10:12I hope will be too young to remember this or will have blanked it out as a traumatic memory.
- 10:17But this was a time when there were, there was actually a marketing term, massively multi-threaded.
- 10:22This was like a good thing that you would be proud of that your code would do.
- 10:25And so this Java thing definitely qualified and it was full of just unfixable race conditions and bugs.
- 10:34So one of the things that the Python language had, which I didn't have exposure to in Java or any of
- 10:41my previous C++ work was the select module. And the select module, I discovered it first because we,
- 10:48one of the people who was helping me out with this was developing a kind of client server protocol.
- 10:54This was a mud with like a rich text front end so that it wasn't just a console.
- 11:00Graphics and background patterns and things like that.
- 11:03And so he was rewriting this communication layer with the client and he was tired of coordinating the five or six threads that got involved in the networking layer.
- 11:14And so he just wrote it to use the select module to detect which of the operations that we might need to do to the socket were available, read or write or error.
- 11:26And I had never seen such a thing before. And I thought to myself, that's interesting.
- 11:30So you could do like two or three things at a time, but without threads.
- 11:33And that's more or less where Twisted came from was I had started investigating that.
- 11:37And it ended up being a much simpler, less error prone way to develop apps.
- 11:42And so I fell in love with Python on many levels simultaneously.
- 11:47One of them was that it made that whole style of programming possible.
- 11:51Another was that it sort of was this thin foam padding around C that made it easier to distribute applications.
- 11:58And this thing's not sharp. It doesn't cut me anymore. Does it hurt?
- 12:01Exactly. Yes, it was. Physically, it didn't hurt. Actually, I was typing so many fewer lines of code in Python that I wasn't developing serious wrist pain or anything at the time.
- 12:13But like after a day of coding, I would feel it if I were writing in C++ or Java.
- 12:17And in Python, like it literally did not hurt me to code. So that was a pretty big upgrade.
- 12:22That's really good. That's cool. Yeah, that's an unexpected benefit.
- 12:27So I think this using things like IO ports and completion ports, this type of programming that's sort of asynchronous but not threaded.
- 12:35That's something that takes a while to run into maybe a little bit less these days.
- 12:41But certainly, it's really easy to jump into threading straight away and just think I need parallelism. Let's go create threads.
- 12:47It's kind of interesting how it depends where you come from, like different programming cultures, I think give different exposures to this.
- 12:54I actually did a PyCon talk a couple years ago called So Simple You Could Even Do It in JavaScript about event-driven programming.
- 13:01Because if you come from a background, not just of JavaScript, but of any kind of graphical user interface, event-driven programming is very natural.
- 13:10It just seems like something you do.
- 13:12Even like VB6 or something like that. Yeah.
- 13:14Right. Just because it's really clear when you're saying like on click, do X, on mouse down, do Y, right?
- 13:20Like those types of things make intuitive sense.
- 13:22The problem is when you're kind of in a back-end environment.
- 13:26You're talking to a database or you're doing some kind of transaction processing.
- 13:30And then you have to say on transaction complete.
- 13:33And you think to yourself, but wait a second, why can't I just block?
- 13:36Like this is kind of like a function call.
- 13:38And that's when thread seems really appealing.
- 13:40And if you've been developing things that way, then it just seems natural to keep developing them that way once you have concurrency.
- 13:48I do think that it's definitely kind of becoming more popular in that domain.
- 13:53But there are lots and lots of programmers that you might consider sort of novice or like not really or like non-programmers who can code, who actually take to it very easily.
- 14:04And so it's kind of an interesting piece of expertise that people pick up in odd ways.
- 14:08Yeah, I'm sure.
- 14:09And also the rise of JavaScript, the rise of Node.js, they really put that front and center like it's unavoidable.
- 14:16Exactly.
- 14:17And it's that same thing where you just say, you know, on click equals and then some code.
- 14:20And it intuitively makes sense.
- 14:22You don't have to explain that that's an event handler and, you know, the cascading model in JavaScript.
- 14:27You can learn a whole lot about handling events before you hear the word event.
- 14:30Yeah, for sure.
- 14:32So what do you do day to day for like professional work?
- 14:36I work at a startup that is started by one of your previous guests, I believe.
- 14:41Jessica McKellar.
- 14:42Okay.
- 14:43Is one of the founders.
- 14:44And we do bookkeeping.
- 14:47Actually, we're a bookkeeping service.
- 14:49Primarily, I think right now for startups.
- 14:52But the idea behind the company is there's lots of apps for doing your own bookkeeping like QuickBooks.
- 14:59We do the work of bookkeeping with software, though.
- 15:03So we can automatically classify transactions.
- 15:06And so our product is not software.
- 15:09It's your books.
- 15:10So awesome.
- 15:12Yeah.
- 15:12Yeah.
- 15:12That sounds really awesome.
- 15:13But of course, you know, we have some software behind the scenes.
- 15:15So since podcasts are a durable cultural artifact and our name is temporary, I will avoid saying our name.
- 15:22Hopefully we'll have a permanent one soon.
- 15:24Well, it sounds like a really noble goal.
- 15:27There are pretty decent bookkeeping bits of software like QuickBooks.
- 15:32I'm not sure I'm willing to judge it.
- 15:34FreshBooks, Invoiced, those types of things.
- 15:37But that doesn't solve the problem of like, hey, I would rather like do something technical and not force myself to become an accountant.
- 15:44Right?
- 15:44Yeah.
- 15:44We are bookkeeping for companies that don't want to worry about bookkeeping.
- 15:47Right.
- 15:48And we have a real focus on automation and trying to make things kind of seamlessly just work.
- 15:53Nice.
- 15:53That sounds really fun.
- 15:54Do you guys have like machine learning and stuff going on there?
- 15:56We have, I guess I could say we have proprietary machine intelligence, which might mean machine learning or might mean a pile of regexes.
- 16:04Who could say?
- 16:05Yeah, sure.
- 16:05Yeah, who could say?
- 16:06All right.
- 16:06Awesome.
- 16:06Well, it sounds like a really fun project.
- 16:08So we're going to talk about some, spend a little time on your PyCon talk.
- 16:14Now, this is the PyCon 2016 talk, but were you at the 2017 PyCon?
- 16:18I was.
- 16:19In fact, I spoke at the 2017 PyCon.
- 16:21That's right.
- 16:22That's right.
- 16:22I do.
- 16:22I also have, we're going to also talk about your talk there.
- 16:24How was that experience?
- 16:26What do you think?
- 16:26I mean, PyCon is always a highlight of the year.
- 16:28There's just so much stuff that goes on.
- 16:30I can't possibly consume all of it.
- 16:33One of the really interesting things about PyCon is for a technical conference that has like a really large number of tracks.
- 16:38And in fact, not only does it have a large number of tracks, but there's kind of an intentional scheduling thing they do where they will put high profile talks up against each other.
- 16:47So Corey Benfield, for example, gave a really good talk right at the same time as I did.
- 16:53So I didn't get to see his.
- 16:54Yeah.
- 16:54And that was inside requests or something like that, right?
- 16:57I believe that was, I always get mixed up which year it is, but yes, I think that was it this year.
- 17:02Okay.
- 17:03But there's so much stuff going on beyond just the talks.
- 17:07I mean, there's the summits.
- 17:09There's just an incredible hallway track where there's people doing open spaces and informal conversations.
- 17:16And it's a real opportunity for open source projects to get together and be strategic, which is not something that we get to do a lot in open source.
- 17:24But we get to sit down and see people from Twisted and Requests and AsyncIO and Flask and Jinja and Django, all in the same room, all kind of talking about the future of Python and how we're all going to add features to our various projects and things that we can work together on, standards we can collaborate on.
- 17:47And so there's so much stuff going on at PyCon, no matter what your level of skill is.
- 17:52There's a lot of new folks.
- 17:54Every year at PyCon, I learn something really interesting about some of the software that I work on from someone who's either never used it or who's just started using it for something really unusual.
- 18:03So I love hearing from those types of people as well.
- 18:06Yeah.
- 18:07So PyCon, always amazing.
- 18:09Yeah.
- 18:09I definitely look forward to it.
- 18:10I'm already looking forward to the next one.
- 18:12And it's like 49 weeks away or something, right?
- 18:16Just to start get a calendar, start checking them off or something.
- 18:19I really like what they do with the program committee where there are also a lot of new speakers every year.
- 18:24Like there are people sharing new and different perspectives.
- 18:27It's not, you know, obviously I give great talks.
- 18:30You should go see all of my talks.
- 18:32They're all archived.
- 18:34But it's not just me and Corey and Hinnick and Guido standing up every year and giving the same talk over and over again.
- 18:41It's like if we want to be, if the old timers want to get up on stage and say something, it's a very competitive environment because there are people talking about monitoring black holes with Python or...
- 18:55...innovating robots in factories or all sorts of stuff, right?
- 18:59Yeah.
- 19:00There's just so much, especially with the uptick in data science, there's so much science going on that has Python involved in it in some way.
- 19:07Yeah.
- 19:07That's interesting.
- 19:08It's probably going to only get more competitive in that there are more people and more disciplines it's pulling from.
- 19:14Exactly.
- 19:15And it's great to see that reflected.
- 19:16I like to say that Python is always the second best language for everything.
- 19:21So it's never quite the best thing you can reach for, but as soon as you need to do two things, suddenly it's the best language because you can't do machine learning and be a web server at the same time in any other language nearly as well.
- 19:35Unless you want to try to write it in R, which I hear is theoretically possible, but I'm not sure it's a good idea.
- 19:40Yeah.
- 19:41Well, it comes down to that same thing.
- 19:43I can guarantee you R is not the second best language for writing a web server.
- 19:47That's right.
- 19:49That's right.
- 19:50This portion of Talk Python To Me has been brought to you by Rollbar.
- 19:54One of the frustrating things about being a developer is dealing with errors.
- 19:58Relying on users to report errors, digging through log files, trying to debug issues, or getting millions of alerts just flooding your inbox and ruining your day.
- 20:07With Rollbar's full stack error monitoring, you get the context, insight, and control you need to find and fix bugs faster.
- 20:13Adding Rollbar to your Python app is as easy as pip install Rollbar.
- 20:18You can start tracking production errors and deployments in eight minutes or less.
- 20:22Are you considering self-hosting tools for security or compliance reasons?
- 20:26Then you should really check out Rollbar's compliant SaaS option.
- 20:29Get advanced security features and meet compliance without the hassle of self-hosting, including HIPAA, ISO 27001, Privacy Shield, and more.
- 20:39They'd love to give you a demo.
- 20:40Give Rollbar a try today.
- 20:42Go to talkpython.fm/Rollbar and check them out.
- 20:45I definitely want to touch on a few of your projects before we get into shipping software because you've got some popular projects and you've got to package them up and ship them.
- 20:56So maybe we could touch them.
- 20:58Like probably the best known one is Twisted and the stuff that's spun out from Twisted, right?
- 21:03I think that that will probably hound me to my grave is the most popular thing I've ever done.
- 21:08Yes.
- 21:10Yeah.
- 21:10You don't get a pick, right?
- 21:11Indeed, we do not.
- 21:12So maybe tell people what Twisted is for those people who don't know.
- 21:17Twisted is an event-driven programming system networking engine for Python.
- 21:22It's a thing that basically if things happen on the network or over the passage of time and you want to get a method called on your objects, as a result of that, Twisted can help you out.
- 21:33It's got web client and server.
- 21:35It's got an IMAP client and server.
- 21:37It's got a DNS client and server.
- 21:39It's got a whole bunch of protocols implemented.
- 21:41And it's also got a lot of stuff that lets you kind of combine asynchronous control flows in various interesting ways.
- 21:50It's kind of almost the original framework for this.
- 21:53I hesitate to say that because there are a lot of precursors that Twisted drew from.
- 21:58But a lot of those precursors were much more special-cased and kind of purpose-specific.
- 22:03Whereas Twisted, like the concept of a deferred originally came from Twisted and deferreds eventually moved kind of front-end into JavaScript and eventually deferreds became promises.
- 22:13And promises are obviously a very popular thing for JavaScript developers to use these days.
- 22:18So Twisted is both new and dynamic.
- 22:21There's lots of interesting stuff going on in that community.
- 22:23Lots of modern practices being adopted.
- 22:26But it's also very kind of venerable and pretty old as a non-legacy technology goes.
- 22:33Yeah.
- 22:34It was definitely one of the original ways to write this style program that you talked about in the beginning,
- 22:40where it's kind of IO completion port, not just 100 threads running next to each other, right?
- 22:45Right. And one of the things we did, we actually presented a paper at Usenix at the very beginning of the Twisted project,
- 22:50talking about the need for kind of a high-level interface to things like IO completion ports.
- 22:55Because at the time, FreeBSD was adding KQ, and Linux was starting to add ePoll,
- 23:00and Solaris had its own high-performance multiplexing mechanism.
- 23:05But of course...
- 23:06You guys are like, stop the madness. We can't have all of these.
- 23:08Well, actually, we were kind of almost saying the opposite.
- 23:11We were like, this is great, all these hyper-optimized, low-level kernel things.
- 23:15And I guarantee you, no one will ever write an application to talk to one of these.
- 23:18You're going to get the three biggest servers out there to do it,
- 23:21and then no other app will ever be able to take advantage of your custom kernel special thing.
- 23:27We need a way for apps to write against a common API so that when the kernel goes off and does some crazy new thing,
- 23:33we can actually use it without having to rewrite all of our code from scratch.
- 23:37So there was definitely an element of stop the madness from the perspective of stop putting all of these new .h files that I have to include.
- 23:45Like, they're not helping me.
- 23:48Yeah, yeah.
- 23:48It sounds really interesting.
- 23:49So Twisted's still going strong, huh?
- 23:53People are still doing interesting new things with it?
- 23:55Oh, yeah, absolutely.
- 23:56One of the interesting things about it, which I did predict when AsyncIO came out,
- 24:00there were a lot of people who don't like Twisted for one reason or another
- 24:04and who were sort of sharpening their knives when AsyncIO came out.
- 24:08And they were like, oh, great.
- 24:09Now, you know, we don't have to use Twisted anymore.
- 24:11It's like, it's true.
- 24:12If you don't like Twisted, there's like more options now.
- 24:14But there was a sense among many people that it was going to kind of be the doom of Twisted.
- 24:19Oh, now there's this event loop in the standard library.
- 24:22But one of the interesting things that came out of that was that event loop is just one small piece of what Twisted did.
- 24:30And we did not want to have to be the kind of standard bearers for all event-driven programming in Python.
- 24:36We wanted to provide like a nice little suite of protocols that all work together nicely and like tools to help you with testing and like generally be like a framework.
- 24:46But it would sort of be like if Django, let's say, were the only way to speak HTTP from Python.
- 24:53And one day somebody came out with a second web server or there was like a web server in the standard library.
- 24:58Yeah, watch out.
- 24:59There's a bottle now.
- 25:00Everyone's going to just stop using Django.
- 25:02Exactly.
- 25:03It's like, no, Django does like one or two other things that you might want to do.
- 25:06And Twisted's the same way.
- 25:07We've actually seen a big uptick in activity and interest.
- 25:10A lot of other people starting to pick up Twisted.
- 25:12Because for a long time there was a vacuum in the standard library.
- 25:16It really wasn't clear how Python was going to do concurrency.
- 25:20And now that the answer is like async await, event-driven I.O., that's what's coming.
- 25:25That's the future.
- 25:26It's like, oh, okay.
- 25:27Well, Twisted's been in the future for the last 15 years.
- 25:30That's cool.
- 25:31Are you thinking of, or can you already like access it in Python 3 with like async and await type programming models?
- 25:38Oh, yeah.
- 25:38No, we support.
- 25:39So I believe we've been adding new features every release for the last couple of years.
- 25:44I'm not sure exactly where everything landed.
- 25:46But in 17.5, which is a release that just came out, I believe, yesterday, we have full support for converting deferreds into futures and creating futures from deferreds.
- 25:59So not only can you use async await, which you've been able to do for a while with Twisted, you can even use Twisted in the middle of an async I.O. app.
- 26:06You can switch to use some Twisted library code and then switch back anytime you want.
- 26:11So it fully integrates at every layer.
- 26:13Oh, that's awesome.
- 26:15It's got coroutine support for interacting with futures.
- 26:17It's got event loop support.
- 26:19It's got an async I.O. reactor that you can use.
- 26:21So you can map Twisted's event loop on top of async I.O.
- 26:24There's TXTULIP, which is a third-party thing that's been able to do this for a really long time, even before Tulip became async I.O.
- 26:33and got it at the standard library.
- 26:34So we've been really – I mean, Twisted has always been a very integration-focused project.
- 26:39I mean, we speak gross, difficult protocols like IMAP, so you don't have to.
- 26:45And, you know, we do the low-level plumbing so you don't have to, too.
- 26:49Yeah, that sounds really, really nice.
- 26:51So two quick comparison questions.
- 26:54First of all, what do you think of some of the new frameworks coming out, like UVLoop and things like Sanic and Jopronto and those efforts there?
- 27:03I mean, I think it's great that everybody's learning this new paradigm and doing cool little experiments with it.
- 27:08I do think that there is maybe a slightly odd perspective where people are looking at something like Sanic, which is brand new and kind of named after a weird meme,
- 27:22to be equally kind of feature-complete and robust as something like Twisted.
- 27:27And I think that in many cases, like, the comparison is almost unfair because, like, it's not like Sanic comes with its own DNS server, right?
- 27:37Like, there's a lot more stuff in the Twisted ecosystem and in the Twisted core.
- 27:41I think both those projects, personally, I think they're pretty interesting and they look very promising.
- 27:46But I don't feel like they're close to ready yet.
- 27:50Yeah, I think that, I mean, they're certainly ready for some things.
- 27:52And I wouldn't want to discourage people from trying them out.
- 27:55But I also think that it's important to kind of calibrate your expectations.
- 27:58I mean, there are many things that Twisted still doesn't do right after 15 years of trying to do this.
- 28:05And so I think that there's also, like, Curio and Trio, like, weird new event loop models that people are experimenting with.
- 28:12Yeah, that was my second question.
- 28:13Like, Curio also sounds a little bit similar to Twisted in that it's trying to really be the loop and, you know, talk different protocols in the network and stuff like that.
- 28:23I mean, I think that the idea behind Curio and Trio was kind of to invent a new style of programming.
- 28:29And Twisted has this kind of unofficial policy of no new ideas.
- 28:33We don't implement anything, like, novel or original.
- 28:36Everything that Twisted does at a kind of fundamental level is something that my dad was doing on Stratus mainframes with, in C, in, like, the 80s and 90s.
- 28:49So, you know, we are not as focused on kind of being a research platform, which means that, you know, there's kind of less interesting new agey stuff in Twisted that might spark an interesting research direction.
- 29:02But it also means that you can kind of let Twisted be boring and make your application be the interesting part.
- 29:07Yeah, well, sometimes boring is good if you're building on top of it.
- 29:10That is our hope.
- 29:11Nice.
- 29:12All right.
- 29:12So you want to just maybe touch a little bit on some of your other projects that you want to mention?
- 29:16And then we can talk about shipping software.
- 29:18Sure.
- 29:19I mean, a couple that I think are always need to be mentioned in the same breath as Twisted are Klein and Trek.
- 29:24Klein is like Flask, but for Twisted.
- 29:26Trek is like Requests, but for Twisted.
- 29:28They're a little bit different than Flask and Requests in certain ways.
- 29:33But if you want to build like a kind of standard service-oriented app or like a little web app with Twisted in an event-driven way, those are pretty much almost required.
- 29:43Right.
- 29:43Because you're going to need to not just listen on HTTP, like Twisted, the web server that comes with Twisted, you should think of like as a competitor to Apache or Nginx, not Django or Flask.
- 29:54It's a web server and it's designed to be, the API that it offers is designed to be kind of like a configuration language for composing resources together.
- 30:02Whereas like Klein is an app platform.
- 30:04You can write a little server with it.
- 30:07And then there's also TX Acme, which is based.
- 30:12So I made a project called TX S&I, which was just sort of designed to make it easy to dump your SSL certificates into files without caring what order the private key and the chain certificate and the nine other things you seem to need to dump into a SSL configuration.
- 30:27You could just kind of put them all in a file in any order and call it like your domain.pem and it would automatically get loaded.
- 30:33And then Tristan Seligman built on top of that with TX Acme, which is a Let's Encrypt implementation for Twisted.
- 30:38So you can just like combine those three things and get a service that automatically listens on an SSL port, automatically provisions the certificate and gives you nice async server and client web APIs.
- 30:49Oh, that sounds like a fun set of building blocks.
- 30:52So yeah, so those are the ones you should definitely check out.
- 30:54We've also been trying to make an effort to move some of the data structures that Twisted uses that have nothing to do with event-driven programming, that are just kind of useful Python library functionality, out.
- 31:03So Mahmoud Hashemi recently extracted our URL object into a project called Hyperlink.
- 31:10And Hyperlink got adopted partially as part of that inter-project communication and collaboration that I mentioned at PyCon into the Python HyperOrg.
- 31:20The name and the fact that the org is called Hyper are just kind of a coincidence, but people I'm sure are going to assume that it's called Hyperlink because it was made by Hyper.
- 31:28But that's a really handy object if you need to parse URLs like a web browser does, like dealing with Unicode and all the different places that Unicode can show up and parsing percent escaped stuff into human readable text.
- 31:43That's a handy library to have.
- 31:45That sounds nice.
- 31:46And that's the kind of stuff you don't want to mess with, with weird escapes people can do to get around security and all sorts of stuff, right?
- 31:53Oh, yeah, you can find slashes in all kinds of strange places.
- 31:56And yeah, Hyperlink, it's because it kind of parses like a browser does.
- 32:00It lets you do all kinds of interesting stuff, like interesting transformations where you can say there's like a click method that'll take a URL and give you a new URL.
- 32:08It's like a link to the URL, which is the kind of thing where if you like doing web crawling or, you know, indexing web documents, it's the sort of thing you have to be able to do a lot.
- 32:21So, but there's a couple others.
- 32:23There's also incremental, which is we have a version object in Twisted because we were very concerned with backward compatibility and long term support for various things that you need to be able to track versions.
- 32:35So we spun that out to a different library.
- 32:38It's also eventually, which is because we're concerned about compatibility.
- 32:41Compatibility means you need to have deprecations.
- 32:45And so eventually is a library for deprecating stuff and eventually removing it, which is where it comes from.
- 32:52Yeah, I really like that project.
- 32:54Yeah, we're hoping it becomes a little more popular because like in such a high level dynamic language as Python, you need to be kind of disciplined about making sure that you communicate to your users like, hey, this is going away.
- 33:05It's going to stop working in so many versions.
- 33:07And like this is perhaps segwaying into our main topic here.
- 33:10It's important to be able to do that because you want people to be if they're packaging applications, including your stuff, if it's part of their requirements that text, you want them to be able to upgrade regularly.
- 33:21But you also want them to know how much technical debt they've got pending and like how much work they have to do before they can upgrade again.
- 33:27Yeah.
- 33:28And you don't have the compiler with a, you know, a deprecated flag right there.
- 33:33Right.
- 33:33And so you basically have this runtime thing that does something similar, which is cool.
- 33:37Exactly.
- 33:37Yeah.
- 33:38Nice.
- 33:38Hey, everyone.
- 33:40This is Michael.
- 33:40Let me tell you about Datadog.
- 33:41They're sponsoring this episode.
- 33:43Performance and bottlenecks don't exist just in your application code.
- 33:47Modern applications are systems built upon systems.
- 33:49And Datadog lets you view the system as a whole.
- 33:53Let's say you have a Python web app running Flask.
- 33:55It's built upon MongoDB and hosted and scaled out on a set of Ubuntu servers running Nginx and MicroWSGI.
- 34:00Add Datadog and you can view and monitor and even get alerts across all of these systems.
- 34:05Datadog has a great getting started tutorial that takes just a few moments.
- 34:09And if you complete it, they'll send you a sweet Datadog t-shirt for free.
- 34:13Don't hesitate.
- 34:14Visit talkpython.fm/Datadog and see what you've been missing.
- 34:18That's talkpython.fm/Datadog.
- 34:22You gave a really nice talk and you structured it in the form of a play, more or less, at PyCon 2016 called Shipping Software to Users with Python.
- 34:32And this is something I'm also super passionate about.
- 34:35And I feel like we've seen the growth curves of Python really, really taking off and, surprisingly, even in the last few years, becoming much more popular than it was.
- 34:45But I think if we had a better deployment story, it would even be steeper, that curve.
- 34:52I totally agree.
- 34:53And this is one of the reasons that I wanted to write that talk in the first place was that I was and am really passionate about Python being available to people kind of where they are.
- 35:04One of the things that drove me to talk about deployment is it's cool that Python's usable as a web service thing.
- 35:12It's certainly been a huge driver of economic activity and scientific discovery in that kind of role.
- 35:18But there's also something just tremendously empowering about being able to program your own computer and make it do useful stuff for you.
- 35:27Yeah.
- 35:27And the problem with having a kind of broken deployment story is it seems like a kind of arcane technical solution, system deployment or application packaging.
- 35:37But when you think about it, it's really just like some fifth grader makes a hilarious guess the number game.
- 35:44And then they want to share it with their friend.
- 35:46Like what do they do at that point?
- 35:49They go to their friend's house and they set up their machine to run it.
- 35:51Right.
- 35:52Exactly.
- 35:52They take their laptop over there because that's all you can do these days.
- 35:56And so that often drives educators away from Python because if they do it in Java or they do it in – so in Java, it's a little bit weird.
- 36:05You often have like a strange runtime environment that all the students have to set up.
- 36:10But if it's in JavaScript, they just load the web page and there it is, right?
- 36:13Yep.
- 36:13And Swift is making inroads there as well with their playgrounds and all that kind of stuff as well.
- 36:18Exactly.
- 36:18And Swift is as amazing as playgrounds are and there's a lot to like about them.
- 36:24It's almost the thing that I was – it's sort of the nightmare scenario that I'm afraid of, which is why I really think we should get our deployment story together in the Python community, which is that it kind of draws this line between technical people and non-technical people.
- 36:38And if you're like a real programmer, you ship to the app store.
- 36:41And if you're just playing around, you use playgrounds.
- 36:45And that dichotomy creates this sense that people are not empowered to do like real programming or make real apps.
- 36:52And I think there's two sides to that.
- 36:55Apple's also done quite a bit to reduce the barrier to entry on shipping software into the app store.
- 37:02It's a lot less expensive than it used to be.
- 37:03It's a lot less effort than it used to be.
- 37:05But it is still this hurdle that, for example, kids are just never going to get over.
- 37:10Whereas when I was learning to program as a kid, the sense that grown-up professional, serious software company like Broderbund could make something and put it on floppy disks and then you could do the same thing was very powerful.
- 37:23It was really – it gave you a sense that you could do something real in a way that kids don't get to experience in a lot of different levels.
- 37:29Like if a kid wants to be a doctor when they grow up, they can't like kind of do some surgery just to try it out, right?
- 37:36But as programmers –
- 37:38That's right. We hope not.
- 37:38Exactly.
- 37:40But as programmers, you know, we have this luxury of the safety of being able to potentially make something that's like real and useful and shareable.
- 37:48But if deployment doesn't work, you don't get any of that.
- 37:51Yeah. Yeah, absolutely.
- 37:52And on the other end of the spectrum, if you go to the pro places and you say, let's write some – especially like the one that really strikes me is, let's write a GUI app in Python that we're going to ship around, right?
- 38:06Like it certainly is possible and we'll talk about some of the tools that you can do it with.
- 38:12But it's not as easy as some of the other here's the thing I compiled and you just take it and it just runs stories.
- 38:19Right. It's really not very streamlined.
- 38:22And it is getting better, but again, I guess we can talk about how.
- 38:25Yeah, yeah, absolutely.
- 38:26So you said that you had your talk sort of focused in different areas.
- 38:31Like you were focused on maybe the people that create libraries, the people who run stuff in the cloud, like web developer types.
- 38:40And then this third one where we talk about either from a kid perspective, like learning or from a pro perspective, shipping stuff to end users, right?
- 38:50Was that basically the three areas you were focusing on?
- 38:53More or less, yeah.
- 38:54I mean I also talked a little bit about the people maintaining the infrastructure in Python, but that's kind of more of a like telling them to consider those other three perspectives.
- 39:04Right. Okay. So you went through some of the stuff that you can do for the server side and that's pretty straightforward.
- 39:10Like we can make packages.
- 39:12We can use things like Twine and ship those up to PyPI.
- 39:16We can package them as wheels.
- 39:18We have requirements.txts.
- 39:20Like that kind of stuff.
- 39:21I don't know. It's super clean, but it certainly works well once you get used to it.
- 39:27Like I've had a few people who are learning Python web development come to me and say, this is all really hard.
- 39:31How do I make this stuff work?
- 39:32Like I don't know what to do.
- 39:33So maybe it's not hard, but it, and you kind of touched on that.
- 39:38It's like, it's confusing or not clear what the steps are.
- 39:41Yeah. One of the problems is, you know, we actually have a fair amount of documentation at this point, except there's so much of it now.
- 39:49We trip over our own feet trying to explain to users how to do this kind of stuff.
- 39:53And so you end up with something where it's like, it's actually pretty straightforward to assemble a Docker container, let's say.
- 40:00But you'll find so many half written tutorials and there's so many concepts and so many separate tools that you have to chain together that most people do not end up on the fast path.
- 40:10They do not end up just doing the one thing that's going to be easy for them.
- 40:14And I think that that's getting a little bit better in terms of like what things people are linking to and what you happen to find just thanks to PageRank kind of finding the better articles over time.
- 40:24But yeah, it's starting to stabilize a little bit as well.
- 40:27Yeah, it's definitely been a long slog to get here, though.
- 40:30And where we are is definitely not ideal.
- 40:32One of the points I think that I didn't make in the talk that's probably worth talking about is that Python is not a deployment platform.
- 40:41And so everything that we do, the things that I talked about in the talk, the things that we're talking about now, distutils, setup.py, virtualenv, right?
- 40:50These are mostly developer tools.
- 40:53They're for assembling the software into some shape, but they're not really for shipping it.
- 40:58And one of the reasons that Cloud Python has gotten a lot better is that most of the assumption about where you're deploying your stuff is shifting towards containers.
- 41:07And Docker is a deployment platform.
- 41:11That is a system with like a pretty clear contract of what goes into a software artifact.
- 41:17Like it's a Docker image.
- 41:18That's it.
- 41:19There are really no other options.
- 41:21How do you run it?
- 41:22Well, it's got an entry point.
- 41:23And that's it.
- 41:24Like there's a couple of things you might need to document.
- 41:27I have a whole separate series of blog posts and stuff about type system for Docker and how it needs to be more expressive.
- 41:35But basically, if you hand an ops person a Docker image, they more or less know what to do with it.
- 41:40It's a clear integration point between Python people and systems people.
- 41:45And the tools that we have at our disposal, like pip, like distutils, like virtualenv, make sense in that context.
- 41:52And we can pretty easily script them to do the right thing to build a Docker image.
- 41:57But Docker is just one deployment platform.
- 42:01And the problem is we need tools that deploy Python to multiple different deployment targets and not try to come up with a quote unquote Python deployment target that is universal and works.
- 42:15Right. Like, for example, in the GUI space, just because you get a Docker container and you can ship that to end users and go, now run the Docker container.
- 42:24Right. There's no Docker run on my iPhone.
- 42:26Right.
- 42:27Yeah, exactly.
- 42:28That shows up in a couple of different places.
- 42:30I mean, there's any kind of GUI front end thing suffers from this.
- 42:35Like the GUI front end stuff just can't be shipped in that style.
- 42:40But also it can't be as easily shipped with shell scripts.
- 42:43Right.
- 42:44The reason Docker works so nicely with the Python tool chain is that most of the things that we've sort of been building up from are a combination of dependency on some Linuxy,
- 42:54type tools that are the low level stuff and then a script to assemble them into a coherent, like runnable shape.
- 43:00And that's pretty easy to do in Docker, but that's a lot harder to do on, let's say, Windows.
- 43:06Right.
- 43:06Where ultimately you're just trying to get a P executable or zip file together.
- 43:11But the process you need to go through to do that in order to, like, integrate with the Windows compiler and all of that stuff,
- 43:19you actually kind of have to know about those tools and you can't just, like, write a little script and copy some binaries around.
- 43:25Right, right.
- 43:26The system's got to be, like, in a place to receive it in the first place.
- 43:29Exactly.
- 43:29Yeah.
- 43:30So you kind of taunted the audience a little bit with this thing you called pip.app.
- 43:34And you're like, okay, here's how we're going to deploy it.
- 43:36We're going to run this thing called pip.app.
- 43:38We're going to select our program.
- 43:41We're going to select our dependencies.
- 43:42We'll, you know, choose the operating system and we'll just package this puppy up, right?
- 43:46Yeah.
- 43:47And why can't we have it, right?
- 43:48Like, this seems like a kind of almost obvious tool.
- 43:52But it's, I think that one of the reasons that nobody's made such a thing is that it's, you have to care a lot about the general case.
- 44:02And you have to care a lot about the end user experience.
- 44:05And in the kind of open source world to scratch your own itch, you're never that end user, right?
- 44:10You've already gotten to some point that's further down the line than just, like, I don't know what Python is.
- 44:15But if we were thinking about making this in, like, a 1990s style desktop app where, like, a user finds your floppy disks in the store and can't talk to you after that, like, you'd better make it work just from the beginning.
- 44:29And if we thought about it more like that, I think that people would end up having to Google for those confusing virtual end articles a lot less often.
- 44:36And, you know, part of the problem is just that we don't have that many volunteers who are working on this stuff.
- 44:41I think you're touching on a super important point.
- 44:44And I've spoken to several people about this.
- 44:48Like, you know, I sort of opened this section by saying if we could get the deployment, especially the client side UI style deployment better, it would just open up an entire new avenue of growth for Python and where we could really leverage apps.
- 45:01And I was talking to somebody and said, look, this is a problem that is super important we need to solve.
- 45:05And I said, well, it's just not a thing that I find people who do Python do very often.
- 45:09We don't run into this problem.
- 45:10And we don't run into this problem because it's so hard that we don't even consider doing this most of the time, right?
- 45:16Exactly.
- 45:17And it's really kind of sad because, in fact, it's not that hard.
- 45:20And, like, 80% solutions exist for so many of these problems.
- 45:24Yeah.
- 45:24I mean, Dropbox is on, like, they always have that huge number.
- 45:29I'm not sure what it is, like 10 billion computers or something.
- 45:32They're running everywhere.
- 45:35And that's a Python desktop app.
- 45:36So clearly it's not going to, you know, wreck your company if you decide to use Python.
- 45:41You know, they had to do some work to make that work.
- 45:44And they made it work for them.
- 45:46And I absolutely don't want to criticize Dropbox for not doing enough to help the open source community because they've definitely done tons of stuff.
- 45:53Lots of really interesting work has come out of there.
- 45:55But at the same time, like, if somebody else wanted to follow in their footsteps and make another Python app that would deploy to, like, a zillion machines, they'd kind of have to solve a lot of the same problems again in a different way because the Python ecosystem has moved quickly and has got a lot more and better tools than when Dropbox was first started.
- 46:16So there's just problems.
- 46:18The problem is everybody who's, like, really, really concerned about this problem is already too busy already.
- 46:23Like, I gave this talk to try to help newer people to the community try to understand the problem because as we spent quite a while talking at the beginning of this show, I've already got a lot going on.
- 46:35Like, I've got to, you know, keep the books for our customers and write software to automate financial stuff at work.
- 46:41And then I come home and then I maintain Twisted and I maintain Climb and I maintain Track and I do all of this stuff.
- 46:47And I, you know, try to keep the peace in the community and make sure the mailing list doesn't go down and keep our servers running.
- 46:55And at the end of all that, I just don't have any time to start the fairly ambitious project to fix all of these problems.
- 47:03Yeah. Well, and it doesn't sound to me, from what you described just now, that you individually have this problem, right?
- 47:11And I feel like there needs to be, you know, a couple of major companies or a couple of major projects that are like, we need to build this app and ship it this way.
- 47:20And we need to just fix the tooling to make it work for us and take the community along with us.
- 47:25Yeah, I feel like it's the person who's going to have this exact problem is kind of hard to imagine.
- 47:30Because if you want to ship a desktop app and you have interesting enough logic and enough investment in Python, there's lots of ways you can just do that today.
- 47:40You can grab Pi to app and you can grab Pi to exe and you can work around the same seven bugs that everybody who uses them has to work around.
- 47:49And eventually, after you've had a couple of professional programmers hammer on it for a few weeks, you'll have a deploy pipeline that works for you.
- 47:56You put it into your continuous integration system and then you're good.
- 48:00Right. Once you get around that, you make it work, then you forget how you even made it work, right?
- 48:04Exactly. And then it's in your, you know, when you do something in your code that makes it stop working, then you notice and you back it out.
- 48:12And this is actually one of the problems I didn't talk about in the Python talk was that one of the reasons this is so pernicious is that we don't tell users to start by deploying.
- 48:23Because Python is so flexible and it's so empowering to just get in there and, you know, make a module and then make another module next to it and edit the first one to import the second one and then just change it and maybe even reload it on the fly.
- 48:35There's all this cool stuff you can do with that and with Jupyter Notebook, just typing code into cells and never even put it into a module that by the time you have something you want to deploy,
- 48:47you might have made a dozen mistakes about how you're loading resources or about how you're getting your code installed or the layout of your repository, right?
- 48:59It's pretty easy to end up in a place where you can't even write a setup.py because all your modules are expecting to import stuff from like three different paths at the same time.
- 49:07And at that point, you have to like back out of whatever weird structure you've got yourself into and then recreate something sensible.
- 49:15And that's the point where you throw up your hands and go, I'm never going to ship this thing.
- 49:19Like, I'm not going to rewrite my app or it's just not going to work for real apps or whatever, right?
- 49:23So that's super interesting.
- 49:25You're basically proposing that like if you know that you want to use Py2 app or Py2.exe or the cross-platform Py2 installer or Shakespeare's or some probably combination thereof,
- 49:36like write your hello world and then create your hello.app and start building them up together.
- 49:43Is that what you're proposing?
- 49:44Yeah, I mean, I think for anybody who's out there who's thinking, I want to make a desktop app.
- 49:49I want to make a mobile app.
- 49:50I want to make a low-level system utility.
- 49:53One of the categories we haven't talked about too much yet is just like if you're making a program that needs to like be a system control thing for Unix systems at a level lower than like Docker, right?
- 50:05Like you want to write your own SSH server or something like that that like controls a system.
- 50:10You also can't ship it as a Docker container because you need it to like live on the Debian or the Red Hat system.
- 50:16So you need to ship it as a package.
- 50:18So if you're in one of those categories and you're like, I want to ship this command line thing or GUI app and you're thinking, I'm definitely going to want this to have a GUI.
- 50:25I'm definitely going to want this to ship as part of Homebrew.
- 50:28I'm definitely going to want to ship this as a Debian package.
- 50:31Whatever it is that your deployment target is, deploy your hello world to that target and get like Travis or some kind of continuous integration system to start running it for you and doing that build and making sure that it at least basically works.
- 50:46Because it's really, really easy.
- 50:48Once you've got that set up, once you've got that pipeline working, it'll pretty much keep working.
- 50:53You might have the occasional problem where like some third party library has a weird like shared object that you need to install in some funny way.
- 51:00But if you know that at that moment when you're adding that dependency or you're installing that tool, if it breaks right then, you could say, aha, I'm not going to use that.
- 51:11Or I'm going to get in touch with their maintainers and say like, why is this broken?
- 51:14As opposed to writing a big complicated app, getting everything all done, and then ramming headfirst into this brick wall of like, now how do I put this on somebody else's machine?
- 51:27Because one of the things that you don't realize is you're making all kinds of decisions about how to get it to run on your machine.
- 51:33And they seem like totally sensible, right?
- 51:36You have icon.png and it's in the current directory.
- 51:40So you just open up icon.png and you read it.
- 51:42Except what's the current directory?
- 51:44How do you know that it's in your git checkout?
- 51:47Because your git checkout is not going to be there on your target machine.
- 51:50So unless you're going to ship dev tools to everybody, you have to think about, well, where does that resource come from?
- 51:55And that's exactly the kind of stuff that trips people up with packaging.
- 51:58Yeah, that makes a lot of sense, actually.
- 52:00I hadn't really thought about it that way, but it certainly makes a lot of sense.
- 52:03I mean, it feels a little bit like, let's write 100,000 lines of code and then run flake 8 on it to find the problems.
- 52:11Right.
- 52:12Just the first time.
- 52:13Exactly.
- 52:14And a day before you ship, right?
- 52:17Yeah.
- 52:18Or another way to think about it is like, let's write 10,000 lines of code and we'll make sure that all unit tests pass, but we'll never run it.
- 52:28Because we'll just assume that it'll work if we run it.
- 52:30But of course, you run it that first time and it's like, oh, you forgot a couple of unit tests.
- 52:36And your build pipeline is the same way.
- 52:39So this is when I talk about pip.app, what I'm really talking about is not just like, let's make it easy, but let's make it the first thing you do.
- 52:48So if there are bugs in it and there are problems with it, you're just doing it constantly.
- 52:52So you notice when there's an issue.
- 52:54Yeah.
- 52:54I think that's really great advice.
- 52:56So, you know, there might be a lot of people listening who don't, are not familiar with pip.app or pip.exe and how these things work.
- 53:03Basically, you can take this pip.app utility.
- 53:07So let's stick on the macOS for a moment.
- 53:09And it will create, like kind of embed a Python runtime that you need, all the dependency packages that you need, your code and package it up in a way that looks just like Safari or something.
- 53:21And users double click it and it can run.
- 53:23Right?
- 53:25Exactly.
- 53:25Yeah.
- 53:25And so they don't even necessarily, it doesn't even matter what version of Python they have, whether they have Python.
- 53:31It's just, they get the app, it runs because it's a self-contained unit, like other runtimes like Go or certain Windows EXEs.
- 53:40Yeah.
- 53:40And this is exactly what I meant when I said that Python is not a deployment target.
- 53:44Like macOS is the deployment target.
- 53:46And the Mac says what you have to do to be an app.
- 53:49And PyToApp just makes Python be that thing.
- 53:52Right.
- 53:52Here's your P list.
- 53:53Here's your resources.
- 53:54All that kind of stuff.
- 53:55Exactly.
- 53:56And it just bundles it up into the shape that macOS expects without any regard for like what else is on the system.
- 54:02And really like Go is sort of famous for producing these static executables where they include all of your Go dependencies.
- 54:09But oddly enough, Python is sort of in a better place for many operating systems than Go would be.
- 54:16Because what Go lets you do is it lets you put all of your binary resources into one file.
- 54:21But that's kind of a red herring.
- 54:23The thing you actually need is to put it into the shape the operating system expects, which is almost never one file.
- 54:29Windows is the one place that that's true.
- 54:31But on Windows, there's a whole system for like tacking on resources into a .exe.
- 54:37You can, I believe, Windows loads from the end of the binary.
- 54:41So you can actually tack like you can, your binary can just be a zip file.
- 54:45And then you stick the executable on the end.
- 54:48And suddenly it works and it launches.
- 54:49And I might be mixing that up.
- 54:51I know that Unix is one way and Windows is the other.
- 54:54And one's the beginning and one's the end.
- 54:55But that kind of thing is like once you know how you want your app to run, it turns out that actually on Windows and on the Mac, you often need like shared libraries or DLLs or resources or things that can't be put into a single binary.
- 55:13Like an app on the Mac cannot be a single binary.
- 55:16It has to be at least an info.plist and an executable.
- 55:19And practically speaking, you need a dozen other resources like icon files and other things.
- 55:24And similarly, like even if you're just talking about command lines, right?
- 55:27You think single file binary, you think, oh, that's really good for the command line.
- 55:30That's really how I want to run my stuff is I just want to have this one binary.
- 55:33And that can make the deployment process easier.
- 55:36But how do people actually deploy stuff onto the command line on the Mac?
- 55:40Do they like curl a binary in chamod plus exit?
- 55:44No, they brew install it, right?
- 55:46And homebrew has a whole complicated multi-file setup where the deployment target is homebrew.
- 55:51That's a really interesting point.
- 55:53In your little PIDA app graphic, you had the various targets.
- 55:57And one was Ubuntu, one was Windows, one was macOS.
- 56:00But another was a chocolatey install.
- 56:02And one was a brew install.
- 56:04And one was an aptitude package and things like that, right?
- 56:07Yeah.
- 56:07And each of these kind of defines its own deployment surface.
- 56:11And the reason that you don't want to just be randomly curling some Go binary onto your system
- 56:16is because that initial install is just one thing.
- 56:20You've also got to have an update process.
- 56:23And that update process probably has to be cryptographically signed or something.
- 56:26Like somebody needs to be in charge of making sure there's a secure pipeline to
- 56:30deliver it to all your users.
- 56:31And then that has to run on a CDN to make sure you don't have too much load.
- 56:35And by the time you're done with that, you've got JSON files that are describing your metadata
- 56:39and hashes and all kinds of other stuff which don't fit into that one binary anymore.
- 56:43So Go can kind of get you started.
- 56:46And it can make a lot of parts of this pipeline easier.
- 56:48But one of my favorite examples of this, which I don't think I mentioned in the talk
- 56:52because I think I found out about it somewhat later, is Askinima, which is a website.
- 56:58It's a really cool website for sharing like screencasts of terminals.
- 57:02Have you ever used it?
- 57:02No, no, I haven't.
- 57:03But you have to put a link in the show notes for us so we can check it out.
- 57:06Definitely.
- 57:06But the idea is it's just this little thing.
- 57:09It's like a social place where you can share your various like Emacs and VI sessions.
- 57:14Nice.
- 57:14That's awesome.
- 57:14And when you do this, they have a local TTY recording tool, which they originally wrote
- 57:19in Python.
- 57:20And then, of course, because Python makes deployment hard, they rewrote it in Go from scratch.
- 57:26And then they rewrote it again in Python because they just went to Python 3 and they shipped
- 57:33it as a thing that you brew install because it turns out going to the single file Go binary
- 57:37didn't really help solve their problems that much.
- 57:40Right.
- 57:41And, you know, Go is a lot lower level language.
- 57:43So it didn't like there were a lot of things that they lost as well.
- 57:46So by just kind of going straight to the never mind the single file thing, we just want to
- 57:52make sure that this is brew installable.
- 57:53It got to what their users really wanted, which is way to get it installed.
- 57:57That's like easy to explain.
- 57:59It doesn't require a lot of sysadmin knowledge to keep updated.
- 58:02It doesn't require a studio.
- 58:03Exactly.
- 58:03Yeah.
- 58:04You just type the brew install command.
- 58:05And the killer thing about the way that the thing that people think they want when they
- 58:11hear a single file is when you've got a Python install and you're doing like pip install
- 58:17to get your tools installed.
- 58:19The problem with that isn't that it's multiple files.
- 58:21It's that it's sharing all kinds of files.
- 58:23So you do a pip install A and then you do a pip install B.
- 58:26And if you just need tools from A and B, they can conflict with each other.
- 58:31So pip install B breaks A because they're all reading from the same location.
- 58:37All their libraries are piled on top of each other.
- 58:39And there's no dependency checker in pip, which makes sure that A isn't going to break.
- 58:43The versioning metadata isn't fine grained enough for A to even know that it's going to
- 58:48break when B gets pip installed.
- 58:49So it's just too fragile to try to share all of this stuff between Python libraries.
- 58:55It's not like a .so where you can have like a very, very strict binary interface.
- 59:00That never, ever changes.
- 59:02Like anything can change in any Python file anywhere and potentially break every user of
- 59:07that library.
- 59:07You pretty much need to do a full on test run of your application to make sure that it's
- 59:12not going to break with a new version of a dependency.
- 59:14So it's that sharing that becomes a really big problem.
- 59:18Yeah.
- 59:18And sometimes you can't even avoid that because you're using two packages.
- 59:21They might both use a dependency, but they were built against different versions of that
- 59:25dependency or something, right?
- 59:26Exactly.
- 59:27And there's nothing really wrong with that even.
- 59:29That's the, when you describe the problem, it sounds like, oh, that one library really
- 59:33should have ran its tests.
- 59:35Shame on them.
- 59:36But it's not really, it's, it's not their responsibility to make sure that whatever random
- 59:41versions of libraries on your system happen to work, they have a continuous integration system
- 59:46that says what they work with.
- 59:47And so, you know, we've gotten a lot of improvements in the Python ecosystem for library developers
- 59:53to put out more and more robust artifacts.
- 59:55But that last mile of like, put the application together, packaging everything together.
- 1:00:00One tool that I really like that I use a lot is Pipsy, pip S-I, which I don't think is actually
- 1:00:08an acronym for anything, but I pretend that it stands for pip script installer.
- 1:00:12What it does is you do Pipsy install HTTPIE, let's say, or Pipsy install Boto3 or AWS CLI
- 1:00:20or something.
- 1:00:21And it will install a new virtual env that contains just the scripts that come from that top level
- 1:00:31package.
- 1:00:31And it'll like symlink those scripts into a shared directory, but kind of hide the virtual
- 1:00:37end from you.
- 1:00:38So it's every single tool that you need is installed into a separate virtual end for
- 1:00:42its own requirements installed into it.
- 1:00:44It's still kind of a developer installation tool because you already need to have Python,
- 1:00:49you already need to have virtual end.
- 1:00:51There's like a little bit of setup that goes into installing Pipsy in the first place and
- 1:00:54bootstrapping it.
- 1:00:55But then once you've got it, at least your stuff doesn't break all the time.
- 1:00:58Like, yeah, it lets you play with stuff more aggressively or without care, right?
- 1:01:04Right.
- 1:01:04It's isolated and it's kind of installed the way that it should be, which is that each
- 1:01:07app has its own dependencies.
- 1:01:09Because again, Python is not a platform.
- 1:01:11The compatibility guarantees that a library can make in Python are not strict enough that
- 1:01:17you can have users upgrading their own stuff and then thinking it's going to work afterwards.
- 1:01:22Like you need to ship a user all of the libraries that you tested with.
- 1:01:26Yeah.
- 1:01:26Yeah.
- 1:01:26That makes a lot of sense.
- 1:01:27So one thing that you held up as a good example is Briefcase.
- 1:01:31I think that Briefcase is headed in a really good direction.
- 1:01:34I think that they, that project has set up some really good infrastructure in terms of
- 1:01:40like how they think about the long-term solution to the problem in that they have great onboarding
- 1:01:48for new contributors.
- 1:01:49They show up at lots of events.
- 1:01:50They had a great presence at PyCon.
- 1:01:53And they also, so they're, they're playing the long game here.
- 1:01:55They recognize that this is a very big complex problem.
- 1:01:59That's going to require a lot of people to solve.
- 1:02:00And that it's also multi-layered.
- 1:02:01Like one of the parts of the Beware project is not just Briefcase, but Batavia.
- 1:02:07And Batavia is this transpiler from Python byte or not transpiler.
- 1:02:14It's a Python virtual machine written in JavaScript.
- 1:02:17So that you can ship your PYCs into a web browser.
- 1:02:20And that doesn't seem like it's really related to Briefcase at first, until you realize that
- 1:02:26the vision that they're pursuing is ship Python anywhere, write all of your code in Python all
- 1:02:32the time, which is really the vision that I'm also sympathetic to.
- 1:02:36And, but unfortunately what that means is because they are taking this very long view of the problem,
- 1:02:41it's probably not the thing that you would use like right now for everything.
- 1:02:45It does have some really great iOS build templates.
- 1:02:48If you were going to do a mobile app in Python, it's probably the best place to start.
- 1:02:52Yeah, I agree with that.
- 1:02:52They, Russell Keith-Magee did a, a bunch of the build work on Pythonista.
- 1:02:58So I don't think that Pythonista, that the iOS app that runs Python is itself like straight up
- 1:03:05deployed with Briefcase, but it shares a lot of that same technology.
- 1:03:07And so there's kind of a, at least a proof concept that it can work really nicely.
- 1:03:11I don't know if you've played.
- 1:03:12Yeah, I've played with Pythonista.
- 1:03:13It's a cool app for sure.
- 1:03:14It's basically, it's a Python editor and runtime for iOS.
- 1:03:20Maybe also an Android.
- 1:03:21I don't know about Android.
- 1:03:22I'm pretty sure it's just iOS.
- 1:03:23Yeah.
- 1:03:23Yeah.
- 1:03:24Which it's impressive to me that that's even possible given all the restrictions that Apple
- 1:03:29puts on executables.
- 1:03:30Yeah.
- 1:03:30I mean, they probably wouldn't like it if you started shipping apps to people in the form of
- 1:03:35like that really, really long base 64 encoded.py files.
- 1:03:41There is some tooling to actually help you write an iOS app inside Pythonista on iOS.
- 1:03:47You do need to like have a Mac to kind of bounce your project off of because you need to do the
- 1:03:53build of an iOS app on a Mac.
- 1:03:55Yeah.
- 1:03:56But I've done that.
- 1:03:56I've downloaded the templates and like made a little hello world out of the scripts that come
- 1:04:01on Pythonista, which is actually kind of another interesting reflection of the same problem from
- 1:04:06a different direction, which is that Pythonista does not have any equivalent to pip.
- 1:04:11So it's actually very hard to write full apps that take advantage of the Python ecosystem because
- 1:04:18you can't, your build pipeline can't include that kind of like, and install this requirements.txt file
- 1:04:24first.
- 1:04:25Python's less fun when you, you have no import.
- 1:04:28Yeah.
- 1:04:29I mean, Pythonista kind of cheats a little bit because it just gives you a thing that like
- 1:04:33already includes like requests and like NumPy and some pretty big chunks of SciPy, I think
- 1:04:39are also in there.
- 1:04:40So it's, it's just kind of like, ah, here's about a third of the interesting stuff in the
- 1:04:44Python ecosystem.
- 1:04:45Just in a big box.
- 1:04:46But yeah, the idea that like you can grab this, you know, from the staggering ecosystem
- 1:04:54that Python has to provide for you.
- 1:04:56That's really what makes this interesting because if you're just going to write an app, you know,
- 1:05:01do it in a Swift playground and then, you know, copy the Swift code to a Mac and write all of
- 1:05:07that yourself.
- 1:05:07It's not that much different than Python.
- 1:05:10Like Python might be a little nicer, but once you can pull in stuff, like you can pull in
- 1:05:15Jupyter or something like that and you can have like live introspection of your objects
- 1:05:19in your app or you can pull in something like NumPy and have that tremendously powerful numerical
- 1:05:24library at your disposal, it starts to make the investment in Python kind of make sense.
- 1:05:29Yeah.
- 1:05:30Yeah, it definitely does.
- 1:05:31I think Swift is a fine language.
- 1:05:32I just think their equivalent of the standard library is really, really not, not a great story.
- 1:05:38It's pretty bare bones.
- 1:05:40Yeah.
- 1:05:40But, but, you know, Python, the way Python can compete with that is by
- 1:05:44being yet more robust in the library ecosystem and not by kind of cutting itself off at the
- 1:05:50knees and saying like, here's a really streamlined deployment experience that only works if you
- 1:05:55write all of your code yourself.
- 1:05:56All right.
- 1:05:57Yeah, absolutely.
- 1:05:58We definitely don't want, I want to see that.
- 1:06:00So, Cliff, this is a bunch of great advice and hopefully a lot of inspiration for, for people
- 1:06:07that, like you said, go that last mile to kind of close the gap and make this really sweet
- 1:06:11deployment story.
- 1:06:12Well, I certainly hope that, folks get inspired to go do that.
- 1:06:15I think that, if you are kind of, if you feel like you're just a regular developer and
- 1:06:20you don't feel like you could take on something this ambitious, going and helping out the Beware
- 1:06:24folks, get briefcase into the kind of shape that it can just do a lot of this work
- 1:06:29itself is probably the best way to help out the community at this point.
- 1:06:34Yeah, I agree.
- 1:06:34And they are, they have like basically a mentorship program for first time open source contributors
- 1:06:40and they're very welcoming there.
- 1:06:41So it's, it's a nice environment.
- 1:06:43Definitely.
- 1:06:43I think that that's one of the things that they, they might do better than almost any other
- 1:06:46project I've seen is that they are really focusing on the people problems and making it
- 1:06:50easy to get involved with the project and make a real impact quickly.
- 1:06:54Yeah.
- 1:06:54It's good to see they're working on this problem as well, cause they're doing cool stuff.
- 1:06:57All right.
- 1:06:58So I think we probably should leave it there for, for that, but let me ask you the two questions.
- 1:07:02So we talked a lot about shipping Python code, but if you're going to write some Python code,
- 1:07:06what editor do you use?
- 1:07:07So we began with a story about my childhood and I feel it's only fitting to, to end on one
- 1:07:13because I've heard you ask this question of a lot of people and they all give you an answer
- 1:07:18and I have an answer, but I think it's important to reflect on where that comes from.
- 1:07:23When I was 10 years old, my father sat me down and he said, you're going to grow up and
- 1:07:30people are going to tell you that you should be a VI user or you should be an Emacs user.
- 1:07:36And what I have to tell you is they're both wrong.
- 1:07:40You need to do both editors because sometimes you're going to be SSH'd into some machine
- 1:07:44that you have.
- 1:07:46He probably said telneted, but you know, sign of the times.
- 1:07:49Same basic thing.
- 1:07:50You're going to be in on some console where you can't install anything and Emacs isn't there
- 1:07:55and the environment's set up wrong.
- 1:07:56And you're really going to want to know how to be able to exit VI.
- 1:07:58And at the same time, like Emacs is this tremendously powerful library ecosystem of all kinds of
- 1:08:04sophisticated stuff that you probably want to be able to leverage to be able to use like
- 1:08:12an IDE.
- 1:08:13So I actually learned pretty young, both Emacs and VI.
- 1:08:17And I have tried to take that philosophy to heart in that I have a working Sublime Text
- 1:08:22configuration.
- 1:08:23I've been working on upgrading that to Sublime Text 3.
- 1:08:26I haven't messed around with Adam too much yet, but I definitely intend to.
- 1:08:29And my wife is a big proponent of Visual Studio Code.
- 1:08:33So I feel like we should all learn to use editors in harmony.
- 1:08:38Yes.
- 1:08:39That said, Emacs is the best one.
- 1:08:41And that's what I use.
- 1:08:43That's a great story.
- 1:08:45Thanks.
- 1:08:45And a good answer.
- 1:08:46All right.
- 1:08:47And notable PyPI packages?
- 1:08:49I'll throw a twisted out there for you straight away.
- 1:08:51Yeah.
- 1:08:52Actually, I wanted to talk about, I wanted to bring up one that we haven't already mentioned
- 1:08:56in the course of this discussion.
- 1:08:57And so I think Hypothesis is a package that I would really recommend people check out.
- 1:09:02I haven't used it very much yet, but what Hypothesis is, is it's a generative testing framework.
- 1:09:09So you kind of give it a piece of code that you want it to test, and then you give it some
- 1:09:15variables, some ways that it can generate data or state for that code to be tested in.
- 1:09:22And then you kind of fire it off, and it will figure out what's interesting to test about
- 1:09:28your code in some ways.
- 1:09:30I'm making it sound a little bit more magical than it is, but it lets you, like if you have
- 1:09:35just a function that takes two numbers, and there are range limits on how those numbers
- 1:09:41are supposed to relate to each other, like there's one case where they're equal to each
- 1:09:44other, and there's one case where the first one's greater, and one case where the second
- 1:09:46one's greater.
- 1:09:47Hypothesis can, if properly set up, discover that those are the three things that you can't
- 1:09:52three unit tests you need to write.
- 1:09:53And there's like a whole bunch of values where it behaves one way, and a whole bunch of values
- 1:09:56where it behaves a different way, but it'll kind of like minimize and do like a binary
- 1:10:00search to find the interesting test cases for you.
- 1:10:04And so I haven't, like I said, I haven't really used it myself yet, but I have been investigating
- 1:10:09it, and it's kind of changed the way that I've thought about how tests can interact with
- 1:10:14each other.
- 1:10:14And I would, I know a couple of my friends have given it a spin on various kind of complex
- 1:10:19testing projects, and it's really helped improve the reliability of their software a lot.
- 1:10:24It's, it's found bugs in a way that like straight up unit testing generally doesn't.
- 1:10:28Yeah, it's awesome.
- 1:10:29I've definitely heard that as well.
- 1:10:30And there's some amazing stuff hypothesis can do.
- 1:10:33I actually had the David McIver on there on episode 67.
- 1:10:38So quite a while ago, but talking about that there, and it's, I'm impressed with it as well.
- 1:10:41And it pairs up with the other unit testing things.
- 1:10:44Like you can use it with pytest or with Tox or whatever.
- 1:10:48Yeah, it's really, it's a, it's kind of a power up for your tests.
- 1:10:51It's not like a whole new testing system.
- 1:10:53People have used it with Twisted's built-in TestRunner and as well as pytest and a whole bunch
- 1:10:59of other ones.
- 1:11:00Yeah.
- 1:11:00So you touched on this just a little bit, but one more chance, final call to action.
- 1:11:05You've got people caring about this deployment story.
- 1:11:08What can they do?
- 1:11:08Well, so aside from just like go help beware, the thing to do when you go help beware is
- 1:11:14if you're the sort of person who has like a virtual machine or like the ability to spin
- 1:11:20up new VMs, run a VM for some GUI operating system, whether it's macOS or Windows and pretend
- 1:11:27you don't know anything about Python and you want to just write a little GUI application,
- 1:11:33try to find a tutorial.
- 1:11:35And in your fresh new VM with no developer tools installed, try to make an app that you
- 1:11:42can run on a different VM also with no developer tools installed.
- 1:11:47And the interesting thing about this is, well, the reason this is my final call to action
- 1:11:53is if you do this, you will see all of the places that even if you yourself are only do
- 1:12:00like web-based Python and don't do a lot of stuff with GUIs or desktop apps or mobile apps,
- 1:12:05you will see all kinds of places where you know where the sharp edges are and you know exactly
- 1:12:12what to do and it's not really written down anywhere and try to figure out how to take
- 1:12:16that process to like the parts of the process that you understand that you know how to get
- 1:12:20done the same way, the right way every time.
- 1:12:23Blog about it, write about it, contribute to packaging.python.org that where there's documentation
- 1:12:29for how to set up packaging and try to think of whatever you're trying to help with these issues,
- 1:12:34whether it's Beware or just on your own blog. Remember where the actual beginning is and don't
- 1:12:43just write tutorials for people who already have pip installed and already have Python installed and
- 1:12:48already know the difference between Python 2 and Python 3. Just go back to the beginning and think
- 1:12:53hard about what it would take for a total beginner to get started because there are a lot of total
- 1:12:58beginners out there that do not have a friend to kind of shepherd them through that wilderness and I feel
- 1:13:04like we're losing a lot of new Python programmers who if only that part were easy, they would be
- 1:13:09coming to PyCon with us every year.
- 1:13:11Yeah, absolutely. Well, that's a great thing for people to try. I totally think it would be helpful
- 1:13:16to go through that whole exercise. All right, Cliff, thank you so much for being on the show. I really
- 1:13:21enjoyed chatting with you.
- 1:13:22It was a total honor to be here and see my name up in lights next to all those other luminaries that
- 1:13:27you've interviewed.
- 1:13:28I'm thrilled to put it up there. Thanks again.
- 1:13:32This has been another episode of Talk Python To Me. Rollbar takes the pain out of errors. They give you the context
- 1:13:39and insight you need to quickly locate and fix errors that might have gone unnoticed until your users complain,
- 1:13:45of course. As Talk Python To Me listeners, track a ridiculous number of errors for free at
- 1:13:50rollbar.com slash Talk Python To Me. Datadog gives you visibility into the whole system running your code. Visit
- 1:13:57Talk Python.fm slash Datadog and see what you've been missing. Don't even throw in a free t-shirt for doing the
- 1:14:02tutorial. Are you or a
- 1:14:04or a colleague trying to learn Python? Have you tried books and videos that just left you bored by
- 1:14:09covering topics point by point? Well, check out my online course,
- 1:14:12Python Jumpstart by Building 10 Apps at talkpython.fm/course to experience a more engaging way to
- 1:14:18learn Python. And if you're looking for something a little more advanced, try my WritePythonic code
- 1:14:23course at talkpython.fm/Pythonic. Be sure to subscribe to the show. Open your favorite podcatcher
- 1:14:30and search for Python. We should be right at the top. You can also find the iTunes feed at /itunes,
- 1:14:36Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
- 1:14:42This is your host, Michael Kennedy. Thanks so much for listening. I really appreciate it.
- 1:14:46Now get out there and write some Python code.
- 1:14:48Thank you.
- 1:15:08Thank you.