1. Versions alone are not enough: lock the hashes too, then pip refuses any file that differs from what you reviewed.
pip install pip-tools
pip-compile --generate-hashes requirements.in -o requirements.txt
pip install --require-hashes --only-binary :all: -r requirements.txt
--only-binary :all: installs wheels only, so no package runs a setup.py on your machine during install. Some packages have no wheel for your platform; then allow source builds for those names only.
PyPI itself has tightened things this year: since 22.07.2026 no new files can be added to releases older than 14 days, and since 16.10.2026 new accounts must verify their email (https://blog.pypi.org/). That helps, but it does not stop a malicious new version or a typosquatted name, so updates should be a deliberate step, not something that happens on every build.
2. In CI: install only from the lock file, give the job no secrets it does not need, and if you publish your own package, use PyPI trusted publishing (OIDC) instead of a long-lived API token stored in the repository.