Skip to main content

Difflog

Automated Changelog Generation via API Diffing for Python Projects

Difflog simplifies the task of generating changelogs by using static analysis to detect API-level changes in Python scripts. It outputs a concise Markdown changelog, ideal for release notes or CI/CD workflows.

Example integration: See .github/workflows/changes.yml


Installation

Install Difflog via pip:

pip install difflog

Detecting API Changes Between Files

Given two versions of a Python script:

main1.py

def main():
    print("Hello, world!")

if __name__ == "__main__":
    main()

main2.py

def main(name: str):
    print("Hello, world! My name is", name)

if __name__ == "__main__":
    main("John")
    print("Goodbye, world!")

Run the following command to detect API differences:

python -m difflog main1.py main2.py

Example output:

[main] Added positional or keyword argument `name`

For more examples, see tests/test_api_diffing.py


Generating a Markdown Changelog from Git

If you're working in a Git repository, you can generate a changelog based on file-level API changes between commits:

difflog.git_report > CHANGES.md

This will:

  • Analyze code changes since the last Git push
  • Output a changelog in GitHub's Markdown format to CHANGES.md

You can also specify a revision range:

difflog.git_report --from-rev v1.0.0 --to-rev HEAD > CHANGES.md

Programmatic API Usage

Use Difflog as a Python module for custom workflows, e.g., filtering changes, customizing output formats, etc.

import difflog

with open("old_file.py") as f:
    old_code = f.read()

with open("new_file.py") as f:
    new_code = f.read()

for change in difflog.diff(old_code, new_code):
    print(change)

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a new branch
  3. Submit a pull request

See existing issues or open a new one to discuss your ideas.


License

Licensed under the Apache License 2.0. See LICENSE for details.


Acknowledgments

Difflog leverages the excellent DeepDiff library for structural diffing.

Metadata

Release files for difflog 0.0.2

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

Source distribution (sdist)

Source distribution for difflog 0.0.2
File Size Uploaded
difflog-0.0.2.tar.gz 13.8 kB Details

Built distribution (wheel)

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

Total release size: 26.6 kB

Release files / difflog-0.0.2.tar.gz

Download URL difflog-0.0.2.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1fbb7940807c256640bd833f4be82f276cb87aeff74baa8ab1093e18b1eb5d01
BLAKE2b-256 checksum
How to use checksums
f7507ec6d520b2529744e61639fb26280d62dc440c0dfcba0615a90f60a7b95a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / difflog-0.0.2-py3-none-any.whl

Download URL difflog-0.0.2-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52d559472676696d5d544f4dce3c5caedf80a4e73a10391cd8f137d917369545
BLAKE2b-256 checksum
How to use checksums
ab02025e3d522b2e501e8eb367779eda88cd29627edc30c03f34e5f5c3a42880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9
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