Skip to main content

pyswiftdemangler

A Swift programming language symbol demangler/normalizer library for Python on Windows (unofficial).
It uses Python's ctypes to call the official Swift DLL for demangling Swift mangled symbols.

Author: https://github.com/its-me-abi
Date: 18/10/2024


Features

  • Demangles Swift symbol names using the official Swift DLL (swiftDemangle.dll).
  • Exposes a simple Python class interface.
  • Provides command-line usage for convenience.
  • Offers a test mode to verify correct demangling.
  • Installable as a PyPI package.

Installation

pip install pyswiftdemangler

From source

git clone https://github.com/its-me-abi/pyswiftDemangler.git
cd pyswiftDemangler
pip install -e .

Requirements

  • Python 3.6 or higher
  • Windows OS (due to DLL usage)
  • swiftDemangle.dll (included in the package, or provide a custom path)

Usage

As a Library

from pyswiftdemangler import demangler

d = demangler()  # or demangler(path_to_dll)
demangled = d.get_demangled_name("_TtuRxs8RunciblerFxWx5Mince6Quince_")
print(demangled)  # Outputs: <A where A: Swift.Runcible>(A) -> A.Mince.Quince

From the Command Line

pyswiftdemangler --name <mangled_swift_symbol>

Example:

pyswiftdemangler --name _TtuRxs8RunciblerFxWx5Mince6Quince_

Test Mode

To run the built-in test (checks a hardcoded input/output pair):

pyswiftdemangler --test

API Reference

demangler class

from pyswiftdemangler import demangler

d = demangler(path="")

Parameters:

  • path (str, optional): Path to the swiftDemangle.dll. Defaults to the bundled DLL.

Methods:

  • get_demangled_name(name, max_buffer_size=0)
    • Returns the demangled symbol as a string or None if demangling fails.
    • name (str): The mangled Swift symbol name.
    • max_buffer_size (int): Optional maximum buffer size for output.

Example:

from pyswiftdemangler import demangler

demangler_instance = demangler()
demangled = demangler_instance.get_demangled_name("_TtuRxs8RunciblerFxWx5Mince6Quince_")
print(demangled)  # <A where A: Swift.Runcible>(A) -> A.Mince.Quince

File Structure

pyswiftDemangler/
├── pyswiftdemangler/
│   ├── __init__.py          # Package initialization
│   ├── core.py              # Main demangler implementation
│   ├── cli.py               # Command-line interface
│   └── lib/
│       └── swiftDemangle.dll # Swift DLL (required for demangling)
├── README.md                # This file
├── LICENSE                  # MIT License
├── CHANGELOG.md             # Version history
├── pyproject.toml           # Modern Python packaging config
├── setup.py                 # Legacy setup script
├── setup.cfg                # Setup configuration
└── MANIFEST.in              # Package manifest

Notes

  • Only works on Windows due to DLL usage.
  • Ensure the DLL path is correct; the default expects it in the lib folder within the package.
  • If you get a DLL loading error, verify that swiftDemangle.dll exists in the package lib directory.

Example

import pyswiftdemangler

demangler = pyswiftdemangler.demangler()
print(demangler.get_demangled_name("_TtuRxs8RunciblerFxWx5Mince6Quince_"))
# Output: <A where A: Swift.Runcible>(A) -> A.Mince.Quince

Development

Running Tests

pyswiftdemangler --test

Building the Package

pip install build
python -m build

This creates dist/ directory with wheel (.whl) and source (.tar.gz) distributions.

Publishing to PyPI

pip install twine
twine upload dist/*

License

This project is licensed under the MIT License - see the LICENSE file for details.


Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for pyswiftdemangler 0.1.1

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

Source distribution (sdist)

Source distribution for pyswiftdemangler 0.1.1
File Size Uploaded Provenance Actions
pyswiftdemangler-0.1.1.tar.gz 110.5 kB Without provenance Details for pyswiftdemangler-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 219.0 kB

Release files / pyswiftdemangler-0.1.1.tar.gz

Download URL pyswiftdemangler-0.1.1.tar.gz
Size 110.5 kB
Tags Source
SHA-256 checksum
How to use checksums
92bb598d7a6513e5bd5ae6198ddd1b3fe083e95b4f6afdedb2e4fd14911dad6e
BLAKE2b-256 checksum
How to use checksums
ae69e64e8a6822e05c0ad0f1777fdf8bac32e864740ee74b7e3b4fbadd48d862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / pyswiftdemangler-0.1.1-py3-none-any.whl

Download URL pyswiftdemangler-0.1.1-py3-none-any.whl
Size 108.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
308be45d018c28e64f85d6df6819ce19c3004d3af22de1a77c72ac5b9a45c444
BLAKE2b-256 checksum
How to use checksums
2f596fc2430065244a0417e774fd459ff6ef8656d73c3018f4da703d7db8f257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for pyswiftdemangler 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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