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 the default subtitles language 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 see our video player troubleshooting guide to resolve the issue.

Extra: Understanding What an Egg Is

It’s more than just a high-protein food! Here’s a variation on an age-old question: What came first, the wheel or the egg?

You’ll also learn about importlib.metadata.

00:00 Oh yeah, one more question. I saw this interesting folder come up here, snakesay.egg-info\. What’s an egg? Yeah, so there’s a bit of Python history again.

00:12 I think we briefly mentioned the word wheel a little bit. Right, it was mentioned in one of the PEPs that define the whole build system. Yeah. A wheel is a build Python artifact, which is essentially a ZIP file that contains a package.

00:26 So sometimes, when you install a big package like pandas or NumPy, you’ll see a bunch of wheels being downloaded. Yeah, and by default, almost any package that you install, it’ll be based on wheels. Right. It’s the, it’s kind of the standard way to just zip things together. Yeah, but the wheels, as you say, are more important for packages like pandas and NumPy, where there are things that needs to be compiled, because you can have, then, system-specific wheels.

00:51 You can have things that are ready-made for Windows or Linux, and so on. Right. So it’s easy to install for people. The egg was the predecessor to wheels.

01:02 So the name is still found in this directory, although I don’t think we’re actually creating eggs anymore. This particular directory is then actually containing information, so you can see some of the data that we have been adding here you can recognize from we’ve been doing.

01:19 So there is console_scripts, for instance, that just points to our package. And one thing that we could look at, just to get some information from the this snakesay.egg-info\ … so if you go into the terminal again and start a Python REPL,

01:36 there is a package called importlib metadata. So you can do from importlib import metadata.

01:45 So this metadata thing can pick up information about packages and, for instance, we could do metadata.version()

01:53 and then just give it the name of the package as a parameter. This a function, so just call it with "snakesay" as a string. And there we see this is version 1.0.0, which was what we defined in the project, the toml file. And metadata has a few other things that it can then look up in the same manner. Right, and this grabs this information from that egg-info. Right.

02:19 Okay, so it’s sort of an artifact, but it still contains important information, and even though there’s no real egg, it’s just a name that kind of stuck.

02:27 Exactly. This same format is actually used then for other packages, and the reason that it popped up into this folder was that this is an editable install, so our source code lives here.

02:37 If we hadn’t installed this as an editable install, then this information would live somewhere else.

02:43 Okay, but this is definitely something that you want to add to a .gitignore file. You don’t want to be committing the egg info to your source. Correct.

02:51 But you definitely want to be committing the pyproject. That’s where all the important information lives. Exactly.

Become a Member to join the conversation.