Skip to main content
PyPi version Python compatibility GitHub Actions Workflow Status Libraries.io dependency status for latest release Documentation Coverage Codacy

codemetrics

Mine your SCM for insight on your software. A work of love inspired by Adam Tornhill’s books.

Code metrics is a simple Python module that leverage pandas and your source control management (SCM) tool togenerate insight on your code base.

  • pandas: for data munching.

  • lizard: for code complexity calculation.

  • cloc.pl (script): for line counts from cloc

  • For now, only Subversion and git are supported.

Installation

To install codemetrics into a uv environment:

uv venv
uv pip install codemetrics

Usage

This is a simple tool that makes it easy to retrieve information from your Source Control Management (SCM) repository and hopefully gain insight from it.

import codemetrics as cm
import cm.git

project = cm.GitProject('path/to/project')
loc_df = cm.get_cloc(project, cloc_program='/path/to/cloc')
log_df = cm.get_log(project)
ages_df = cm.get_ages(log_df)

To retrieve the number of lines changed by revision with Subversion:

import codemetrics as cm
import cm.git

project = cm.SvnProject('path/to/project')
log_df = cm.get_log(project).set_index(['revision', 'path'])
log_df.loc[:, ['added', 'removed']] = log_df.reset_index().\
                                         groupby('revision').\
                                         apply(cm.svn.get_diff_stats, chunks=False)

See module documentation for more advanced functions or the example notebook where codemetrics is applied to pandas.

There is also an example notebook running codemetrics on the pandas code base, and the example html export of that notebook output (some features are missing like the display of file names when hovering on the circles).

License

Licensed under the term of MIT License. See attached file LICENSE.txt.

Credits

Development

Install uv, then run:

uv sync --locked
uv run --locked pytest

Dependencies are declared in pyproject.toml and pinned in uv.lock. Use uv sync --locked --group docs for documentation dependencies or uv sync --locked --group notebooks for notebooks. See CONTRIBUTING.rst for the full workflow.

Metadata

Release files for codemetrics 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codemetrics 2.0.0
File Size Uploaded Provenance Actions
codemetrics-2.0.0.tar.gz 54.1 kB With provenance Details for codemetrics-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codemetrics 2.0.0
File Interpreter ABI Platform Actions
codemetrics-2.0.0-py3-none-any.whl Python 3 none any Details for codemetrics-2.0.0-py3-none-any.whl

Total release size: 82.8 kB

Release files / codemetrics-2.0.0.tar.gz

Download URL codemetrics-2.0.0.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ba7182a77a3194f9c8d22ef5b9502d58ef87c6e82e2395e189ac58aa8150532e
BLAKE2b-256 checksum
How to use checksums
9b9d4458ae0ded9ef2ad51f2cb37ef43406aada59f1291dcd8e9374581b670fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / codemetrics-2.0.0-py3-none-any.whl

Download URL codemetrics-2.0.0-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82f3c8608a395588b302713938c147cd79a5ce187e248a82bb01c7904cd1df1c
BLAKE2b-256 checksum
How to use checksums
b5912b390d3d820d2c46055d3d7e7233814897e1cb5d2e9cc7915a140a2df028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for codemetrics 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codemetrics-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page