Skip to content

Commit 30957e9

Browse files
authored
Use importlib.resources to get paths (#37)
1 parent 9e988c6 commit 30957e9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/gtnet/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import glob
22
import hashlib
3+
from importlib.resources import files
34
import json
45
import logging
56
import os
@@ -9,7 +10,6 @@
910
import zipfile
1011

1112
import numpy as np
12-
from pkg_resources import resource_filename
1313
import torch
1414
import torch.nn as nn
1515

@@ -40,15 +40,15 @@ class DeployPkg:
4040

4141
@classmethod
4242
def check_pkg(cls):
43-
deploy_dir = resource_filename(__name__, 'deploy_pkg')
43+
deploy_dir = files(__package__).joinpath('deploy_pkg')
4444
total = 0
4545
for path in glob.glob(f"{deploy_dir}/*"):
4646
total += os.path.getsize(path)
4747
if total == 0:
4848
msg = ("Downloading GTNet deployment package. This will only happen on the first invocation "
4949
"of gtnet predict or gtnet classify")
5050
warnings.warn(msg)
51-
zip_path = resource_filename(__name__, 'deploy_pkg.zip')
51+
zip_path = files(__package__).joinpath('deploy_pkg.zip')
5252
urllib.request.urlretrieve(cls._deploy_pkg_url, zip_path)
5353
dl_checksum = hashlib.md5(open(zip_path,'rb').read()).hexdigest()
5454
if dl_checksum != cls._checksum:

0 commit comments

Comments
 (0)