Packaging Your Python Code With pyproject.toml | Complete Code Conversation

Real Python · 66K views · 2022 · 51:39

Open on YouTube

Python, Ruby & scripting languagesTesting, debugging & developer toolstutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering questions about relative imports, __main__.py and packaging layout problems that are solved by installing the project with a pyproject.toml.

Recommended by 1 people across 1 different months, 2024 to 2024.

What it is

A 52-minute Real Python 'Code Conversation' in which Ian and Geir Arne walk through packaging a Python project with a pyproject.toml file and installing it with pip. It covers project layout, how the import system works, ways to run a script, and configuring the package for build systems.

What people said

Strong rec Michael Gardner · 2024-01 · Stack Overflow · on “What form of imports should I use in __main__.py and then how should I run the project?”

This video does an excellent job of describing the issue and how to resolve it using current best practices. [this video]

Cites mkp · 2024-05 · Stack Overflow · on “Problem with relative imports on locally installed package via pip: "ModuleNotFoundError" vs "ImportError"”

\_\_main__ .py is a main script and is named so and kept in project;s "root" directory because, as far as I understand, it must be so for pip installation using .toml file and to serve as an entry point. DIR_MODULES will contain various functions. There will be also DIR_GUI for gui related parts of program etc I followed this video from Real Python: [this video]

Cites avalon20 · 2024-12 · Stack Overflow · on “Wheel File Not Including templates Directory and Root Files in Python Package”

After looking at serveral resourced (and a link included by sinoroc in the comments - thanks) and Youtube videos, I ended up reorganising my layout: ├── LICENSE ├── pyproject.toml ├── README.md └── src ├── controller │ ├── conn_mgr.py │ └── ora_tapi.py ├── __init__.py ├── lib │ ├── config_manager.py │ └── __init__.py ├── model │ ├── api_generator.py │ ├── db_objects.py │ ├── framework_errors.py │ ├── __init__.py │ ├── session_manager.py │ └── user_security.py ├── OraTAPI.csv ├── resources │ ├── config │ │ ├── OraTAPI.ini │ │ └── OraTAPI.ini.sample │ └── templates │ ├── column_expressions │ │ ├── inserts │ │ │ ├── created_by.tpt │ │ │ ├── created_by.tpt.sample │ │ │ ├── updated_on.tpt │ │ │ └