Skip to main content

PyPI version

Pygfried

pygfried is a CPython extension that brings siegfried - a powerful, signature-based file format identification tool written in Go - into the Python ecosystem.

Identifying a file with pygfried

Instead of reimplementing siegfried's logic, pygfried embeds the original Go code directly, making core siegfried functionality available to Python users without any changes to the underlying detection engine.

No animals were harmed in the making of this extension.

Usage

$ pip install pygfried
$ python -q
>>> import pygfried
>>> pygfried.version()
'1.11.8'
>>> pygfried.identify("example.png")
'fmt/13'
>>> pygfried.identify("example.png", detailed=True)
{'siegfried': '1.11.8', 'scandate': '2026-09-23T18:18:29+02:00', 'signature': 'default.sig', 'created': '2026-09-15T19:45:35+10:00', 'identifiers': [{'name': 'pronom', 'details': 'DROID_SignatureFile_V125.xml; container-signature-20260119.xml'}], 'files': [{'filename': 'example.png', 'filesize': 676214, 'modified': '2025-06-13T11:53:28+02:00', 'errors': '', 'matches': [{'ns': 'pronom', 'id': 'fmt/13', 'format': 'Portable Network Graphics', 'version': '1.2', 'mime': 'image/png', 'class': 'Image (Raster)', 'basis': 'extension match png; byte match at [[0 16] [2962 4] [676202 12]]', 'warning': ''}]}]}
>>> pygfried.identify_many(["example.png", "README.md"], workers=2)
{'siegfried': '1.11.8', ...}
>>> pygfried.identify_dir("samples", recursive=True, workers=2)
{'siegfried': '1.11.8', ...}

Custom scanners

The module-level functions use Siegfried's embedded default.sig. To select another complete Siegfried signature database, create a Scanner with its path:

import pygfried

scanner = pygfried.Scanner(signature="/usr/share/siegfried/custom.sig")
scanner.identify("example.png")
scanner.identify_many(["example.png", "README.md"], workers=2)
scanner.identify_dir("samples", recursive=True, workers=2)

External databases are validated and loaded into memory when the scanner is constructed, so changing or deleting the file afterward does not affect that scanner.

As a convenience, a scanner can instead select a bundled signature profile by name:

scanner = pygfried.Scanner(profile="archivematica")
scanner.identify("disk-image.ad1")
# 'archivematica-fmt/2'

Available bundled profiles are:

  • default, which is also selected by Scanner() and matches the behavior of the module-level functions.
  • archivematica, which contains the complete PRONOM database plus Archivematica's extended identifiers for AD1, encrypted AD1, raw disk images, and AFF.

The Archivematica database is copied from the exact Siegfried module version used to compile pygfried. It is embedded in the extension, so it does not need to be installed separately.

profile and signature are keyword-only and mutually exclusive. The read-only scanner.profile property reports the bundled profile, or None for an external database. The read-only scanner.signature property reports the database's filename without its directory path.

Batch and directory scans

Use identify_many when you already have a list of paths, or identify_dir when you want pygfried to scan a directory for you. Both functions return the same detailed result shape as identify(..., detailed=True).

>>> from pathlib import Path
>>> paths = [str(path) for path in Path("samples").rglob("*.png")]
>>> pygfried.identify_many(paths, workers=4)
{'siegfried': '1.11.8', ...}
>>> pygfried.identify_dir("samples", recursive=True, workers=4)
{'siegfried': '1.11.8', ...}

Batch and directory scans avoid repeated Python-to-Go calls. The workers argument controls Go-side concurrency and defaults to 1. Higher values allow multiple files to be identified in parallel. To tune performance, start with the number of CPU cores available to your process, then measure with your own files.

By default identify_dir skips symlinks. Use follow_symlinks=True to identify file symlinks and descend symlinked directories; directory cycles are skipped, and repeated links to the same directory are scanned once.

Concurrency

Both the module-level functions and Scanner methods are safe to call from multiple threads. The module-level API shares one immutable default scanner; each custom scanner owns an independent, immutable Siegfried engine.

The extension holds Python's GIL during identification, so Python threads do not run scans in parallel. Use workers for parallel file identification within a batch.

