Skip to content
Open
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
14 changes: 11 additions & 3 deletions python/ctranslate2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
import glob
import os

import pkg_resources

module_name = sys.modules[__name__].__name__
package_dir = pkg_resources.resource_filename(module_name, "")

# Adressing python 3.9 < version
try:
from importlib.resources import files

# Fixed the pkg_resources depreciation
package_dir = str(files(module_name))
except ImportError:
import pkg_resources

package_dir = pkg_resources.resource_filename(module_name, "")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not support Python < 3.9, see:

https://github.com/OpenNMT/CTranslate2/blob/master/python/setup.py#L101

It is safe just to remove the < 3.9 specific code

add_dll_directory = getattr(os, "add_dll_directory", None)
if add_dll_directory is not None:
Expand Down
Loading