unasync
The async transformation code.
Decision gist · record as of 2026-08-14
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.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires setuptools to be available; intended for use during package build, not runtime.
- Low friction install with only two runtime dependencies (tokenize-rt and setuptools).
- Actively maintained as of 2026-07-31 with 108 repository stars.
License · maintenance · safety
MIT OR Apache-2.0 (permissive) — Licensed under MIT OR Apache-2.0 (your choice), both permissive licenses with no restrictions on commercial use or redistribution.
last release 2024-05-03 (833 days) · last repo commit 2026-07-31 · 108 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 253,396 downloads/mo, #8,520 on PyPI
Alternatives
Verify before relying
pip install unasync
# In setup.py:
import unasync
import setuptools
setuptools.setup(
...,
cmdclass={'build_py': unasync.cmdclass_build_py()},
...
)- 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.
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 on this page. Verify before relying on it.
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
unasync on PyPI
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.
Requires setuptools to be available; intended for use during package build, not runtime.
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()},
...
)
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 the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagestokenize-rtsetuptools |
| Maintenance | Actively maintained 833 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 253,396 / month, #8,520 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Framework :: TrioLicense :: OSI Approved :: Apache Software LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: MacOS :: MacOS XOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy |
Evidence: unasync-0.6.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “async to sync code generation”
- unasyncTransforms asynchronous Python code into synchronous code during…
- greenbackAllows you to call async functions from synchronous code that runs…
- asyncerAsyncer provides utility functions for working with async/await code…
Give your agent the search over MCP, or paste the wish link into any chat.
More Build Tools packages
Provides reusable utilities for Python packaging interoperability, including version handling, specifiers, markers, requirements, tags, and metadata parsing according to standards like PEP 440 and PEP 425.
Wraps any iterable to display a real-time progress bar in the terminal or Jupyter notebook, showing iteration count, elapsed time, and estimated time remaining.
pip is the standard installer for Python packages, enabling you to download and install packages from the Python Package Index and other indexes into your Python environment.
Hatchling is a standards-compliant Python build backend that handles packaging, metadata, and distribution of Python projects when configured in a project's pyproject.toml file.
Generates Python gRPC service stubs and message classes from Protocol Buffer definitions, enabling developers to build gRPC clients and servers.
pre-commit is a framework for installing and running git hooks written in any language before commits are made, automating code quality and validation checks across multi-language projects.
Install it if your team needs consistent, automated validation at commit time.
See also synchronicity · async_generator · asgiref · async-stripe · pytest-trio · httpx · janus · trio · greenback · python-ffmpeg