@@ -41,7 +41,7 @@ def _to_generic_pyver(pyver_tags):
4141 return ['py%s' % tag [2 ] if tag .startswith ('cp' ) else tag for tag in pyver_tags ]
4242
4343
44- def _convert_to_generic_platform_wheel (wheel_ctx , additional_platforms ):
44+ def _convert_to_generic_platform_wheel (wheel_ctx , py2_py3 , additional_platforms ):
4545 """Switch to generic python tags and remove ABI tags from a wheel
4646
4747 Convert implementation specific python tags to their generic equivalent and
@@ -51,6 +51,8 @@ def _convert_to_generic_platform_wheel(wheel_ctx, additional_platforms):
5151 ----------
5252 wheel_ctx : InWheelCtx
5353 An open wheel context
54+ py2_py3: Bool
55+ Wether the pyver tag shall be py2.py3 or just the one inferred from the wheel name
5456 additional_platforms : Optional[Iterable[str]]
5557 An optional iterable of additional platform to add to the wheel
5658 """
@@ -91,6 +93,10 @@ def _convert_to_generic_platform_wheel(wheel_ctx, additional_platforms):
9193 original_pyver_tags = fparts ['pyver' ].split ('.' )
9294 logger .debug ('Previous pyver tags: %s' , ', ' .join (original_pyver_tags ))
9395 pyver_tags = _to_generic_pyver (original_pyver_tags )
96+ if py2_py3 :
97+ if len (set (["py2" , "py3" ]) & set (pyver_tags )) == 0 :
98+ raise ValueError ("pyver_tags does not contain py2 nor py3" )
99+ pyver_tags = list (sorted (set (pyver_tags + ["py2" , "py3" ])))
94100 if pyver_tags != original_pyver_tags :
95101 logger .debug ('New pyver tags ....: %s' , ', ' .join (pyver_tags ))
96102 fparts ['pyver' ] = '.' .join (pyver_tags )
@@ -115,8 +121,7 @@ def _convert_to_generic_platform_wheel(wheel_ctx, additional_platforms):
115121
116122 # Python version, C-API version combinations
117123 pyc_apis = []
118- for tag in in_info_tags :
119- py_ver = '.' .join (_to_generic_pyver (tag .split ('-' )[0 ].split ('.' )))
124+ for py_ver in pyver_tags :
120125 abi = 'none'
121126 pyc_apis .append ('-' .join ([py_ver , abi ]))
122127 # unique Python version, C-API version combinations
@@ -138,7 +143,7 @@ def _convert_to_generic_platform_wheel(wheel_ctx, additional_platforms):
138143
139144
140145def convert_to_generic_platform_wheel (wheel_path , out_dir = './dist/' , remove_original = False , verbose = 0 ,
141- additional_platforms = None ):
146+ py2_py3 = False , additional_platforms = None ):
142147 logging .disable (logging .NOTSET )
143148 if verbose >= 1 :
144149 logging .basicConfig (level = logging .DEBUG )
@@ -150,7 +155,7 @@ def convert_to_generic_platform_wheel(wheel_path, out_dir='./dist/', remove_orig
150155
151156 with InWheelCtx (wheel_path ) as ctx :
152157 ctx .out_wheel = pjoin (out_dir , wheel_fname )
153- ctx .out_wheel = _convert_to_generic_platform_wheel (ctx , additional_platforms )
158+ ctx .out_wheel = _convert_to_generic_platform_wheel (ctx , py2_py3 , additional_platforms )
154159
155160 if remove_original :
156161 logger .info ('Removed original wheel %s' % wheel_path )
@@ -179,13 +184,23 @@ def main():
179184 dest = 'remove_original' ,
180185 action = 'store_true' ,
181186 help = 'Remove original wheel' )
187+ p .add_argument ("--py2-py3" ,
188+ dest = 'py2_py3' ,
189+ action = 'store_true' ,
190+ help = 'Remove original wheel' )
191+ p .add_argument ("-p" ,
192+ "--add-platform" ,
193+ dest = 'additional_platforms' ,
194+ action = "append" ,
195+ help = 'Add a platform tag' )
182196
183197 args = p .parse_args ()
184198
185199 if not isfile (args .WHEEL_FILE ):
186200 p .error ('cannot access %s. No such file' % args .WHEEL_FILE )
187201
188- convert_to_generic_platform_wheel (args .WHEEL_FILE , args .WHEEL_DIR , args .remove_original , args .verbose )
202+ convert_to_generic_platform_wheel (args .WHEEL_FILE , args .WHEEL_DIR , args .remove_original , args .verbose ,
203+ args .py2_py3 , args .additional_platforms )
189204
190205
191206if __name__ == '__main__' :
0 commit comments