From 7426eaf99e0aa6104dfc7062bc3a36b40c0d7bf3 Mon Sep 17 00:00:00 2001 From: melvyn2 Date: Sat, 2 Nov 2019 13:57:53 -0700 Subject: [PATCH] Fix many releases issues: -Windows powershell syntax -Nuitka not properly linking openssl -Problem with the test And clean up bits of PySteamAuth.py --- .github/workflows/build-and-deploy.yml | 1 + .idea/.gitignore | 2 + .idea/inspectionProfiles/Project_Default.xml | 21 +-------- .../markdown-navigator/profiles_settings.xml | 3 -- .idea/scopes/Main_Code.xml | 3 ++ PySteamAuth/PySteamAuth.py | 24 ++++++----- ...hoserdialog.ui => AccountChooserDialog.ui} | 0 PySteamAuth/UIs/PySteamAuth.pro | 2 +- make.py | 43 ++++++++++++++----- 9 files changed, 53 insertions(+), 46 deletions(-) create mode 100644 .idea/.gitignore delete mode 100644 .idea/markdown-navigator/profiles_settings.xml create mode 100644 .idea/scopes/Main_Code.xml rename PySteamAuth/UIs/{accountchoserdialog.ui => AccountChooserDialog.ui} (100%) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index dd5a646..c3db386 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -50,6 +50,7 @@ jobs: run: python make.py deps - name: Build run: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat" && python make.py build --zip -v' + shell: cmd - name: Test run: python make.py test - run: go get github.com/aktau/github-release diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 8f4daee..467be61 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -1,29 +1,10 @@ - \ No newline at end of file + diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml deleted file mode 100644 index db06266..0000000 --- a/.idea/markdown-navigator/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/scopes/Main_Code.xml b/.idea/scopes/Main_Code.xml new file mode 100644 index 0000000..ab2c1a3 --- /dev/null +++ b/.idea/scopes/Main_Code.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/PySteamAuth/PySteamAuth.py b/PySteamAuth/PySteamAuth.py index 79f8633..3bafb0a 100755 --- a/PySteamAuth/PySteamAuth.py +++ b/PySteamAuth/PySteamAuth.py @@ -217,7 +217,7 @@ def load_info(): info.index -= 1 conf_ui.titleLabel.setText(conf.description) conf_ui.infoLabel.setText('{0}\nTime: {1}\nID: {2}\nType: {3}' - .format(conf.sub_description, conf.time, conf.id, conf.type_str)) + .format(conf.sub_description, conf.time, conf.id, conf.type_str)) if conf.icon_url: pixmap = QtGui.QPixmap() pixmap.loadFromData(requests.get(conf.icon_url).content) @@ -249,9 +249,10 @@ def refresh_confs(): load_info() conf_ui.refreshButton.clicked.connect(refresh_confs) conf_ui.nextButton.clicked.connect(lambda: (setattr(info, 'index', ((info.index + 1) if info.index < - (len(info.confs) - 1) else info.index)), load_info())) + (len(info.confs) - 1) else info.index)), + load_info())) conf_ui.backButton.clicked.connect(lambda: (setattr(info, 'index', ((info.index - 1) if info.index > 0 - else info.index)), load_info())) + else info.index)), load_info())) conf_ui.acceptButton.clicked.connect(accept) conf_ui.denyButton.clicked.connect(deny) conf_dialog.exec_() @@ -271,7 +272,7 @@ def add_authenticator(): code_ui.buttonBox.rejected.connect(lambda: setattr(endfunc, 'endfunc', True)) code_dialog.setWindowTitle('Phone number') code_ui.actionBox.setText('This account is missing a phone number. Type yours below to add it.\n' - 'Eg. +1 123-456-7890') + 'Eg. +1 123-456-7890') code_dialog.exec_() if endfunc.endfunc: return @@ -299,7 +300,7 @@ def add_authenticator(): code_ui.buttonBox.rejected.connect(lambda: setattr(endfunc, 'endfunc', True)) code_dialog.setWindowTitle('Remove old authenticator') code_ui.actionBox.setText('There is already an authenticator associated with this account.' - ' Enter its revocation code to remove it.') + ' Enter its revocation code to remove it.') code_dialog.exec_() if endfunc.endfunc: return @@ -327,11 +328,11 @@ def add_authenticator(): with open(os.path.join(mafiles_folder_path, 'manifest.json'), 'w') as manifest_file: manifest_file.write(json.dumps( {'periodic_checking': False, 'first_run': False, 'encrypted': False, 'periodic_checking_interval': 5, - 'periodic_checking_checkall': False, 'auto_confirm_market_transactions': False, - 'entries': [{'steamid': mwa.steam_id, 'encryption_iv': None, 'encryption_salt': None, - 'filename': mwa.steam_id + '.maFile'}], 'auto_confirm_trades': False})) + 'periodic_checking_checkall': False, 'auto_confirm_market_transactions': False, + 'entries': [{'steamid': mwa.steam_id, 'encryption_iv': None, 'encryption_salt': None, + 'filename': mwa.steam_id + '.maFile'}], 'auto_confirm_trades': False})) Common.error_popup('This is your revocation code. Write it down physically and keep it. You will need it in case' - ' you lose your authenticator.', sa.secrets['revocation_code']) + ' you lose your authenticator.', sa.secrets['revocation_code']) code_dialog = QtWidgets.QDialog() code_ui = PyUIs.PhoneDialog.Ui_Dialog() code_ui.setupUi(code_dialog) @@ -429,7 +430,7 @@ def app_load(): manifest_entry_index = manifest['selected_account'] else: ac_dialog = QtWidgets.QDialog() - ac_ui = PyUIs.AccountChoserDialog.Ui_Dialog() + ac_ui = PyUIs.AccountChooserDialog.Ui_Dialog() ac_ui.setupUi(ac_dialog) for i in valid_entries: try: @@ -518,7 +519,8 @@ def main(argv): # TODO debug menubar actions app = QtWidgets.QApplication(argv) if '--test' in argv: - QtCore.QTimer.singleShot(3000, app.quit) + sys.exit() + # QtCore.QTimer.singleShot(3000, app.quit) main_window = QtWidgets.QMainWindow() main_ui = PyUIs.MainWindow.Ui_MainWindow() main_ui.setupUi(main_window) diff --git a/PySteamAuth/UIs/accountchoserdialog.ui b/PySteamAuth/UIs/AccountChooserDialog.ui similarity index 100% rename from PySteamAuth/UIs/accountchoserdialog.ui rename to PySteamAuth/UIs/AccountChooserDialog.ui diff --git a/PySteamAuth/UIs/PySteamAuth.pro b/PySteamAuth/UIs/PySteamAuth.pro index 2d66eca..00876e1 100644 --- a/PySteamAuth/UIs/PySteamAuth.pro +++ b/PySteamAuth/UIs/PySteamAuth.pro @@ -22,7 +22,7 @@ FORMS += \ ErrorDialog.ui \ ConfirmationDialog.ui \ BackupCodesDeleteDialog.ui \ - AccountChoserDialog.ui \ + AccountChooserDialog.ui \ BackupCodesCreatedDialog.ui DISTFILES += diff --git a/make.py b/make.py index fae103c..92a0201 100755 --- a/make.py +++ b/make.py @@ -142,7 +142,28 @@ def build_qt_files(): .replace('${USERNAME}', username) .replace('${VERSION}', version)) os.rename('PySteamAuth.dist', os.path.join('PySteamAuth.app', 'Contents', 'MacOS')) - os.chdir('..') + # Hotfix for issue Nuitka/Nuitka#516 + os.chdir(os.path.join('PySteamAuth.app', 'Contents', 'MacOS')) + try: + libs = subprocess.check_output(['otool', '-L', '_ssl.so']).decode('utf-8').split('\n') + for i in libs[1:]: + if 'libssl' in i: + target_lib = i.strip().split(' (')[0].replace('@executable_path', '.') + break + else: + raise FileNotFoundError('could not find target lib path') + libs = subprocess.check_output(['otool', '-L', target_lib]).decode('utf-8').split('\n') + for i in libs[1:]: + if 'libcrypto' in i: + static_lib = i.strip().split(' (')[0] + break + else: + raise FileNotFoundError('could not find static lib path') + distributed_lib = os.path.join('@executable_path', os.path.basename(static_lib)) + subprocess.check_output(['install_name_tool', '-change', static_lib, distributed_lib, target_lib]) + except (subprocess.CalledProcessError, FileNotFoundError): + print('Warning: failed to patch statically linked libraries. Bundle may not work!') + os.chdir('../' * 4) os.mkdir('dist') os.rename(os.path.join('build', 'PySteamAuth.app'), os.path.join('dist', 'PySteamAuth.app')) else: @@ -314,6 +335,14 @@ def build_qt_files(): print('Using github-release at', gh_release) set_target = True + try: + rev_sha = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], check=True, stderr=subprocess.PIPE, + stdout=subprocess.PIPE).stdout.decode('utf-8').strip() + except subprocess.CalledProcessError as e: + raise SystemExit('Failed to get revision sha\n' + e.stderr.decode('utf-8')) + except FileNotFoundError: + raise SystemExit('Failed to find git') + if '-t' in sys.argv: try: tag = sys.argv[sys.argv.index('-t') + 1] @@ -323,16 +352,9 @@ def build_qt_files(): try: tag = subprocess.run(['git', 'describe', '--exact-match'], check=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE).stdout.decode('utf-8').strip() - except FileNotFoundError: - raise SystemExit('Failed to find git') except subprocess.CalledProcessError as e: if b'no tag exactly matches' in e.stderr: - try: - tag = 'pre-' + subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], check=True, - stderr=subprocess.PIPE, stdout=subprocess.PIPE) \ - .stdout.decode('utf-8').strip() - except subprocess.CalledProcessError as e1: - raise SystemExit('Failed to create tag\n' + e1.stderr.decode('utf-8')) + tag = 'pre-' + rev_sha else: raise SystemExit('Failed to fetch tag\n' + e.stderr.decode('utf-8')) else: @@ -343,8 +365,7 @@ def build_qt_files(): if prerelease and '-f' not in sys.argv: try: - if subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).decode('utf-8').strip() \ - != 'master': + if 'master' in subprocess.check_output(['git', 'branch', '--contains', rev_sha]).decode('utf-8').strip(): print('Not on master branch or tag; use -f to force') sys.exit(0) except subprocess.CalledProcessError: