From 0ed8079c7633e73d8f33099c23295d2a39affc89 Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Sat, 5 Dec 2026 20:27:47 +0000 Subject: [PATCH 1/2] Copy pool: register the fork handler only where os has one test_host_copies' large copy failed on Windows with AttributeError: the copy pool, made on the first host copy of _PARALLEL_COPY_BYTES or more, called os.register_at_fork, which Windows lacks. Any such copy on a host with two or more copy threads raised there. Windows never forks, so the handler is only registered where it exists. --- changelog.d/windows-copy-pool.md | 5 +++++ packages/tack-core/src/tack/lang/array.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelog.d/windows-copy-pool.md diff --git a/changelog.d/windows-copy-pool.md b/changelog.d/windows-copy-pool.md new file mode 100644 index 00000000..4a67cb4c --- /dev/null +++ b/changelog.d/windows-copy-pool.md @@ -0,0 +1,5 @@ +### Fixed + +- On Windows a host copy of 32 MiB or more (on two or more threads) raised + `AttributeError`: the copy pool registered a fork handler, which Windows + does not have. diff --git a/packages/tack-core/src/tack/lang/array.py b/packages/tack-core/src/tack/lang/array.py index eee36ee3..0b9bdbe0 100644 --- a/packages/tack-core/src/tack/lang/array.py +++ b/packages/tack-core/src/tack/lang/array.py @@ -278,7 +278,8 @@ def _host_copy(dst: np.ndarray, src: np.ndarray): from concurrent.futures import ThreadPoolExecutor _copy_pool = ThreadPoolExecutor(max_workers=_COPY_THREADS, thread_name_prefix="tack-copy") - os.register_at_fork(after_in_child=_reset_copy_pool) + if hasattr(os, "register_at_fork"): # POSIX alone: Windows never forks + os.register_at_fork(after_in_child=_reset_copy_pool) d, s = dst.reshape(-1), src.reshape(-1) k = int(min(threads, max(1, nbytes // _COPY_CHUNK_BYTES))) step = -(-d.size // k) From 8c35da525a3b34eb105dcf7bfd3f59e70044d8a3 Mon Sep 17 00:00:00 2001 From: Berk Geveci Date: Sat, 5 Dec 2026 20:27:47 +0000 Subject: [PATCH 2/2] Deprecations: read an editable install's path with url2pathname test_an_editable_install_is_read_at_its_source_trees_version failed on Windows: the path of direct_url.json's file:///C:/... URL is /C:/..., which opens nothing there, so the version fell back to the metadata's (the one installed at), and the removed_in guard read the wrong version in a checkout. url2pathname gives C:\... on Windows and the unquoted path elsewhere, as before. --- changelog.d/windows-editable-version.md | 4 ++++ packages/tack-core/src/tack/_deprecation.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelog.d/windows-editable-version.md diff --git a/changelog.d/windows-editable-version.md b/changelog.d/windows-editable-version.md new file mode 100644 index 00000000..fa17d2be --- /dev/null +++ b/changelog.d/windows-editable-version.md @@ -0,0 +1,4 @@ +### Fixed + +- On Windows an editable install's version was read from its metadata, not its + `pyproject.toml`: the `file:///C:/...` URL's path does not open there. diff --git a/packages/tack-core/src/tack/_deprecation.py b/packages/tack-core/src/tack/_deprecation.py index 77c5be08..a802ba13 100644 --- a/packages/tack-core/src/tack/_deprecation.py +++ b/packages/tack-core/src/tack/_deprecation.py @@ -124,12 +124,15 @@ def _package_version(package): import json import tomllib from importlib.metadata import distribution - from urllib.parse import unquote, urlparse + from urllib.parse import urlparse + from urllib.request import url2pathname found = distribution(package) origin = json.loads(found.read_text("direct_url.json") or "{}") if origin.get("dir_info", {}).get("editable") and origin.get("url", "").startswith("file:"): - project = os.path.join(unquote(urlparse(origin["url"]).path), "pyproject.toml") + # url2pathname, not the URL's path alone: on Windows that is /C:/..., which + # opens nothing (it unquotes as unquote did). + project = os.path.join(url2pathname(urlparse(origin["url"]).path), "pyproject.toml") try: with open(project, "rb") as f: stated = tomllib.load(f).get("project", {}).get("version")