Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Delving Into a Brief History of Python Packaging

To fully understand packaging, it’s good to know how it started. This can explain why Python has so many ways of packaging.

In this brief history, you’ll learn:

  • How Python started and how packaging became a problem
  • What distutils is and how it’s being deprecated
  • Why setuptools is replacing distutils
  • What PEPs have to say about Python packaging

You can also Get to Know Python Packaging in this Real Python tutorial.

00:00 So, how do we get there? Let’s see. This is also something where you find lots of different ways of doing things. Right, yeah. There is some history here. Yeah.

00:11 Because this is one of the sort of pain points of Python, right? That there’s a lot of people coming into Python who might criticize that there’s not some kind of standard system here.

00:21 Is that justified? Yes and no. So there is a lot of history to Python packaging, and it kind of goes back all the way to when Python was kind of first, I guess, invented and released, which was about the same time as the World Wide Web was invented and made available.

00:38 So there was really no thinking at all about how do we distribute code. So packaging was not really a thing. And then in the beginning of the kind of Python 1 era, people would kind of just share files with each other. Just single files.

00:54 Single files or scripts and like this. Right. And you’d kind of maybe send them by email or maybe had some server where people could. Huh. It’s a lot more of the shell script tradition where you just put a ton of code in one file and then you just pass that around. Yeah. So that, that’s kind of Python’s history back in the day. That was kind of—Right, so you didn’t have any of these problems really with the import, because you just tried to keep it all in one file. Partly. Yeah. And then you could, even if you were importing things, that would typically be something fairly simple. Right.

01:25 So then—I think it was around the year 2000 and when Python 2 came online—the first distutils was the first kind of module for trying to distribute.

01:36 So here’s the page for distutils the module. Yeah. So what does this do? As you can see, this is in the Python docs. It’s in the standard library.

01:44 But you can also see that it’s deprecated, with removal planned for Python 3.12, so it’s definitely going away. It’s going away. It’s on the way out. Yeah.

01:52 And it’s been on its way out for a long, long time. How long? Yeah, I don’t know the years there actually— But a long time. Long time. And yeah, the thing that has kind of taken over from distutils is called setuptools.

02:05 Setuptools. In contrast to distutils, this is not part of the standard library, so it’s kind of been a thing that you need to install, but it’s also more powerful, and it’s something that been changing towards being more and more modern. Originally, setuptools was just a drop-in replacement for distutils.

02:23 Okay, so you could just swap one in for the other, and it would still work. Right. And then they have done a lot of improvements to that setuptools to make it a better system. Cool.

02:33 But still for many years it was the only way to really set up Python packages

02:38 was to run setuptools, and it was kind of its own thing that were then just defining standards by being the tool everyone used. Okay.

02:48 So then we started doing PEPs, which essentially means that we set standards for how things should be, and there is a decent list that we have in one of our articles where we show that history of Python packaging.

03:01 This one, called Publish an Open-Source Python Package to PyPI. And if we just look at the history there, Get to Know Python Packaging … we can scroll down a little bit here and see that there’s a list of some of the most important PEPs that

03:12 over the years have now defined how should packages be set up.

03:17 Right. Wheels, version numbers, dependencies, back ends, build systems, project metadata, editable installs. Lot of technical words and technical documents that you may dive into.

03:29 You probably don’t want to and shouldn’t, at least not just to get your snake running. Right. So we’re not going to dive into the details of this, kind of more just say that things have changed, right, so that’s where we’re coming from. There was Python, as we can see, has a fairly messy history with packaging.

03:47 But the place that we kind of arrived at now is actually very neat and clean. So what we’re going to show here is how can we now create a local package of snakesay that will then just run and work beautifully.

Become a Member to join the conversation.