{"id":9409,"library":"winrt-windows-foundation-collections","title":"WinRT Windows Foundation Collections","description":"This package provides Python projections for the Windows Runtime (WinRT) APIs specifically within the `Windows.Foundation.Collections` namespace. It enables Python developers to interact with WinRT collection types like maps, vectors, and property sets. The current version is 3.2.1, with releases occurring frequently, often tied to Windows SDK updates and bug fixes.","status":"active","version":"3.2.1","language":"python","source_language":"en","source_url":"https://github.com/pywinrt/pywinrt","tags":["windows","winrt","collections","interop","gui"],"install":[{"cmd":"pip install winrt-windows-foundation-collections","lang":"bash","label":"Install core collections package"}],"dependencies":[{"reason":"Provides the core WinRT projection engine and base types.","package":"winrt-runtime","optional":false},{"reason":"Provides types from the Windows.Foundation namespace, which collections often rely on.","package":"winrt-windows-foundation","optional":false}],"imports":[{"note":"The full namespace path `winrt.windows.foundation.collections` must be used, not `winrt.foundation.collections`.","wrong":"from winrt.foundation.collections import IVector","symbol":"IVector","correct":"from winrt.windows.foundation.collections import IVector"},{"note":"WinRT types are organized by their full WinRT namespace within the `winrt` Python package hierarchy.","wrong":"from winrt.runtime.collections import IMap","symbol":"IMap","correct":"from winrt.windows.foundation.collections import IMap"},{"symbol":"PropertySet","correct":"from winrt.windows.foundation.collections import PropertySet"}],"quickstart":{"code":"from winrt.windows.foundation.collections import PropertySet\nfrom winrt.windows.foundation import Uri\n\n# PropertySet is a concrete WinRT collection type (IMap<str, object>)\nproperties = PropertySet()\nproperties.Insert(\"myString\", \"Hello WinRT\")\nproperties.Insert(\"myNumber\", 123)\nproperties.Insert(\"myUri\", Uri(\"http://example.com/test\"))\n\nprint(f\"PropertySet size: {properties.Size}\")\nprint(f\"Value for 'myString': {properties.Lookup('myString')}\")\nprint(f\"Value for 'myUri': {properties.Lookup('myUri')}\")\n\n# PropertySet also supports Python dictionary-like access and iteration\nproperties[\"anotherKey\"] = \"anotherValue\"\n\nprint(\"\\nIterating through PropertySet:\")\nfor key, value in properties:\n    print(f\"  {key}: {value}\")\n\n# Check if a key exists\nif properties.HasKey(\"myNumber\"):\n    print(f\"'myNumber' exists with value: {properties['myNumber']}\")","lang":"python","description":"This quickstart demonstrates creating and interacting with a `PropertySet`, a common mutable WinRT map-like collection. It shows how to insert items, retrieve them, and iterate over the collection using both WinRT-specific methods and Python's dictionary-like interface."},"warnings":[{"fix":"Consult the official migration guide for `pywinrt` version 2 to 3 (often found in the project's GitHub repository under `scripts/2to3/README.md`) to adapt your code.","message":"Version 3.0.0 introduced significant breaking changes, including a new `winrt.runtime` module, changes to object identity (`==`, `hash()`), and interface casting (`as_()`).","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Do not target version `2.0.0`. Use `2.0.1` or later, as `2.0.1` contains fixes and was successfully published.","message":"The `winrt-windows-foundation-collections==2.0.0` package was never published to PyPI due to compilation issues, despite being tagged in GitHub. Attempts to install this specific version will fail.","severity":"breaking","affected_versions":"2.0.0"},{"fix":"Upgrade to `winrt-windows-foundation-collections` version 3.1.0 or newer to ensure correct iteration behavior for WinRT collections.","message":"Prior to version 3.1.0, `IIterator.__iter__()` returned an invalid object or did not take a reference, leading to crashes or broken Pythonic iteration (e.g., `for item in my_collection:`).","severity":"breaking","affected_versions":"<3.1.0"},{"fix":"Review `asyncio` task cancellation logic when awaiting WinRT async operations. If previous cancellation behavior was implicitly relied upon, you might need to adjust task handling or error recovery.","message":"As of version 3.2.0, `asyncio` cancellation is propagated to WinRT async actions/operations. If your code relies on WinRT operations continuing after an `asyncio` task is cancelled, this behavior change might affect you.","severity":"gotcha","affected_versions":">=3.2.0"}],"env_vars":null,"search_vec":"'3.2.1':41 'api':15 'bug':53 'collect':4,29,57 'current':38 'develop':24 'enabl':22 'fix':54 'foundat':3 'frequent':45 'gui':59 'interact':26 'interop':58 'like':31 'map':32 'namespac':20 'occur':44 'often':46 'packag':6 'project':9 'properti':35 'provid':7 'python':8,23 'releas':43 'runtim':13 'sdk':50 'set':36 'specif':16 'tie':47 'type':30 'updat':51 'vector':33 'version':39 'window':2,12,49,55 'windows.foundation.collections':19 'winrt':1,14,28,56 'within':17","created_at":"2026-04-16T18:50:04.085563+00:00","updated_at":"2026-04-16T18:50:04.085563+00:00","problems":{"verify_error":"× Failed to build `winrt-windows-foundation-collections==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      creating\n      build/lib.linu"},"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-foundation-collections/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","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}}