File tree 2 files changed +31
-7
lines changed
2 files changed +31
-7
lines changed Original file line number Diff line number Diff line change @@ -117,13 +117,35 @@ class PkgCfgProvider:
117
117
118
118
def __init__ (self ):
119
119
self .pkgs = {}
120
- for entry_point in iter_entry_points (group = "robotpybuild" , name = None ):
121
- try :
122
- pkg = PkgCfg (entry_point )
123
- except Exception as e :
124
- warnings .warn (f"Error loading entry point { entry_point .name } : { e } " )
125
- else :
126
- self .add_pkg (pkg )
120
+
121
+ def detect_pkgs (self ) -> None :
122
+ """
123
+ Detect and load packages under the robotpybuild entry point group.
124
+ Only loads packages that are dependencies.
125
+ """
126
+ deps_names = set ().union (* [pkg .depends for pkg in self .pkgs .values ()])
127
+ entry_points = list (iter_entry_points (group = "robotpybuild" , name = None ))
128
+
129
+ # Only load the dependencies of the package we're building.
130
+ # If we load the [package being built], then the current build will fail.
131
+ # If we load a package that depends on the [package being built],
132
+ # then the [package being built] will be loaded and the current build will fail.
133
+ run_loop = True
134
+ while run_loop :
135
+ run_loop = False
136
+ for ep in entry_points :
137
+ if ep .name in self .pkgs : # Prevents loading the package being built
138
+ continue
139
+ if ep .name not in deps_names and ep .name != "robotpy-build" :
140
+ continue
141
+ try :
142
+ pkg = PkgCfg (ep )
143
+ except Exception as e :
144
+ warnings .warn (f"Error loading entry point { ep .name } : { e } " )
145
+ else :
146
+ self .add_pkg (pkg )
147
+ deps_names |= set (pkg .depends )
148
+ run_loop = True
127
149
128
150
def add_pkg (self , pkg : PkgCfg ) -> None :
129
151
self .pkgs [pkg .name ] = pkg
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ def prepare(self):
105
105
self ._collect_static_libs ()
106
106
self ._collect_wrappers ()
107
107
108
+ self .pkgcfg .detect_pkgs ()
109
+
108
110
self .setup_kwargs ["cmdclass" ] = {
109
111
"build_py" : BuildPy ,
110
112
"build_dl" : BuildDl ,
You can’t perform that action at this time.
0 commit comments