--- id: unasync version: "0.6.0" license: MIT OR Apache-2.0 license_treatment: permissive maintenance: active --- # unasync — The async transformation code. License: permissive · Maintenance: active · Downloads: 253.4K/mo ## What it is and what it does Unasync is a build-time code transformation tool that converts asynchronous Python code into synchronous equivalents. It works by scanning a designated async source directory (typically named _async), applying token-level transformations to remove async/await keywords and replace async-specific patterns with their synchronous counterparts, then writing the result to a sync directory (typically _sync). This allows library maintainers to maintain a single async codebase while automatically generating a synchronous API variant during the build process. The tool integrates directly into setuptools as a custom build command, making it transparent to the build pipeline. It supports customizable transformation rules via unasync.Rule instances, allowing you to specify different source and target directories and add custom token replacements beyond the defaults. This approach is used by production libraries like the official Elasticsearch Python client and other HTTP clients that need to support both async and sync calling conventions. Use it for: - Generate synchronous client libraries from async code to support users who cannot use async/await. - Maintain dual async/sync APIs in a single package without duplicating source code manually. - Provide backward-compatible synchronous interfaces alongside modern async implementations. - Reduce maintenance burden when supporting both async and sync calling patterns in HTTP clients or network libraries. - Automate code generation during package builds to keep sync and async versions in sync. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Transforms asynchronous Python code into synchronous code during package build, enabling maintainers to generate both async and sync APIs from a single async source. Yes, if you are building a library that needs to offer both async and sync APIs. It solves a real maintenance problem by automating code duplication at build time. Install it as a build dependency in your setup.py, not as a runtime dependency. No known vulnerabilities and permissive licensing make it low-risk. ## Install pip install unasync uv add unasync poetry add unasync ## Installing unasync Before you install: Low friction install with only two runtime dependencies (tokenize-rt and setuptools). Actively maintained as of 2026-07-31 with 108 repository stars. License in practice: Licensed under MIT OR Apache-2.0 (your choice), both permissive licenses with no restrictions on commercial use or redistribution. Quickstart: pip install unasync # In setup.py: import unasync import setuptools setuptools.setup( ..., cmdclass={'build_py': unasync.cmdclass_build_py()}, ... ) Requires setuptools to be available; intended for use during package build, not runtime. Verify before relying: - Whether the transformation handles all async patterns or has known limitations with specific syntax. - Performance characteristics of the generated synchronous code compared to hand-written sync implementations. - How well the tool handles complex async patterns like context managers, generators, or exception handling. ## Package facts - License: MIT OR Apache-2.0 (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 253.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags async to sync code generation, transform async code synchronous, dual async sync library, async code transformation tool, generate sync from async, build-time code transformation, async sync code duplication, code-generation, async-sync-bridge [View on SkillFed](https://skillfed.io/packages/unasync) · [View on PyPI](https://pypi.org/project/unasync/)