Skip to content

Commit

Permalink
Switch on importlib.resources
Browse files Browse the repository at this point in the history
What's wrong with`__file__`? The assumption that you have files and subdirectories available is not correct. This approach doesn't work if executing code which is packed in a zip or a wheel, and it may be entirely out of the user's control whether or not your package gets extracted to a filesystem at all.
  • Loading branch information
shadchin authored May 4, 2024
1 parent 0323d3a commit efdc7e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions thinc/backends/_custom_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import re
from collections import defaultdict
from functools import reduce
from pathlib import Path
from importlib.resources import files
from typing import Callable, Optional, Tuple

import numpy

from ..compat import cupy, has_cupy_gpu

PWD = Path(__file__).parent
PWD = files(__package__)
KERNELS_SRC = (PWD / "_custom_kernels.cu").read_text(encoding="utf8")
KERNELS_LIST = [
"backprop_clipped_linear<double>",
Expand Down

0 comments on commit efdc7e2

Please sign in to comment.