11"""
22Bindings to integrate plux into setuptools build processes.
33"""
4+
45import importlib
56import json
67import logging
@@ -30,6 +31,7 @@ def run(self):
3031 def _ensure_dist_info (self , * args , ** kwargs ):
3132 pass
3233
34+
3335from setuptools .command .egg_info import InfoCommon , write_entries
3436
3537from plux .core .entrypoint import EntryPointDict , discover_entry_points
@@ -44,6 +46,7 @@ def _ensure_dist_info(self, *args, **kwargs):
4446# The following classes and methods are a way for plux to hook into
4547# the setuptools build process either indirectly or programmatically.
4648
49+
4750class plugins (InfoCommon , setuptools .Command ):
4851 """
4952 Setuptools command that discovers plugins and writes them into the egg_info directory to a ``plux.json`` file.
@@ -57,11 +60,15 @@ class plugins(InfoCommon, setuptools.Command):
5760 ``patch_egg_info_command`` where we could implement this logic. More background can be found here:
5861 https://github.com/pypa/setuptools/discussions/4223.
5962 """
63+
6064 description = "Discover plux plugins and store them in .egg_info"
6165
6266 user_options : t .ClassVar [t .List [t .Tuple [str , str , str ]]] = [
63- ('exclude=' , 'e' ,
64- "a sequence of paths to exclude; '*' can be used as a wildcard in the names. 'foo.*' will exclude all subpackages of 'foo' (but not 'foo' itself)." ),
67+ (
68+ "exclude=" ,
69+ "e" ,
70+ "a sequence of paths to exclude; '*' can be used as a wildcard in the names. 'foo.*' will exclude all subpackages of 'foo' (but not 'foo' itself)." ,
71+ ),
6572 # TODO: add more
6673 ]
6774
@@ -84,7 +91,7 @@ def finalize_options(self) -> None:
8491 )
8592
8693 def run (self ) -> None :
87- index_builder = create_plugin_index_builder (self .plux_config ,self .distribution , output_format = "json" )
94+ index_builder = create_plugin_index_builder (self .plux_config , self .distribution , output_format = "json" )
8895
8996 self .debug_print (f"writing discovered plugins into { self .plux_json_path } " )
9097 self .mkpath (os .path .dirname (self .plux_json_path ))
@@ -233,14 +240,10 @@ def find_plugins(where=".", exclude=(), include=("*",)) -> EntryPointDict:
233240 )
234241 """
235242
236- return discover_entry_points (
237- PackagePathPluginFinder (where = where , exclude = exclude , include = include )
238- )
243+ return discover_entry_points (PackagePathPluginFinder (where = where , exclude = exclude , include = include ))
239244
240245
241- def load_entry_points (
242- where = "." , exclude = (), include = ("*" ,), merge : EntryPointDict = None
243- ) -> EntryPointDict :
246+ def load_entry_points (where = "." , exclude = (), include = ("*" ,), merge : EntryPointDict = None ) -> EntryPointDict :
244247 """
245248 Finds plugins and builds and entry point map. This is to be used in a setup.py in the setup call:
246249
@@ -289,6 +292,7 @@ def load_entry_points(
289292# =========
290293# The remaining methods are utilities
291294
295+
292296def get_plux_json_path (distribution : setuptools .Distribution ) -> str :
293297 """
294298 Returns the full path of ``plux.json`` file for the given distribution. The file is located within the .egg-info
@@ -327,11 +331,10 @@ def update_entrypoints(distribution: setuptools.Distribution, ep: EntryPointDict
327331 distribution .entry_points .update (ep )
328332
329333
330-
331334def create_plugin_index_builder (
332335 cfg : config .PluxConfiguration ,
333336 distribution : setuptools .Distribution ,
334- output_format : t .Literal ["json" , "ini" ] = "json"
337+ output_format : t .Literal ["json" , "ini" ] = "json" ,
335338) -> PluginIndexBuilder :
336339 """
337340 Creates a PluginIndexBuilder instance for discovering plugins from a setuptools distribution. It uses a
0 commit comments