Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

You need to guarantee that a Python service's dependencies are exactly what was tested. What do you do?

AdvancedScenarioTesting, CI/CD, packaging & services
Answer

Situation read → Reproducibility and supply-chain integrity.

What I'd do →

  1. Lock all dependencies, including transitive, with hashes (pip-compile --generate-hashes or uv lock).
  2. Install with pip install --require-hashes --no-deps -r requirements.txt (or uv sync --frozen) in the image build.
  3. Build the image once, test that image, promote the same digest to production.
  4. Generate an SBOM (Syft) and scan (Trivy/Grype); sign the image (cosign).

Why → Hashes stop tampered packages; promoting the same digest guarantees "tested == deployed".

Interview tip → "Build once, promote by digest" is the key line.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services