From c095c2861848fefb6e99f58b0a56716e099116aa Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Sun, 6 Jun 2021 15:30:20 +0200 Subject: [PATCH] Split requirements into world types, automatically discover and resolve them. --- ModuleUpdate.py | 10 +++++++++- WebHost.py | 2 +- requirements.txt | 4 ---- worlds/alttp/requirements.txt | 3 +++ worlds/factorio/requirements.txt | 2 ++ 5 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 worlds/alttp/requirements.txt create mode 100644 worlds/factorio/requirements.txt diff --git a/ModuleUpdate.py b/ModuleUpdate.py index 3c2cc987b4c8..2a578aabc8d1 100644 --- a/ModuleUpdate.py +++ b/ModuleUpdate.py @@ -3,12 +3,20 @@ import subprocess import pkg_resources -requirements_files = ['requirements.txt'] +requirements_files = {'requirements.txt'} + if sys.version_info < (3, 8, 6): raise RuntimeError("Incompatible Python Version. 3.8.7+ is supported.") update_ran = getattr(sys, "frozen", False) # don't run update if environment is frozen/compiled +if not update_ran: + for entry in os.scandir("worlds"): + if entry.is_dir(): + req_file = os.path.join(entry.path, "requirements.txt") + if os.path.exists(req_file): + requirements_files.add(req_file) + def update_command(): for file in requirements_files: diff --git a/WebHost.py b/WebHost.py index 50022b0b1697..a3a259476cc5 100644 --- a/WebHost.py +++ b/WebHost.py @@ -3,7 +3,7 @@ import logging import ModuleUpdate -ModuleUpdate.requirements_files.append(os.path.join("WebHostLib", "requirements.txt")) +ModuleUpdate.requirements_files.add(os.path.join("WebHostLib", "requirements.txt")) ModuleUpdate.update() from WebHostLib import app as raw_app diff --git a/requirements.txt b/requirements.txt index 946f89ff4510..5b7e32d069d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,10 +2,6 @@ colorama>=0.4.4 websockets>=9.1 PyYAML>=5.4.1 fuzzywuzzy>=0.18.0 -bsdiff4>=1.2.1 prompt_toolkit>=3.0.18 appdirs>=1.4.4 -maseya-z3pr>=1.0.0rc1 -xxtea>=2.0.0.post0 -factorio-rcon-py>=1.2.1 jinja2>=3.0.1 \ No newline at end of file diff --git a/worlds/alttp/requirements.txt b/worlds/alttp/requirements.txt new file mode 100644 index 000000000000..83e890ae149a --- /dev/null +++ b/worlds/alttp/requirements.txt @@ -0,0 +1,3 @@ +bsdiff4>=1.2.1 +maseya-z3pr>=1.0.0rc1 +xxtea>=2.0.0.post0 \ No newline at end of file diff --git a/worlds/factorio/requirements.txt b/worlds/factorio/requirements.txt new file mode 100644 index 000000000000..0fe5b405206e --- /dev/null +++ b/worlds/factorio/requirements.txt @@ -0,0 +1,2 @@ +kivy>=2.0.0 +factorio-rcon-py>=1.2.1 \ No newline at end of file