Interview Prep/Build Tools (Java, Node.js, Python, .NET)/Python builds (pip, venv, requirements.txt)

What is PyPI and how do companies use a private package index?

BeginnerConceptPython builds (pip, venv, requirements.txt)
Answer

Short answer

PyPI (Python Package Index, pypi.org) is the public repository pip downloads packages from. Companies often put a private index in front — Nexus, JFrog Artifactory, AWS CodeArtifact or Azure Artifacts — to cache PyPI (faster, survives outages), host internal packages, and control what's allowed in.

Configuring pip

pip install -r requirements.txt --index-url https://nexus.company.com/repository/pypi-all/simple
# /etc/pip.conf  or  ~/.config/pip/pip.conf
[global]
index-url = https://nexus.company.com/repository/pypi-all/simple

Credentials come from the CI secret store (e.g. a token in the URL injected via an env var), never committed.

Dependency confusion warning

Using --extra-index-url (internal + public at the same time) is risky: an attacker can publish a public package with the same name as your internal one and a higher version, and pip may pick theirs. Use a single index that proxies PyPI and hosts internal packages.

What to say in the interview

"PyPI is the public index. We route all installs through a single internal proxy like Nexus or CodeArtifact via index-url, which caches PyPI, hosts our internal packages and avoids dependency-confusion attacks from extra-index-url."

All Build Tools (Java, Node.js, Python, .NET) questions Roadmap: Python apps: pip, venv & requirements.txt

More on Python builds (pip, venv, requirements.txt)