Principle:Langchain ai Langchain Pre Release Validation
Overview
Pre-Release Validation is a multi-step quality gate that verifies release artifacts are functional, dependency-correct, and backward-compatible before production publishing.
Description
After building distribution artifacts and uploading them to a staging index, a robust release pipeline performs several validation steps before allowing the package to be published to production. These checks catch issues that unit tests during development may miss, because they operate on the actual built artifact rather than the source tree.
The validation typically includes:
- Import check: Install the built wheel into a clean virtual environment and verify the package can be imported. This catches missing files, broken
__init__.py, and packaging configuration errors. - Pre-release dependency check: Ensure that stable releases do not depend on pre-release versions of other packages (e.g., a dependency specifier containing
rcorallow-prereleases). - Unit tests against the built artifact: Run the full unit test suite using the installed wheel rather than the source tree, catching issues where the package manifest does not include required files.
- Minimum version tests: Determine the lowest published versions of key dependencies that satisfy the version constraints, install those versions, and re-run the test suite. This ensures the declared lower bounds are actually functional.
- Integration tests: For partner packages, run integration tests with real API credentials to verify end-to-end functionality.
Each step is a gate: if any step fails, the release is blocked.
Usage
Use pre-release validation:
- On every release pipeline execution, automatically.
- To diagnose packaging issues by examining which validation step failed.
- As a template for adding validation steps to new packages.
Practical Guide
1. Create a clean virtual environment (no cache).
2. Install the built wheel from the dist/ artifacts.
3. Verify the package imports successfully.
4. Install test dependencies.
5. Re-install the built wheel to override any editable install.
6. Run the prerelease dependency checker.
7. Run the unit test suite.
8. Compute minimum dependency versions from the version constraints.
9. Install minimum versions and re-run unit tests.
10. (Partner packages only) Run integration tests.
Pseudocode:
venv = create_venv(no_cache=true)
# Step 1: Import check
venv.install("dist/*.whl")
venv.run("python -c 'import pkg_name; print(dir(pkg_name))'")
# Step 2: Install test deps + re-install wheel
venv.install_group("test")
venv.install("dist/*.whl") # override editable
# Step 3: Prerelease dependency check
venv.run("check_prerelease_dependencies.py pyproject.toml")
# Step 4: Unit tests
run("make tests")
# Step 5: Minimum version tests
min_versions = get_min_versions("pyproject.toml", "release", python_version)
venv.install(min_versions)
run("make tests")
# Step 6: Integration tests (partner packages only)
if is_partner_package:
run("make integration_tests")