From 58642edc17f447e18d9a8c04e3cf803b17b97355 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:19:33 +0200 Subject: [PATCH] Core: allow multi-line and --hash in requirements.txt --- ModuleUpdate.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ModuleUpdate.py b/ModuleUpdate.py index 209f2da6..c33e894e 100644 --- a/ModuleUpdate.py +++ b/ModuleUpdate.py @@ -67,14 +67,23 @@ def update(yes=False, force=False): install_pkg_resources(yes=yes) import pkg_resources + prev = "" # if a line ends in \ we store here and merge later for req_file in requirements_files: path = os.path.join(os.path.dirname(sys.argv[0]), req_file) if not os.path.exists(path): path = os.path.join(os.path.dirname(__file__), req_file) with open(path) as requirementsfile: for line in requirementsfile: - if not line or line[0] == "#": - continue # ignore comments + if not line or line.lstrip(" \t")[0] == "#": + if not prev: + continue # ignore comments + line = "" + elif line.rstrip("\r\n").endswith("\\"): + prev = prev + line.rstrip("\r\n")[:-1] + " " # continue on next line + continue + line = prev + line + line = line.split("--hash=")[0] # remove hashes from requirement for version checking + prev = "" if line.startswith(("https://", "git+https://")): # extract name and version for url rest = line.split('/')[-1]