Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

Everyday Project Packaging With pyproject.toml (Summary)

In this Code Conversation, you’ve learned that packaging is about more than just publishing a project on PyPI. In fact, it can be helpful for your own personal projects. You had the world of packaging demystified and got to know the new, officially sanctioned way of setting up your Python projects using a pyproject.toml file and installing your package with pip. With this, you get the following benefits:

  • Being able to call your project from anywhere
  • Playing on the same team as the import system
  • Allowing for consistent imports
  • Having one file that’ll work for many build systems

Along the way, you:

  • Structured files and folders in your project
  • Understood different ways to run your script
  • Explored how the import system works
  • Explored the Python packaging world
  • Wrote a pyproject.toml file to configure your package
  • Installed your pacakge with pip

Here are some further resources that you might find useful:

Which of your projects will you package next? Share your ideas in the comments below!

Download

Sample Code (.zip)

2.2 KB
Download

Course Slides (.pdf)

2.0 MB
Avatar image for Diego de Pablos

Diego de Pablos on Dec. 12, 2022

This was really helpful. It’s good to learn how to do these things once and for all!

Avatar image for paulfwatts

paulfwatts on Dec. 13, 2022

This is my first course as a paid subscriber.

I really enjoyed the conversational format and all the materials provided, plus the transcript, were excellent.

Nice to know there is a standard way to do this now!

Avatar image for paulfwatts

paulfwatts on Dec. 13, 2022

This is my README.md added to my project file for this course, which may help others:

Course

Everyday Project Packaging With pyproject.toml (Overview) – Real Python

Installation

Install the package in editable mode using -e. This will install the package in development mode, so that any changes made to the source code will be reflected in the installed package. This is useful for development purposes. Run the following command in the root directory of the project (after creating and activating a virtual environment): python -m pip install -e .

Resources

1. Building and Distributing Packages with Setuptools

2. Get to Know Python Packaging

3. Configuring setuptools using pyproject.toml files

4. Python and TOML: New Best Friends

5. PEP 621 - Storing project metadata in pyproject.toml

6. Flit - Build System

7. Poetry - Build System

Avatar image for wols

wols on Dec. 24, 2022

The course should always be considered one of the first - a “way to work”.

Avatar image for Glenn Lehman

Glenn Lehman on Dec. 30, 2022

I enjoyed this conversation! It helped to lay a solid foundation to my understanding of installing my own scripts. I did create an entire GitHub Repo to capture the code at the end of most videos.

snakesay

Avatar image for Martin Breuss

Martin Breuss RP Team on Jan. 2, 2023

Nice, glad you enjoyed the conversation @Glenn Lehmann. You can also download the sample code from the Supporting Materials dropdown at the top of the page.

Although that code doesn’t include your detailed Video Time Index :D

Avatar image for sanvorav

sanvorav on April 12, 2023

Love this course!! 💚🐍 This course is ESSENTIAL for all doing any development work.

NOTE:

If you’re using a Poetry environment, you can install using the command:

poetry add --editable ./myproject

This will add the line (below) to the Poetry pyproject.toml file:

myproject = {path = "myproject", develop = true}

A myproject.egg-info folder will also be generated.

Avatar image for Pradeep Kumar

Pradeep Kumar on July 13, 2023

This was excellent. I like this content so much, it is much better than plain videos. Two people discussing new things and it is entertaining as well as enriching. I learned a lot.

Off topic question:

1) How did you made your Powershell prompt that way. Is there any tutorial that can be looked into?

2) I have also seen __init__.py files in many places, what does that do in general?

Avatar image for ole088

ole088 on Dec. 2, 2023

Pradeep - You can use a PowerShell profile to change your prompt. For information on using profiles, see about Profiles. There is also a section that shows how to Add a customized prompt.

I also enjoyed this conversation. I found this format a little easier to “code-follow” than the other courses. Others sometimes go a little too fast, but I still find them all very useful.

Avatar image for MischaelR

MischaelR on Jan. 20, 2024

I really enjoyed this course. A lot of great information that isn’t included in standard learning paths.

Avatar image for makearney

makearney on April 21, 2024

Excellent course/conversation/tutorial. It answers many issues I have wrestled with regarding python project development since I started using python. Those were serious enough that I finally decided to solve the problem myself before embarking on any large scale project. The “best” solution I found was to bury the problem in a container, which was not a solution at all. I also encountered other solutions in various other states of completion.

This feels good.I was surprised to learn that all the bits required and presented were not fully accepted and implemented until python 12.x, just months ago. That’s ok. There is pile of development/implementation/suport that I don’t have to worry about now.

Hats off to everyone to who worked to achieve this! Have been there and didn’t really want to do it again. Phew!

Become a Member to join the conversation.