Registry / data / commoncode

commoncode

JSON →
library32.5.2pypypi✓ verified 84d ago

commoncode is a collection of essential utilities for Python, originally split from the ScanCode project. It provides robust tools for file system operations, hashing, system information, command execution, and more. It is actively maintained with frequent minor releases to support new Python versions and address bug fixes. The current version is 32.4.2.

pip install commoncode
INSTALL
IMPORT
SIG · COMMONCODE
C
commoncode
datapythonv32.5.2
Install
2.9s avg
Import
Disk
27MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v32.5.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 28.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.9s · import 0.000s · 30MB
27MB installed
● package 27MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

set_re_max_cache
from commoncode import set_re_max_cache
from commoncode.fileutils import file_sha1

This quickstart demonstrates how to use `commoncode.fileutils.file_sha1` to compute a file's SHA1 checksum and `commoncode.system.get_system_info` to retrieve basic system details. It creates a temporary file and cleans it up afterward.

import os from pathlib import Path from commoncode.fileutils import file_sha1 # Create a dummy file for demonstration dummy_file_path = Path('dummy_file.txt') with open(dummy_file_path, 'w') as f: f.write('Hello, commoncode!\n') f.write('This is a test file.\n') try: # Get SHA1 checksum of the file sha1_checksum = file_sha1(str(dummy_file_path)) print(f"SHA1 of '{dummy_file_path}': {sha1_checksum}") # Get system information from commoncode.system import get_system_info system_info = get_system_info() print(f"Python Version: {system_info.get('python_version')}") print(f"OS Release: {system_info.get('os_release_id')}") finally: # Clean up the dummy file if dummy_file_path.exists(): os.remove(dummy_file_path)
Debug
Known issues
breakingcommoncode dropped support for Python 3.9 in version 32.4.0. Using commoncode 32.4.0 or newer with Python 3.9 will lead to installation errors or runtime issues.
fix
Upgrade your Python environment to 3.10 or newer, or pin commoncode to an older version (<32.4.0) if you must use Python 3.9.
affects: >=32.4.0
breakingVersions of commoncode prior to 32.3.0 had compatibility issues with 'click' version 8.1.3 and newer, potentially causing errors in CLI applications that use commoncode.
fix
Upgrade commoncode to version 32.3.0 or newer to ensure compatibility with recent 'click' versions. (Fixed in 32.3.0, further fixes in 32.4.0).
affects: <32.3.0
gotchaPaths containing non-UTF-8 bytes were not handled correctly in versions prior to 32.4.0, potentially leading to errors when processing file paths with unusual characters.
fix
Upgrade to commoncode 32.4.0 or newer to ensure robust handling of non-UTF-8 paths. For older versions, ensure all paths are UTF-8 compliant.
affects: <32.4.0
breakingVersion 32.2.0 introduced adjustments to the `as_unicode` function due to breaking changes in `bs4` (BeautifulSoup4) version 4.13. If you rely on `as_unicode` and use an older `commoncode` with `bs4>=4.13`, you may encounter errors.
fix
Upgrade commoncode to version 32.2.0 or newer to ensure compatibility with `bs4` 4.13+ when using `as_unicode`.
affects: <32.2.0
Upgrade
Version history
32.5.2latest on PyPI · released Jun 11, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer.
Agent activity
39 hits · last 30 days
node
34
OpenAI (training)
1
Resources
commoncode — pip install commoncode · libregistry