{"id":9410,"library":"winrt-windows-storage-streams","title":"WinRT Windows.Storage.Streams","description":"WinRT-Windows.Storage.Streams is a Python projection package providing access to the Windows Runtime (WinRT) APIs within the `Windows.Storage.Streams` namespace. This enables Python developers to interact with stream-related functionalities such as asynchronous read, write, and seek operations on various stream types. It is part of the modular PyWinRT project, which frequently releases updates synchronized with Windows SDK versions, with the current version being 3.2.1. [3, 7, 10]","status":"active","version":"3.2.1","language":"python","source_language":"en","source_url":"https://github.com/pywinrt/pywinrt","tags":["windows","winrt","async","interop","streams","io"],"install":[{"cmd":"pip install winrt-windows-storage-streams","lang":"bash","label":"Install only this package"},{"cmd":"pip install winrt-runtime winrt-windows-storage-streams","lang":"bash","label":"Install with core runtime dependency"}],"dependencies":[{"reason":"Provides the core runtime support for all PyWinRT projections.","package":"winrt-runtime","optional":false},{"reason":"Often used for core types like IAsyncOperation and IClosable.","package":"winrt-windows.foundation","optional":true},{"reason":"Provides collection interfaces like IIterable, IVector, and IMap.","package":"winrt-windows.foundation.collections","optional":true},{"reason":"Provides access to file system and storage APIs, often used in conjunction with streams.","package":"winrt-windows.storage","optional":true},{"reason":"Provides access to system-level APIs.","package":"winrt-windows.system","optional":true}],"imports":[{"symbol":"DataWriter","correct":"from winrt.windows.storage.streams import DataWriter"},{"symbol":"DataReader","correct":"from winrt.windows.storage.streams import DataReader"},{"symbol":"InMemoryRandomAccessStream","correct":"from winrt.windows.storage.streams import InMemoryRandomAccessStream"},{"note":"WinRT `Buffer` is in `windows.storage.streams`, not `system`.","wrong":"from winrt.system import Buffer","symbol":"Buffer","correct":"from winrt.windows.storage.streams import Buffer"}],"quickstart":{"code":"import asyncio\nfrom winrt.windows.storage.streams import DataWriter, DataReader, InMemoryRandomAccessStream, Buffer\n\nasync def write_and_read_stream():\n    stream = InMemoryRandomAccessStream()\n    writer = DataWriter(stream)\n\n    # Write some bytes\n    data_to_write = b\"Hello, WinRT Streams!\"\n    writer.write_bytes(data_to_write)\n    await writer.store_async()\n    await writer.flush_async()\n\n    # Seek to the beginning of the stream and read\n    stream.seek(0)\n    reader = DataReader(stream)\n    await reader.load_async(stream.size)\n    read_buffer = reader.read_buffer(stream.size)\n    \n    # Convert IBuffer to Python bytes using buffer protocol\n    read_bytes = bytes(read_buffer) \n    \n    print(f\"Original: {data_to_write.decode('utf-8')}\")\n    print(f\"Read:     {read_bytes.decode('utf-8')}\")\n\n    writer.close()\n    reader.close()\n    stream.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(write_and_read_stream())","lang":"python","description":"This example demonstrates writing bytes to an `InMemoryRandomAccessStream` using a `DataWriter`, then seeking to the beginning, reading the data back with a `DataReader`, and converting the `IBuffer` result into Python bytes. It showcases fundamental stream operations and the use of async methods."},"warnings":[{"fix":"Refer to the PyWinRT migration guide for specific details on adapting code to the new API surface. Update imports and API calls as necessary. [GitHub Release Notes (v3.0.0)]","message":"Version 3.0.0 introduced significant breaking changes, including a new `winrt.runtime` module, `winrt.system.Object.as_()` method, and `box_...`/`unbox_...` functions in `winrt.system`. Direct migration from older monolithic `winrt` or `winsdk` packages may require substantial code changes.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate to the modular `winrt-*` package structure. Install `winrt-runtime` and specific namespace packages like `winrt-windows-storage-streams`. Update imports from `winsdk.windows...` or `winrt.windows...` to `from winrt.windows...` after installing the new packages.","message":"The previous monolithic `winrt` (Microsoft) and `winsdk` (community) packages are deprecated. The PyWinRT project now uses a modular approach, where each Windows SDK namespace (e.g., `Windows.Storage.Streams`) is a separate `winrt-*` PyPI package. Using older monolithic packages can lead to compatibility issues, especially with newer Python versions (>=3.10).","severity":"deprecated","affected_versions":"<3.0.0 and any usage of `winsdk` or old `winrt`"},{"fix":"Avoid `v2.0.0`. If you need features from this release cycle, install `winrt-windows-storage-streams==2.0.1` or later. [GitHub Release Notes (v2.0.0)]","message":"The `v2.0.0` release was not published to PyPI due to compilation issues. If targeting versions around `2.0.0`, ensure you use `v2.0.1` or newer.","severity":"gotcha","affected_versions":"2.0.0"},{"fix":"Review code that interacts with `asyncio` tasks and WinRT async operations to ensure proper handling of cancellation signals. Ensure your application logic correctly responds to `asyncio.CancelledError`.","message":"`asyncio` cancellation is now propagated to WinRT asynchronous actions and operations being awaited. This changes how cancellation behaves for long-running WinRT tasks.","severity":"breaking","affected_versions":">=3.2.0"},{"fix":"Upgrade to `winrt-windows-storage-streams==3.1.0` or a newer version to benefit from stability fixes for collection iteration.","message":"Prior to `v3.1.0`, there were issues with `IIterator.__iter__()` returning invalid objects and potentially causing crashes. This primarily affected iteration over WinRT collections.","severity":"gotcha","affected_versions":"<3.1.0"}],"env_vars":null,"search_vec":"'10':69 '3':67 '3.2.1':66 '7':68 'access':10 'api':16 'async':72 'asynchron':34 'current':63 'develop':24 'enabl':22 'frequent':53 'function':31 'interact':26 'interop':73 'io':75 'modular':49 'namespac':20 'oper':39 'packag':8 'part':46 'project':7,51 'provid':9 'python':6,23 'pywinrt':50 'read':35 'relat':30 'releas':54 'runtim':14 'sdk':59 'seek':38 'stream':29,42,74 'stream-rel':28 'synchron':56 'type':43 'updat':55 'various':41 'version':60,64 'window':13,58,70 'windows.storage.streams':2,19 'winrt':1,15,71 'winrt-windows.storage.streams':3 'within':17 'write':36","created_at":"2026-04-16T18:50:04.451981+00:00","updated_at":"2026-04-16T18:50:04.451981+00:00","problems":{"verify_error":"× Failed to build `winrt-runtime==3.2.1`\n  ├─▶ The build backend returned an error\n  ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)\n\n      [stdout]\n      running bdist_wheel\n      running build\n      running build_py\n      copying src/winrt/system/__init__.py ->\n      build/"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.2.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pywinrt/pywinrt","docs":"https://pywinrt.readthedocs.io","changelog":"https://github.com/pywinrt/pywinrt/blob/main/CHANGELOG.md","pypi":"https://pypi.org/project/winrt-windows-storage-streams/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"install_fail","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}