TATECHATLAS
◎ English
Home / Topics

Programming: Python, Git and code examples

Python and Git guides covering dependencies, environments, change history and code examples with explanations and primary sources.

Choose the problem you need to solve: a Python environment, package imports or Git history. Check commands against your tool version and the conditions of your project.

Materials

10 materials

PurePath versus Path: when path math is not filesystem truth

Use PurePath-family classes for portable, I/O-free path manipulation and Path/PosixPath/WindowsPath for filesystem-backed work. Do not treat lexical normalization as proof that a target exists, resolves through symlinks, or is contained.

pathlib / PurePath / Path / symlinks / resolve / filesystem checks

Combining Static and Dynamic Metadata in pyproject.toml

In pyproject.toml, static metadata keys are declared directly in the file, while dynamic keys are listed in the project.dynamic array so a build backend can supply their values at build time. A backend must honour statically specified keys that are not listed in dynamic, and it must raise an error if name appears in dynamic. When a key is specified both statically and in dynamic (PEP 808), the backend may only append entries and must not modify or remove existing ones.

pyproject.toml / PEP 621 / PEP 808 / build backend / dynamic metadata / versioning / setuptools_scm / reproducible builds

Separating Build Dependencies from Runtime Dependencies in pyproject.toml

To avoid version conflicts and ensure reproducible installs, use [build-system].requires for build tools only and [project].dependencies for runtime libraries. Pin exact versions in a separate requirements.txt generated with pip freeze or pip-compile.

pyproject.toml / dependencies / packaging / reproducibility / pip / pip-tools

Using pip freeze and --no-deps for Repeatable and Secure Python Package Installation

pip freeze captures all direct and transitive dependencies in a requirements file, ensuring repeatable installations. Using --no-deps during installation adds a safety layer by preventing automatic installation of transitive dependencies. For stronger integrity guarantees, hash-checking mode with pip-compile --generate-hashes verifies downloaded artifacts, although no strategy fully eliminates repository or supply-chain risks.

pip / dependencies / install / freeze / no-deps / repeatable / security / requirements

Declaring and resolving extras in pyproject.toml, including self-referential groups

Each key under [project.optional-dependencies] becomes a Provides-Extra entry whose dependency array elements are gated by an environment marker, so pip only installs them when the user requests the bracket syntax. Self-referencing extras compose groups but require modern package managers.

pyproject.toml / optional-dependencies / extras / self-referential-extras / PEP-621 / packaging

SHA-256 hashes versus wheelhouse for repeatable Python server deployments

Use SHA-256 hash-checking when servers can still reach an index but you need tamper resistance beyond version pinning; use a wheelhouse when the server is offline or must avoid recompilation. Choose the repeatability level by environment: pinning for a cross-platform baseline, hashes for automated tamper protection, and wheelhouse for full offline isolation with portability limits.

pip / repeatable installs / SHA-256 hash-checking / wheelhouse / requirements.txt / offline deployment / server deployment / Python packaging

Describe build and project metadata in pyproject.toml without breaking repeatable pip installs

Use [build-system] for build-time dependencies and [project] for runtime dependency specifiers, then keep pyproject.toml as a declaration rather than a lockfile. For repeatable installs, generate a separate pinned requirements file, add hash-checking, or build a wheelhouse bundle instead of overloading pyproject.toml with locked install state.

pyproject.toml / build-system / project metadata / repeatable installs / pip / pinning / hash-checking / wheelhouse