Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
provision: Avoid distutils; keep PROVISION_VERSION as a tuple.
Anders Kaseorg412e90f601b6
diff --git a/docs/subsystems/dependencies.md b/docs/subsystems/dependencies.mdindex 9335eaa5dba..4fa35122753 100644--- a/docs/subsystems/dependencies.md+++ b/docs/subsystems/dependencies.md@@ -43,7 +43,7 @@ In `version.py`, we have a special parameter, `PROVISION_VERSION`,which is used to help ensure developers don't spend time debuggingtest/linter/etc. failures that actually were caused by the developerrebasing and forgetting to provision". `PROVISION_VERSION` has a-format of `x.y`; when `x` doesn't match the value from the last time+format of `(x, y)`; when `x` doesn't match the value from the last timethe user provisioned, or `y` is higher than the value from lasttime, most Zulip tools will crash early and ask the user to provision.This has empirically made a huge impact on how often developers spenddiff --git a/tools/diagnose b/tools/diagnoseindex 1b05167c381..b29375b55c4 100755--- a/tools/diagnose+++ b/tools/diagnose@@ -76,12 +76,12 @@ def check_django() -> bool:def provision_version() -> bool:fn = os.path.join(UUID_VAR_PATH, "provision_version")with open(fn) as f:- version = f.read().strip()+ version = tuple(map(int, f.read().strip().split(".")))print("latest version provisioned:", version)from version import PROVISION_VERSIONprint("desired version:", PROVISION_VERSION)- if version != PROVISION_VERSION:+ if not (PROVISION_VERSION <= version < (PROVISION_VERSION[0] + 1,)):print("You need to provision!")return Falsereturn Truediff --git a/tools/lib/provision_inner.py b/tools/lib/provision_inner.pyindex c77f70eb33a..acc1856ff0e 100755--- a/tools/lib/provision_inner.py+++ b/tools/lib/provision_inner.py@@ -362,7 +362,7 @@ def main(options: argparse.Namespace) -> int:version_file = os.path.join(UUID_VAR_PATH, "provision_version")print(f"writing to {version_file}\n")with open(version_file, "w") as f:- f.write(PROVISION_VERSION + "\n")+ f.write(".".join(map(str, PROVISION_VERSION)) + "\n")print()print(OKBLUE + "Zulip development environment setup succeeded!" + ENDC)diff --git a/tools/lib/test_script.py b/tools/lib/test_script.pyindex 07e767bd327..aefd1582d55 100644--- a/tools/lib/test_script.py+++ b/tools/lib/test_script.py@@ -3,7 +3,6 @@ import osimport subprocessimport sysfrom argparse import ArgumentParser-from distutils.version import LooseVersionfrom typing import Iterable, List, Optional, Tuplefrom scripts.lib.zulip_tools import get_dev_uuid_var_path@@ -12,10 +11,6 @@ from version import PROVISION_VERSIONZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))-def get_major_version(v: str) -> int:- return int(v.split(".")[0])--def get_version_file() -> str:uuid_var_path = get_dev_uuid_var_path()return os.path.join(uuid_var_path, "provision_version")@@ -30,7 +25,7 @@ properly."""-def preamble(version: str) -> str:+def preamble(version: Tuple[int, ...]) -> str:text = PREAMBLE.format(version, PROVISION_VERSION)text += "\n"return text@@ -64,21 +59,16 @@ def get_provisioning_status() -> Tuple[bool, Optional[str]]:return True, Nonewith open(version_file) as f:- version = f.read().strip()-- # Normal path for people that provision--we're all good!- if version == PROVISION_VERSION:- return True, None+ version = tuple(map(int, f.read().strip().split(".")))# We may be more provisioned than the branch we just moved to. As# long as the major version hasn't changed, then we should be ok.- if LooseVersion(version) > LooseVersion(PROVISION_VERSION):- if get_major_version(version) == get_major_version(PROVISION_VERSION):- return True, None- else:- return False, preamble(version) + NEED_TO_DOWNGRADE-- return False, preamble(version) + NEED_TO_UPGRADE+ if version < PROVISION_VERSION:+ return False, preamble(version) + NEED_TO_UPGRADE+ elif version < (PROVISION_VERSION[0] + 1,):+ return True, None+ else:+ return False, preamble(version) + NEED_TO_DOWNGRADEdef assert_provisioning_status_ok(skip_provision_check: bool) -> None:diff --git a/version.py b/version.pyindex d58ea178fab..a364e215034 100644--- a/version.py+++ b/version.py@@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 133# historical commits sharing the same major version, in which case a# minor version bump suffices.-PROVISION_VERSION = "195.0"+PROVISION_VERSION = (195, 0)