Packaging & Tooling Interview Questions (Python)
10 Packaging & Tooling questions from the Python track. Read each short answer here, then open a question for the full explanation, examples, common mistakes, and sources.
- Junior
Why do we use virtual environments (venv)?
To isolate each project's libraries from the system Python and from other projects, so versions do not conflict and installing does not need administrator privileges.
Read the full explanation - Mid-level
What is the role of the pyproject.toml file?
It is the standard file that describes the build system [build-system], the project metadata [project] (name, version, dependencies, and required Python version), and tool settings under [tool.*].
Read the full explanation - Mid-level
What is the difference between requirements and constraints files?
A requirements file states what must be installed, while a constraints file restricts the allowed versions of packages that may be installed, without adding any package by itself.
Read the full explanation - Mid-level
What is the benefit of the src layout for organizing packages?
Putting the code inside a src folder prevents it from being imported accidentally from the current working directory, so tests are forced to use the installed package and packaging errors appear early.
Read the full explanation - Junior
What does an editable install mean?
Installing the package so it points directly at the source files (pip install -e .), so your edits show up immediately without reinstalling.
Read the full explanation - Mid-level
What is the difference between a wheel and a source distribution (sdist)?
A wheel is a built package ready to install by just copying files, while an sdist is a source archive that needs a build step on the user's machine and may need a compiler if it contains C extensions.
Read the full explanation - Mid-level
How do you expose a CLI command from a Python package?
Define a console script in [project.scripts] inside pyproject.toml pointing to a main function, and installing creates an executable with that name in the environment's bin.
Read the full explanation - Mid-level
How do you decide which Python versions your project supports?
Declare requires-python in pyproject.toml (such as >=3.11), then actually test on the minimum and the newest version in a CI matrix.
Read the full explanation - Mid-level
How do you configure logging in a library or service without annoying its users?
In a library, create a logger named after the module with logging.getLogger(__name__) and no handlers or basicConfig, and leave configuration to the application, which decides the handlers, levels, and format.
Read the full explanation - Senior
How do you separate configuration from secrets in a Python application?
Read configuration and secrets from environment variables or a secret manager at startup, convert them to a typed settings object that is validated once, and never put secrets in the code, the package, or Git.
Read the full explanation