1/140
Looks like no tags are added yet.
Module
An importable unit of Python code, often a single .py file; for example, blackjack.deck.
Package
A module that can contain child modules or packages; for example, blackjack contains blackjack.deck.
Submodule
A module below a parent package in the import hierarchy; blackjack.deck is a submodule of blackjack.
Subpackage
A child module that is itself a package and can contain further modules or packages.
Regular package
A package initialized through an init.py file.
Namespace package
A shared import name to which separate projects can contribute; it can span multiple search locations without a shared init.py.
init.py
The initialization file executed when a regular package is first imported in a Python process; it can expose names for consumers.
Public API
The names and behavior that consumers are intended to rely on, including functions, classes, arguments, return values, and units.
Distribution
Installable code and metadata; its distribution name can differ from the Python import name.
Editable install
An installation that uses working source files, allowing ordinary Python source edits to appear on a fresh run without reinstalling.
Entry point
A mapping from an installed shell command to a Python function, such as blackjack-sim to blackjack.simulation:main.
Resource
A non-code file shipped with a package, such as strategies.json.
Runtime dependency
A package required while the installed code runs; declare it in [project] dependencies.
Build dependency
A package required to produce a distribution; declare Python build requirements in [build-system] requires.
Dependency group
A project-local set of dependencies, such as development or testing tools; these groups are not automatically installed for downstream consumers.
Extra
A named set of optional dependencies offered to consumers through published metadata, such as a plot extra requiring Matplotlib.
Metadata
Recorded package information, such as its name, version, supported Python versions, dependencies, and license.
Lockfile
A record of resolved dependency versions and artifacts for a project environment.
pyproject.toml
The project configuration file containing metadata, dependency declarations, build settings, and possibly tool-specific settings.
Source tree
The collection of working project files and directories that a developer edits.
src layout
A project layout placing importable code under src/, which reduces accidental imports from the project root.
Frontend
The tool that coordinates a build; in this lecture, uv invoked through uv build.
Backend
The software that constructs distributions; the lecture uses uv_build for pure Python and setuptools for Cython.
Build isolation
Keeping Python build requirements separate from the developer environment so the build does not silently rely on undeclared local Python packages.
sdist (source distribution)
An archive containing the project source and inputs needed to build a distribution without the original checkout; commonly a .tar.gz file.
Wheel
A built distribution prepared for installation, with the .whl extension; it can contain Python files, compiled extensions, resources, and metadata.
Compiler
A system tool that translates native source code, such as C, into machine code.
Cython
A language and toolchain that translates Python-like code, optionally using static types, into native source such as C for compilation.
Extension module
Compiled native code that Python can import and call.
CPython
The usual implementation of Python; cp313 in a wheel tag refers to CPython 3.13.
ABI (application binary interface)
Low-level binary layouts and calling conventions needed for compiled components to work together.
Platform tag
Wheel compatibility information identifying an operating system and processor architecture, such as linux_x86_64.
Shared library
Native code loaded from a separate library file and used by another program or extension.
glibc
The GNU C library used by many Linux distributions; compiled extensions may require functions provided by particular glibc versions.
manylinux
A compatibility policy for Linux wheels using glibc, specifying system requirements that conforming wheels must meet.
Compatibility baseline
The minimum supported system level; manylinux_2_17_x86_64 specifies a glibc 2.17 baseline for x86_64 Linux.
Build container
A controlled system environment containing a toolchain and libraries for building software.
auditwheel
A tool that inspects Linux wheels' native-library dependencies and can bundle eligible libraries when repairing a wheel.
License
Terms granting permission to use, modify, or redistribute code, subject to specified conditions.
SPDX expression
A standardized expression identifying license terms; MIT is a simple example.
Semantic versioning
A compatibility policy using MAJOR.MINOR.PATCH: breaking changes increment MAJOR, compatible features MINOR, and compatible fixes PATCH for a stable public API.
PEP 440
Python's rules for version identifiers, ordering, and requirement specifiers; a project's compatibility policy is a separate matter.
Git commit
A recorded source revision identified by a commit ID.
Git tag
A readable reference to a source revision, such as v0.2.0; a tag identifies source and does not contain the built wheel.
SHA-256 digest
A 64-character hexadecimal fingerprint of exact file bytes, used to compare an artifact with a trusted expected value.
Package index
A service from which installers discover and obtain package distributions.
PyPI
The main public Python Package Index used to distribute Python packages.
TestPyPI
A separate package index for testing package publication and installation.
Explicit index
In the lecture's uv configuration, an index used only for packages explicitly assigned to it.
Upload endpoint
The service URL that receives published distribution files; it can differ from the URL used to discover packages for installation.
GEV (generalized extreme-value distribution)
A probability distribution fitted in the lecture to the maximum losses from flat-bet evenings.
Martingale betting
A betting rule that doubles the bet after a loss; the lecture's model assumes unlimited credit.
What problem does packaging solve?
It lets another project reliably install and use your code by supplying code, metadata, requirements, resources, and build information.
Which project supplies the blackjack game, and which performs the analysis?
am215-blackjack supplies the game; blackjack-extremes uses it to analyze large betting losses.
Distribution name versus import name
The distribution name is used by installers, such as am215-blackjack; the import name is used in Python, such as blackjack.
What does uv add am215-blackjack do?
Adds the distribution as a dependency of the current project and normally updates its lockfile and environment.
What does from blackjack import Deck, play_round do?
Makes those names from blackjack available in the current Python code; importing play_round does not itself call the function.
What does from .deck import Card, Deck mean inside init.py?
Import Card and Deck from the deck module within the current package, exposing those names through the package.
Re-export
Making a name defined in an internal module available through another import location; for example, exposing Deck through blackjack.init.py.
Would an empty init.py automatically expose the Deck class from deck.py?
No. The class must be explicitly imported or otherwise defined in the package namespace for from blackjack import Deck to work as shown.
Can two projects contribute lab.cards and lab.statistics to the same namespace?
Yes. Both can contribute under lab if neither defines a conflicting regular lab package; in the example neither supplies lab/init.py.
What does lab.file is None show in the namespace example?
The shared lab namespace has no single initializing source file; it is assembled from package search locations.
How can a source checkout hide an incomplete wheel?
Python may import complete source files from the checkout instead of the installed wheel's incomplete package, making a broken distribution appear to work.
What does requires-python = ">=3.12" declare?
The project requires Python 3.12 or newer; this is metadata, not a Python program statement.
What does dependencies = ["numpy>=2"] declare?
NumPy version 2 or newer is a runtime requirement of the installed project.
What does uv_build>=0.12.1,<0.13 mean?
Use a uv_build version at least 0.12.1 and below 0.13; both constraints must hold.
Why set module-name = "blackjack" in the build configuration?
To identify the importable package when its name differs from the distribution name am215-blackjack.
Runtime dependency versus development dependency
Runtime dependencies are needed by consumers running the package; development dependencies are tools used while working on the project.
Dependency group versus extra
A group is local project tooling; an extra is optional functionality's dependencies that consumers can request through the distribution metadata.
Given NumPy as runtime, Ruff in dev, and pytest in test, what does uv sync --no-default-groups --group test select?
NumPy and pytest, plus any dependencies they require; Ruff is omitted because default groups are disabled and dev is not selected.
Given a plot extra requiring Matplotlib, what does uv sync --no-default-groups --extra plot select?
Runtime dependencies such as NumPy and the plot extra's Matplotlib; it does not select the dev or test groups.
Does --group test automatically exclude the default dev group?
No. uv sync --group test also includes default groups unless you explicitly exclude them, as with --no-default-groups.
How does a consumer request the plotting extra?
Use the requirement am215-blackjack[plot]; extras add optional dependencies to the package's normal requirements.
Does selecting an extra automatically run that feature?
No. Selecting an extra installs its optional dependencies; the program still needs to invoke the feature.
What does uv sync do in the lecture's installable project?
Synchronizes the project environment with the selected dependencies and installs the project editably by default.
What does uv run python -c "import blackjack; print(blackjack.file)" check?
Runs inline Python in the project environment and prints which blackjack file was imported; a src/ path indicates working source in this example.
What does python -c mean?
Execute the Python code supplied in the following command-line string instead of reading a script file.
Does a library's development lockfile bind its users?
No. Consumers resolve the library's declared requirements together with their own requirements and use their own locks.
Version constraint versus resolved version
A constraint specifies acceptable versions, such as numpy>=2; resolution selects particular versions satisfying all relevant project requirements.
What does blackjack-sim = "blackjack.simulation:main" declare under [project.scripts]?
An installed command named blackjack-sim that calls main in the blackjack.simulation module; the colon separates module and function names.
What do --seed 42 --rounds 200 --trajectories 3 supply to blackjack-sim?
A random seed of 42, 200 rounds per trajectory, and three trajectories; the program's argument-handling code interprets these options.
What does (files("blackjack") / "strategies.json").read_text() do?
Finds the resource through the installed blackjack package and reads its text; / joins the resource path rather than performing division.
Why use importlib.resources instead of relying on the current directory?
It locates data through the installed package, allowing the program to find resources when run from another directory.
Does reading a resource through importlib.resources guarantee that it was included in the wheel?
No. The build must actually include the resource; the access method cannot recover a missing file.
What happens during an isolated build?
The frontend prepares a separate build environment, installs declared build requirements, and asks the backend to produce distributions.
Does build isolation provide a complete operating system or guarantee a C compiler?
No. It isolates Python build dependencies; required system compilers and libraries must still be available.
Does building a wheel always compile code?
No. Pure-Python wheels package Python files and metadata; native extensions require compilation.
What must an sdist contain?
Enough project source, configuration, and other necessary project inputs to build without the original checkout, using the required build tools.
What does a wheel's .dist-info directory contain?
Distribution metadata, including files such as METADATA, entry_points.txt, and license text.
What does METADATA record in a wheel?
Package information including runtime requirements and optional extras.
What do py3-none-any mean in a wheel filename?
Python 3 tag; no specific Python ABI requirement; no platform-specific restriction in the tag. Separate Python-version requirements in metadata still apply.
What does uv build produce by default in the lecture?
An sdist, then a wheel built from that sdist, with outputs written to dist/.
uv build --sdist versus uv build --wheel
--sdist builds only the source archive; --wheel builds a wheel directly from the checkout.
Why build a wheel from a saved sdist?
To check that the distributed source contains the necessary project build inputs without relying on extra files in the checkout.
What does uv build dist/am215_blackjack-0.2.0.tar.gz --wheel --out-dir rebuilt do?
Builds a wheel using the saved source archive and writes the output to rebuilt/.
Does rebuilding automatically remove old versions from dist/?
No. Matching filenames are replaced, but files with different names can remain.
What does uv venv --python 3.13 consumer do?
Creates a virtual environment named consumer using Python 3.13.
What does uv pip install --python consumer/bin/python . do?
Builds and installs the source project in the current directory into the consumer environment; . means the current directory.
Installing a checkout or sdist versus installing a wheel
A checkout or sdist must be built into a wheel before installation; an existing compatible wheel supplies prepared files without rebuilding that project.
Does a wheel normally contain all its Python dependencies?
No. It declares runtime dependencies, which the installer resolves and installs separately as needed.