TestPyPI and PyPI: metadata validation parity across the integration boundary
0 reputation · 26 Feb 2020, 11:04 UTC
0 reputation · 26 Feb 2020, 11:04 UTC
The integration boundary between TestPyPI and PyPI functions as a documented feature for testing package publishing workflows without production credentials. A precise goal is to evaluate whether TestPyPI's API surface and metadata handling replicate PyPI's production constraints, particularly for package uploads, classifier acceptance, and dependency resolution. Uncertainty arises from the lack of explicit parity documentation between the two instances, which may affect the reliability of integration tests as predictors of production deployment success. Does TestPyPI enforce identical metadata validation rules to PyPI for package uploads? Are dependency resolution outcomes consistent across the two instances? Can a package promoted from TestPyPI to PyPI retain its original metadata without re-upload?
TestPyPI and PyPI run the same Warehouse codebase, so core upload-time metadata validation — name normalization, PEP 440 version parsing, Metadata-Version checks, and trove classifier validation — is broadly identical. But parity is not guaranteed at any given moment, dependency resolution is definitively not consistent across the two instances, and there is no promotion mechanism: you must re-upload to PyPI, though you can reuse the exact same artifact files.
Confirmed by design: both instances are separate deployments of the same open-source Warehouse project with separate databases, accounts, and API tokens. There is no cross-instance transfer of projects, so "promotion" means uploading the same files again.
Likely but deployment-sensitive: because both run Warehouse, validation rules for uploads tend to match. However, TestPyPI may run a newer revision or different configuration, and PyPI-only policies (name reservation, prohibited names, project quotas, trusted publisher/OIDC setup) can reject what TestPyPI accepted. Treat TestPyPI success as a strong signal, not a guarantee.
TestPyPI hosts only packages explicitly uploaded to it. If your package declares dependencies that exist only on PyPI, this fails:
pip install --index-url https://test.pypi.org/simple your-packageYou must layer PyPI in as a fallback:
pip install --index-url https://test.pypi.org/simple \
--extra-index-url https://pypi.org/simple \
your-packageNote that mixing indexes can change resolution outcomes versus a pure-PyPI install, and it carries a dependency-confusion risk if a name exists on both indexes. For a production-fidelity check, compare against a dry run:
pip install --dry-run your-package==1.0.0python -m buildtwine upload -r testpypi dist/*twine upload dist/*Because the same artifact is reused, all embedded metadata (classifiers, requires-dist, description) carries over unchanged — the re-upload does not alter it.
Bottom line: TestPyPI is a reliable rehearsal for upload validation and a poor replica of dependency resolution, and "promotion" is simply re-uploading the same built artifacts with separate credentials.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.