Skip to main content

Siegfried as a Python extension

Project description

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.2'
>>> pygfried.identify("example.png")
'fmt/11'
>>> pygfried.identify("example.png", detailed=True)
{'siegfried': '1.11.2', 'scandate': '2025-06-10T07:16:31+02:00', 'signature': 'default.sig', 'created': '2025-03-01T15:28:08+11:00', 'identifiers': [{'name': 'pronom', 'details': 'DROID_SignatureFile_V120.xml; container-signature-20240715.xml'}], 'files': [{'filename': 'example.png', 'filesize': 237675, 'modified': '2025-06-10T07:11:26+02:00', 'errors': '', 'matches': [{'ns': 'pronom', 'id': 'fmt/11', 'format': 'Portable Network Graphics', 'version': '1.0', 'mime': 'image/png', 'class': 'Image (Raster)', 'basis': 'extension match png; byte match at [[0 16] [237663 12]]', 'warning': ''}]}]}
>>> pygfried.identify_many(["example.png", "README.md"], workers=2)
{'siegfried': '1.11.2', ...}
>>> pygfried.identify_dir("samples", recursive=True, workers=2)
{'siegfried': '1.11.2', ...}

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.2', ...}
>>> pygfried.identify_dir("samples", recursive=True, workers=4)
{'siegfried': '1.11.2', ...}

The workers argument controls Go-side concurrency. The default is 1, which is the most conservative setting. For directories or large path lists, higher values can be much faster because pygfried avoids repeated Python-to-Go calls and identifies multiple files in parallel. A good starting point is 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.

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 is unsupported 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygfried-0.15.0.tar.gz (664.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pygfried-0.15.0-cp310-abi3-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

pygfried-0.15.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

pygfried-0.15.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl (2.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

pygfried-0.15.0-cp310-abi3-macosx_11_0_universal2.whl (2.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file pygfried-0.15.0.tar.gz.

File metadata

  • Download URL: pygfried-0.15.0.tar.gz
  • Upload date:
  • Size: 664.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pygfried-0.15.0.tar.gz
Algorithm Hash digest
SHA256 9fd1ac31ddbba2eaf507ec77031694ee05214f2ec8ba371c57677f67ebddc2c9
MD5 66473b3b49260f7b63fa7033b4d2b189
BLAKE2b-256 87f04425342059e414c638aa7bf5c5e93d9272a6ca129423fb355e5b62e8e387

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygfried-0.15.0.tar.gz:

Publisher: release.yml on artefactual-labs/pygfried

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygfried-0.15.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pygfried-0.15.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pygfried-0.15.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d0b6da6cc8d91abeda6ddfbe67b3ec5557355fb489a8edc9e48e29082a9f6fe0
MD5 6c43c07a676a3e75973904ad41aae2ca
BLAKE2b-256 86f51c800c707a27a5779703fb88824f0f953a23b4b9c56b06c63febf47bea86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygfried-0.15.0-cp310-abi3-win_amd64.whl:

Publisher: release.yml on artefactual-labs/pygfried

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygfried-0.15.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.

File metadata

File hashes

Hashes for pygfried-0.15.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Algorithm Hash digest
SHA256 e18d4339e28e24aa96f4d4ac897fcefa5f1353495b6f3029656573d6b7866c61
MD5 6954007c54d01e95248e319e623773ff
BLAKE2b-256 c2629a303941c09a18688ff8217090eaf61daf33888ca4c0bd7676e49f1b47e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygfried-0.15.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:

Publisher: release.yml on artefactual-labs/pygfried

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygfried-0.15.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for pygfried-0.15.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 60eca2896b8286a8944530361b658dbceb350014e4db5a1d4eec3782bbf6a84e
MD5 8fa21818981c830470a5d28d9ac0cef6
BLAKE2b-256 cc8ba0409318dc34d8ebbbc548e8c5cb005e00ce72467b80db40397d997474be

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygfried-0.15.0-cp310-abi3-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl:

Publisher: release.yml on artefactual-labs/pygfried

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pygfried-0.15.0-cp310-abi3-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for pygfried-0.15.0-cp310-abi3-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 b27262c4f737b41e5623059e8033c8a20d55bda271eec1f8b5acd8999b75c0d9
MD5 39374cbd15a4d681a14efd147301c0f2
BLAKE2b-256 6fcf33c863ea1a104b706decc5c2ae7b360e317d935047726ba2f455b54b22cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pygfried-0.15.0-cp310-abi3-macosx_11_0_universal2.whl:

Publisher: release.yml on artefactual-labs/pygfried

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page