Codecov Python Uploader
The `codecov` Python package provides a command-line interface for uploading code coverage reports to the Codecov.io platform. It integrates with various CI/CD services and testing tools to provide hosted coverage analytics for GitHub, Bitbucket, and GitLab repositories. Currently at version 2.1.13, this specific Python uploader is deprecated in favor of a universal Codecov CLI or GitHub Action, and its release cadence is irregular due to past deprecation and re-instatement events.
Warnings
- breaking The `codecov-python` uploader is officially deprecated by Codecov. Users are strongly recommended to migrate to the universal Codecov CLI (binary uploader) or the Codecov GitHub Action. Continued use of this Python package may lead to future unannounced breakages or a complete cessation of functionality.
- breaking In April 2023, the `codecov` package was abruptly removed from PyPI, causing widespread build failures for users before it was re-instated as version 2.1.13 with a deprecation notice. This incident highlighted the instability and deprecated status of the package.
- gotcha Users have reported inconsistent and unreliable behavior with the Python uploader over time, including random missed coverage, failures to upload reports (e.g., EPIPE errors), and issues with status reporting back to CI systems. This can lead to flaky CI builds and distrust in coverage metrics.
- gotcha Incorrect or missing upload tokens, especially for private repositories, will prevent coverage data from being successfully uploaded and processed. Additionally, issues can arise if base or head commits lack coverage reports, or if file paths in the coverage report do not correctly map to the repository structure, leading to 'missing base report' or 'unusable report' errors.
Install
-
pip install codecov
Imports
- codecov
codecov -t $CODECOV_TOKEN
Quickstart
# 1. Install necessary packages
pip install pytest pytest-cov
# 2. Run tests and generate coverage report (e.g., using pytest-cov)
pytest --cov=. --cov-report=xml
# 3. Upload coverage report to Codecov (usually in a CI environment)
# Replace CODECOV_TOKEN with your actual Codecov upload token for private repos
# For public repos, this is often not needed with CI integrations.
# Set CODECOV_TOKEN as an environment variable in your CI setup.
codecov -t "${CODECOV_TOKEN:-}"