@@ -64,11 +64,7 @@ def unasync_name(name):
64
64
if name in ASYNC_TO_SYNC :
65
65
return ASYNC_TO_SYNC [name ]
66
66
# 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 ():
72
68
return "Sync" + name [5 :]
73
69
return name
74
70
@@ -131,7 +127,11 @@ class build_py(orig.build_py):
131
127
and saves them in _sync dir.
132
128
"""
133
129
130
+ RENAME_DIR_FROM_TO = ("_async" , "_sync" ) # Controls what directory will be renamed.
131
+
134
132
def run (self ):
133
+ dir_from , dir_to = self .RENAME_DIR_FROM_TO
134
+
135
135
self ._updated_files = []
136
136
137
137
# Base class code
@@ -143,8 +143,8 @@ def run(self):
143
143
144
144
# Our modification!
145
145
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 )
148
148
149
149
# Remaining base class code
150
150
self .byte_compile (self .get_outputs (include_bytecode = 0 ))
@@ -154,3 +154,10 @@ def build_module(self, module, module_file, package):
154
154
if copied :
155
155
self ._updated_files .append (outfile )
156
156
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