@@ -64,11 +64,7 @@ def unasync_name(name):
6464 if name in ASYNC_TO_SYNC :
6565 return ASYNC_TO_SYNC [name ]
6666 # Convert classes prefixed with 'Async' into 'Sync'
67- elif (
68- len (name ) > 5
69- and name .startswith ("Async" )
70- and name [5 ].isupper ()
71- ):
67+ elif len (name ) > 5 and name .startswith ("Async" ) and name [5 ].isupper ():
7268 return "Sync" + name [5 :]
7369 return name
7470
@@ -131,7 +127,11 @@ class build_py(orig.build_py):
131127 and saves them in _sync dir.
132128 """
133129
130+ RENAME_DIR_FROM_TO = ("_async" , "_sync" ) # Controls what directory will be renamed.
131+
134132 def run (self ):
133+ dir_from , dir_to = self .RENAME_DIR_FROM_TO
134+
135135 self ._updated_files = []
136136
137137 # Base class code
@@ -143,8 +143,8 @@ def run(self):
143143
144144 # Our modification!
145145 for f in self ._updated_files :
146- if os .sep + "_async" + os .sep in f :
147- unasync_file (f , "_async" , "_sync" )
146+ if os .sep + dir_from + os .sep in f :
147+ unasync_file (f , dir_from , dir_to )
148148
149149 # Remaining base class code
150150 self .byte_compile (self .get_outputs (include_bytecode = 0 ))
@@ -154,3 +154,10 @@ def build_module(self, module, module_file, package):
154154 if copied :
155155 self ._updated_files .append (outfile )
156156 return outfile , copied
157+
158+
159+ def customize_build_py (rename_dir_from_to = ("_async" , "_sync" )):
160+ class _build_py (build_py ):
161+ RENAME_DIR_FROM_TO = rename_dir_from_to
162+
163+ return _build_py
0 commit comments