#NEWLINE# def sign( wheelfile , replace = False , get_keyring = get_keyring ) : #NEWLINE# #INDENT# 'Sign a wheel' #NEWLINE# ( WheelKeys , keyring ) = get_keyring ( ) #NEWLINE# ed25519ll = signatures . get_ed25519ll ( ) #NEWLINE# wf = WheelFile ( wheelfile , append = True ) #NEWLINE# wk = WheelKeys ( ) . load ( ) #NEWLINE# name = wf . parsed_filename . group ( 'name' ) #NEWLINE# sign_with = wk . signers ( name ) [ 0 ] #NEWLINE# sys . stdout . write ( 'Signing {0} with {1}\n' . format ( name , sign_with [ 1 ] ) ) #NEWLINE# vk = sign_with [ 1 ] #NEWLINE# kr = keyring . get_keyring ( ) #NEWLINE# sk = kr . get_password ( 'wheel' , vk ) #NEWLINE# keypair = ed25519ll . Keypair ( urlsafe_b64decode ( binary ( vk ) ) , urlsafe_b64decode ( binary ( sk ) ) ) #NEWLINE# record_name = ( wf . distinfo_name + '/RECORD' ) #NEWLINE# sig_name = ( wf . distinfo_name + '/RECORD.jws' ) #NEWLINE# if ( sig_name in wf . zipfile . namelist ( ) ) : #NEWLINE# #INDENT# raise WheelError ( 'Wheel is already signed.' ) #NEWLINE# #UNINDENT# record_data = wf . zipfile . read ( record_name ) #NEWLINE# payload = { #NEWLINE# #INDENT# 'hash' : ( 'sha256=' + native ( urlsafe_b64encode ( hashlib . sha256 ( record_data ) . digest ( ) ) ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# sig = signatures . sign ( payload , keypair ) #NEWLINE# wf . zipfile . writestr ( sig_name , json . dumps ( sig , sort_keys = True ) ) #NEWLINE# wf . zipfile . close ( )