Skip to main content

PyCFUtils

PyPI version Python versions License: MIT

PyCFUtils (Cristi Fati's Utils for Python (&& more)) is a cross-platform collection of utility modules covering IO, networking, system operations, ctypes helpers, GUI wrappers (Windows), and SetupTools extensions for building native libraries. It has no global dependencies outside the Python standard library.

Install

python -m pip install --upgrade pycfutils

Usage

IO

import pycfutils.io

print("Press a key in less than one second...")
print(pycfutils.io.read_key(timeout=1))

CTypes

import pycfutils.ctypes

print(pycfutils.ctypes.endianness())

Miscellaneous utilities

import pycfutils.miscellaneous as misc

print(misc.timestamp_string(human_readable=True, separator="T", microseconds=True))
print(tuple(misc.progression(ratio=2, count=20)))
print(
    misc.merge_dicts({1: 2}, misc.nest_object((1,), 3)),
    misc.nested_dict_item({1: {2: 3}}, (1, 2)),
)
print(misc.randomize(180, round_result=True))
print(misc.call_stack())
misc.pretty_print(
    tuple(
        misc.process_path_items(
            path="${a_directory_with_few_child_items}",
            processor=lambda arg: __import__("os").stat(arg).st_size,
        )
    ),
    head="Path items:",
    tail="",
)

Timed execution decorator

import time

import pycfutils.miscellaneous as misc


@misc.timed_execution()
def func(arg0, kw0=1):
    time.sleep(0.2)
    return 5


func("123")

Networking

import pycfutils.network
from pycfutils.exceptions import NetworkException

try:
    print(pycfutils.network.connect_to_server("127.0.0.1", 22))
except NetworkException as e:
    print(e)

System

import pycfutils.system

pycfutils.system.cpu_stress(3)

GUI (Windows only)

import pycfutils.gui

print(pycfutils.gui.message_box("Title", "Text to display", x=320, y=200))

Building a native library (.dll / .so) with SetupTools

Parts of setup.py:

# Requires SetupTools (python -m pip install setuptools) for Python >= 3.12
from setuptools import setup

from pycfutils.setup.command.build_clibdll import build_clibdll
from pycfutils.setup.command.install_platlib import install_platlib  # Optional

dll = (
    "dll_name",
    {
        "sources": [
            "src0.c",
            "src1.c",
        ],
        # ...
        "dll": True,  # False (or nothing) for regular (static) library
        "copy_files": {  # Optional (copy artifacts)
            "dll_name.so": "pkg_name",  # dll_name.dll on Win
        },
        # ...
    },
)


setup(
    name="pkg_name",
    # ...
    cmdclass={
        "build_clib": build_clibdll,
        "install": install_platlib,
    },
    libraries=[dll],
    # ...
)

CLI tools

The tools folder contains CLI wrapper scripts. To list them and view their help:

Unix:

ls "pycfutils/tools"
for script in $(find "pycfutils/tools" -maxdepth 1 -type f); do python "${script}" -h; done

Windows:

dir /b "pycfutils\tools"
for /f %g in ('dir /b /a-d /a-l "pycfutils\tools\*.py"') do (python "pycfutils\tools\%g" -h)

They can also be run as modules. For example, in two separate terminals:

Terminal 1:

python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180

# Go to Terminal 2 and start the server, then come back and re-run:

python -m pycfutils.tools.connect_to_server -a 127.0.0.1 -p 16180

Terminal 2:

python -m pycfutils.tools.start_server -a 127.0.0.1 -p 16180

Notes

  • The package has no global dependencies outside the Python standard library. However, some subpackages have their own requirements:
    • pycfutils.setup.command: requires SetupTools (python -m pip install setuptools) for Python >= 3.12

Changelog

See CHANGELOG for a full list of changes.

Contributing

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Metadata

Release files for pycfutils 2026.6.12

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

Source distribution (sdist)

Source distribution for pycfutils 2026.6.12
File Size Uploaded Provenance Actions
pycfutils-2026.6.12.tar.gz 44.1 kB Without provenance Details for pycfutils-2026.6.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pycfutils 2026.6.12
File Interpreter ABI Platform Actions
pycfutils-2026.6.12-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for pycfutils-2026.6.12-py3-none-win_amd64.whl
pycfutils-2026.6.12-py3-none-win32.whl Python 3 none Windows x86-32 Details for pycfutils-2026.6.12-py3-none-win32.whl
pycfutils-2026.6.12-py3-none-any.whl Python 3 none any Details for pycfutils-2026.6.12-py3-none-any.whl

Total release size: 195.4 kB

Release files / pycfutils-2026.6.12.tar.gz

Download URL pycfutils-2026.6.12.tar.gz
Size 44.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c523477027c99d877a395228e712d64778babf9207c78a45d2e17fc9bb773942
BLAKE2b-256 checksum
How to use checksums
492f672740b1c086e42ae1f833b222e9a2082e52961092b2609bfcca4ad53bad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / pycfutils-2026.6.12-py3-none-win_amd64.whl

Download URL pycfutils-2026.6.12-py3-none-win_amd64.whl
Size 54.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
d3a1dec72d415f0a98918844f2b51533a5837bc9e8443feadd1a45a72d2cbf87
BLAKE2b-256 checksum
How to use checksums
743b3a49751ab4e5650af9aeedeedda4db1e35a5081a3af4485a28605026413d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / pycfutils-2026.6.12-py3-none-win32.whl

Download URL pycfutils-2026.6.12-py3-none-win32.whl
Size 53.6 kB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
ee20f360f954488480955af23363cde377362f66be6b7fddb79783d36e97cd53
BLAKE2b-256 checksum
How to use checksums
4b53dd400cfc836d85ecd4cf4e22e2e88f6a38fcd8fd3740d030d7f8627db311
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Release files / pycfutils-2026.6.12-py3-none-any.whl

Download URL pycfutils-2026.6.12-py3-none-any.whl
Size 43.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f15f06d617b4306a85190b1c074612c2731c826361b6bb15f23c68977d84462
BLAKE2b-256 checksum
How to use checksums
9aef5c3454e313c0752470aa94d80bdf4480e72d978a289badb283b88c5c5862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.3

Security for pycfutils 2026.6.12

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

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