From 428344b6bccf7f69193e5b10d9db3d42414d01f1 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Mon, 30 Jan 2023 01:47:28 +0100 Subject: [PATCH] setup: honor build automation ... ... and reorder imports to PEP it up --- setup.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index a9c7da5c..35a6acc8 100644 --- a/setup.py +++ b/setup.py @@ -10,27 +10,12 @@ import zipfile from collections.abc import Iterable from hashlib import sha3_512 from pathlib import Path - - -if __name__ == "__main__": - import ModuleUpdate - ModuleUpdate.update() - -from Launcher import components, icon_paths -from Utils import version_tuple, is_windows, is_linux - -# On Python < 3.10 LogicMixin is not currently supported. -apworlds: set = { - "Subnautica", - "Factorio", - "Rogue Legacy", -} - -# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it import subprocess import pkg_resources -requirement = 'cx-Freeze>=6.14.1' + +# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it try: + requirement = 'cx-Freeze>=6.14.1' pkg_resources.require(requirement) import cx_Freeze except pkg_resources.ResolutionError: @@ -42,6 +27,24 @@ except pkg_resources.ResolutionError: # .build only exists if cx-Freeze is the right version, so we have to update/install that first before this line import setuptools.command.build +if __name__ == "__main__": + # need to run this early to import from Utils and Launcher + # TODO: move stuff to not require this + import ModuleUpdate + ModuleUpdate.update(yes="--yes" in sys.argv or "-y" in sys.argv) + ModuleUpdate.update_ran = False # restore for later + +from Launcher import components, icon_paths +from Utils import version_tuple, is_windows, is_linux + + +# On Python < 3.10 LogicMixin is not currently supported. +apworlds: set = { + "Subnautica", + "Factorio", + "Rogue Legacy", +} + if os.path.exists("X:/pw.txt"): print("Using signtool") with open("X:/pw.txt", encoding="utf-8-sig") as f: