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.1

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.1
File Size Uploaded Provenance Actions
codemetrics-2.0.1.tar.gz 54.1 kB With provenance Details for codemetrics-2.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 82.9 kB

Release files / codemetrics-2.0.1.tar.gz

Download URL codemetrics-2.0.1.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
95411f8bc6d278ca37bc5072e89c02bce45281032675ecb97a55e47f4940926e
BLAKE2b-256 checksum
How to use checksums
10e9f2e5ccf00e6b418c66fda1df0ad035c2e1e3d8b69a3d26b3ff6e154b3779
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.1-py3-none-any.whl

Download URL codemetrics-2.0.1-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a1bef9843bcf9f638bdc1078c8aca846bb8c3b34ff7938e8912f44c63b457b9
BLAKE2b-256 checksum
How to use checksums
1fd9ad53a661b7b1aebefd03325b86fae05d0b2fc3a274dcaa3e9f1df1ec3281
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.1

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.1.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