## ![Fedora Loves Python](flp.svg) --- ```pycon $ sudo dnf install python3.13 $ python3.13 -m venv venv $ . venv/bin/activate (venv) $ python Python 3.13.0a4 (main, Feb 16 2024, 00:00:00) [GCC 13.2.1 20231205 (Red Hat 13.2.1-6)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> ``` --- # pizza.py ```python [] """ This is a 🍕 module. """ ``` --- # pyproject.toml ```toml [1-8|1-3|5-8] [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [project] name = "pizza" version = "2024" description = "🍕" ``` --- ```pycon [1-4|5-6] >>> import tomllib >>> with open('pyproject.toml', 'rb') as f: ... pyproject = tomllib.load(f) ... >>> pyproject['build-system']['requires'] ['hatchling'] >>> pyproject['build-system']['build-backend'] 'hatchling.build' ``` --- ```bash (venv) $ pip install hatchling ``` --- ```pycon [7-8] >>> import tomllib >>> with open('pyproject.toml', 'rb') as f: ... pyproject = tomllib.load(f) ... >>> pyproject['build-system']['requires'] ['hatchling'] >>> pyproject['build-system']['build-backend'] 'hatchling.build' ``` --- ```pycon [] >>> requires = ['setuptools >= 40.8'] >>> backend_name = 'setuptools.build_meta:__legacy__' ``` --- ```pycon [2-3] >>> import importlib >>> backend_name = pyproject['build-system']['build-backend'] >>> backend = importlib.import_module(backend_name) >>> backend
``` --- ```pycon [3-6|7-13] >>> import importlib, sys >>> backend_name = pyproject['build-system']['build-backend'] >>> backend_path = pyproject['build-system'].get('backend-path') >>> if backend_path: ... sys.path = backend_path + sys.path ... >>> module_name, _, object_name = backend_name.partition(':') >>> backend_module = importlib.import_module(module_name) >>> if object_name: ... backend = getattr(backend_module, object_name) ... else: ... backend = backend_module ... >>> backend
``` --- ```pycon [1-4|5-6] >>> hasattr(backend, 'get_requires_for_build_wheel') True >>> backend.get_requires_for_build_wheel() [] >>> backend.build_wheel('.') 'pizza-2024-py2.py3-none-any.whl' ``` --- ```pycon [1-4|5-6] >>> hasattr(backend, 'get_requires_for_build_sdist') True >>> backend.get_requires_for_build_sdist() [] >>> backend.build_sdist('.') 'pizza-2024.tar.gz' ``` --- ```pycon [1-4|5-6] >>> hasattr(backend, 'get_requires_for_build_editable') True >>> backend.get_requires_for_build_editable() [] >>> backend.build_editable('.') 'pizza-2024-py2.py3-none-any.whl' ``` --- * **PEP 517**: A build-system independent format for source trees * **PEP 518**: Specifying Minimum Build System Requirements for Python Projects * **PEP 660**: Editable installs for pyproject.toml based builds (wheel based) ---
--- # pyproject.toml ```toml [5-8] [build-system] requires = ["hatchling"] build-backend = "hatchling.build" [project] name = "pizza" version = "2024" description = "🍕" ``` --- # pizza-2024.dist-info/METADATA ```email [] Metadata-Version: 2.1 Name: pizza Version: 2024 Summary: 🍕 ``` --- # pizza.py ```python [] """ This is a 🍕 module. """ ``` --- ![distutils](distutils-meme.png) --- * **PEP 566**+: Metadata for Python Software Packages * **PEP 621**: Storing project metadata in pyproject.toml * github.com/**ofek/extensionlib** ---
floss.social/
@hroncok