Each identify_many or identify_dir call controls its own Go-side concurrency with workers, whether it is called on the module or on a scanner. There is no process-wide worker limit beyond the per-call range of 1 to 1024.

For process-based parallelism, use the spawn start method explicitly (multiprocessing.get_context("spawn")). Import pygfried and create any custom scanners inside each worker process. Do not pass scanner instances between processes. Other start methods have not been verified.

Limitations

Go libraries can clash

This project uses Go's -buildmode=c-shared to provide its Python extension. Loading multiple Go-based shared libraries in the same process has known issues and may result in panics or crashes due to conflicts between separate Go runtimes.

This limitation should only affect you if you're using pygfried together with another Python library that also uses a Go extension (built with the same c-shared mechanism) in the same process. If you're just using pygfried on its own, you don't need to worry - everything should work as expected.

Credits

pygfried is powered by the original siegfried project, which is distributed under the Apache License, Version 2.0. All core file format identification logic and signatures are provided by siegfried. We gratefully acknowledge the work of the siegfried project and its contributors.

Metadata

Release files for pygfried 0.18.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 pygfried 0.18.0
File Size Uploaded
pygfried-0.18.0.tar.gz 886.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pygfried 0.18.0
File
pygfried-0.18.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
pygfried-0.18.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
pygfried-0.18.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64, Linux glibc 2.5+ x86-64 Details
pygfried-0.18.0-cp310-abi3-macosx_11_0_universal2.whl CPython 3.10 abi3 macOS 11.0+ universal2 (ARM64, x86-64) Details

Total release size: 11.2 MB

Release files / pygfried-0.18.0.tar.gz

Download URL pygfried-0.18.0.tar.gz
Size 886.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ded0ca4626a7ca0b03a3a5dbaa81f57232faf12940816010825e829743ee6cf
BLAKE2b-256 checksum
How to use checksums
369cf07ec60def701895df89a988aefa43bca1817f0e61f3db6619cb34d6913c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release files / pygfried-0.18.0-cp310-abi3-win_amd64.whl

Download URL pygfried-0.18.0-cp310-abi3-win_amd64.whl
Size 2.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
975898ca243e5e362bb2b8ef80eba1050c6540e1c3641786e66c30fcf06be95d
BLAKE2b-256 checksum
How to use checksums
2bc25fe1d5fd46b4169b7fc48eac8ccc2cf7de4123fb7f47cbe951bd0f73fde4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release files / pygfried-0.18.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pygfried-0.18.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.5 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
e9fbd688db83b7c7f227e23489162ba58d16e8e9df942151728a8f9bf94b2b6d
BLAKE2b-256 checksum
How to use checksums
660e9f1387bd947a58605eb9431bda694cb2cc320a62b62422b0f5495cddb6e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release files / pygfried-0.18.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl

Download URL pygfried-0.18.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
2c2e3910bbe4164ac50c697de15bd2ebc3f72196f14581fba6218ee91c37c748
BLAKE2b-256 checksum
How to use checksums
f1f2104c49123dbbfe3402c35a0756c5a2fb911f81dbb4efc65f8faaec2b05bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release files / pygfried-0.18.0-cp310-abi3-macosx_11_0_universal2.whl

Download URL pygfried-0.18.0-cp310-abi3-macosx_11_0_universal2.whl
Size 2.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
8f0fdc8d4e82c122d231a69e6f45f0dfd60ef874fed1f3aeaa6e8fc98723c18c
BLAKE2b-256 checksum
How to use checksums
61a5cd6a24de4793f94100ffe1866f6e2e9fa9807386a1960ad5288eb73632cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 23, 2026.

Transparency log

Release history Release notifications | RSS feed

0.20.0

5 release files

0.19.0

5 release files

0.18.1

5 release files

This release

0.18.0 This release

5 release files

0.17.0

5 release files

0.16.1

5 release files

0.16.0

5 release files

0.15.1

5 release files

0.15.0

5 release files

0.14.1

5 release files

0.12.0

8 release files

0.11.0

8 release files

0.10.0

4 release files

0.9.1

3 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

3 release files

0.6.0

3 release files

0.5.0

4 release files

0.4.0

4 release files

0.3.0

4 release files

0.2.0

2 release files

0.1.0

2 release files

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