Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog.d/windows-copy-pool.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions changelog.d/windows-editable-version.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 5 additions & 2 deletions packages/tack-core/src/tack/_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion packages/tack-core/src/tack/lang/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading