Skip to content

Commit 8ef0081

Browse files
authored
Merge pull request #4 from pmrv/claude/setuptools-dep-update-2bary2
Drop runtime pkg_resources dependency for setuptools >= 82 compatibility
2 parents db3abfe + 75927d1 commit 8ef0081

3 files changed

Lines changed: 19 additions & 6 deletions

File tree

bin/pacemaker

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@ import getpass # for getpass.getuser()
55
import glob
66
import logging
77
import os
8-
import pkg_resources
98
import re
109

10+
try:
11+
from importlib.resources import files as _importlib_files
12+
13+
def _resource_filename(package, resource):
14+
return str(_importlib_files(package) / resource)
15+
except ImportError: # Python 3.8: importlib.resources.files is not available
16+
from pkg_resources import resource_filename as _resource_filename
17+
1118
try:
1219
import readline
1320

@@ -343,7 +350,7 @@ def generate_template_input():
343350
weighting = None
344351
print("Use UniformWeightingPolicy")
345352

346-
template_input_yaml_filename = pkg_resources.resource_filename('pyace.data', 'input_template.yaml')
353+
template_input_yaml_filename = _resource_filename('pyace.data', 'input_template.yaml')
347354
copyfile(template_input_yaml_filename, "input.yaml")
348355
with open("input.yaml", "r") as f:
349356
input_yaml_text = f.read()

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55
from pathlib import Path
66
import platform
7-
from distutils.version import LooseVersion
87
from setuptools import Extension, setup, find_packages
98
from setuptools.command.build_ext import build_ext
109
from setuptools.command.install import install

src/pyace/multispecies_basisextension.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import logging
22
import numpy as np
33
import pickle
4-
import pkg_resources
54
import re
65

6+
try:
7+
from importlib.resources import files as _importlib_files
8+
9+
def _resource_filename(package, resource):
10+
return str(_importlib_files(package) / resource)
11+
except ImportError: # Python 3.8: importlib.resources.files is not available
12+
from pkg_resources import resource_filename as _resource_filename
13+
714
from collections import defaultdict
815
from copy import deepcopy
916
from itertools import combinations, permutations, combinations_with_replacement, product
@@ -44,8 +51,8 @@
4451
'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc',
4552
'Lv', 'Ts', 'Og']
4653

47-
default_mus_ns_uni_to_rawlsLS_np_rank_filename = pkg_resources.resource_filename('pyace.data',
48-
'mus_ns_uni_to_rawlsLS_np_rank.pckl')
54+
default_mus_ns_uni_to_rawlsLS_np_rank_filename = _resource_filename('pyace.data',
55+
'mus_ns_uni_to_rawlsLS_np_rank.pckl')
4956

5057
def clean_bbasisconfig(initial_bbasisconfig):
5158
for block in initial_bbasisconfig.funcspecs_blocks:

0 commit comments

Comments
 (0)