Skip to content

Commit

Permalink
Setup: don't install webhost dependencies
Browse files Browse the repository at this point in the history
also makes ModuleUpdate detect changed requirements for update()
  • Loading branch information
black-sliver committed Jan 13, 2024
1 parent 3933fd3 commit d5080c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
21 changes: 18 additions & 3 deletions ModuleUpdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@
import multiprocessing
import warnings

local_dir = os.path.dirname(__file__)
requirements_files = {os.path.join(local_dir, 'requirements.txt')}

if sys.version_info < (3, 8, 6):
raise RuntimeError("Incompatible Python Version. 3.8.7+ is supported.")

# don't run update if environment is frozen/compiled or if not the parent process (skip in subprocess)
update_ran = getattr(sys, "frozen", False) or multiprocessing.parent_process()
_skip_update = bool(getattr(sys, "frozen", False) or multiprocessing.parent_process())
update_ran = _skip_update


class RequirementsSet(set):
def add(self, e):
global update_ran
update_ran &= _skip_update
super().add(e)

def update(self, *s):
global update_ran
update_ran &= _skip_update
super().update(*s)


local_dir = os.path.dirname(__file__)
requirements_files = RequirementsSet((os.path.join(local_dir, 'requirements.txt'),))

if not update_ran:
for entry in os.scandir(os.path.join(local_dir, "worlds")):
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
# 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 worlds.LauncherComponents import components, icon_paths
from Utils import version_tuple, is_windows, is_linux
Expand Down Expand Up @@ -304,7 +303,6 @@ def run(self):
print(f"Outputting to: {self.buildfolder}")
os.makedirs(self.buildfolder, exist_ok=True)
import ModuleUpdate
ModuleUpdate.requirements_files.add(os.path.join("WebHostLib", "requirements.txt"))
ModuleUpdate.update(yes=self.yes)

# auto-build cython modules
Expand Down

0 comments on commit d5080c0

Please sign in to comment.