explosion / thinc

🔮 A refreshing functional take on deep learning, compatible with your favorite libraries
https://thinc.ai
MIT License
2.82k stars 275 forks source link

Switch on `importlib.resources` #936

Closed shadchin closed 3 months ago

shadchin commented 6 months ago

Description

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.

Types of change

Switch on importlib.resources.files (Added in version Python 3.9.)

Checklist

honnibal commented 3 months ago

As a general rule we're not claiming to support zip-safe operation, and there may be other places in the code where we're not zip safe. So I'm not inclined to accept a piecemeal change; if we want zip safety it should all be done at once.

This isn't something I'd ask a contributor to do as I haven't thought through the trade-offs properly, and I may end up having to reject the PR. Nevertheless, thanks for your attention and the submission of what seemed like a small fix!