1
1
import importlib .util
2
+ from importlib .metadata import entry_points , EntryPoint
2
3
from os .path import join , dirname
3
- from pkg_resources import iter_entry_points
4
4
import sys
5
5
from typing import Dict , List , Optional , Set
6
6
import warnings
@@ -27,12 +27,17 @@ class PkgCfg:
27
27
Contains information about an installed package that uses robotpy-build
28
28
"""
29
29
30
- def __init__ (self , entry_point ):
30
+ def __init__ (self , entry_point : EntryPoint ):
31
31
try :
32
32
self .module = entry_point .load ()
33
33
except Exception as e :
34
34
try :
35
- self .module = _hacky_entrypoint_loader (entry_point .module_name )
35
+ mod = (
36
+ entry_point .module
37
+ if hasattr (entry_point , "module" )
38
+ else entry_point .value
39
+ )
40
+ self .module = _hacky_entrypoint_loader (mod )
36
41
except Exception :
37
42
raise e
38
43
@@ -147,7 +152,13 @@ def detect_pkgs(self) -> None:
147
152
Only loads packages that are dependencies.
148
153
"""
149
154
deps_names = set ().union (* [pkg .depends for pkg in self .pkgs .values ()])
150
- entry_points = list (iter_entry_points (group = "robotpybuild" , name = None ))
155
+ ep_ret = entry_points ()
156
+
157
+ # Python 3.8/3.9
158
+ if isinstance (ep_ret , dict ):
159
+ all_entry_points = ep_ret .get ("robotpybuild" , [])
160
+ else :
161
+ all_entry_points = [e for e in entry_points () if e .group == "robotpybuild" ]
151
162
152
163
# Only load the dependencies of the package we're building.
153
164
# If we load the [package being built], then the current build will fail.
@@ -156,7 +167,7 @@ def detect_pkgs(self) -> None:
156
167
run_loop = True
157
168
while run_loop :
158
169
run_loop = False
159
- for ep in entry_points :
170
+ for ep in all_entry_points :
160
171
if ep .name in self .pkgs : # Prevents loading the package being built
161
172
continue
162
173
if ep .name not in deps_names and ep .name != "robotpy-build" :
0 commit comments