From 4ffe6ce3c343a1e822e703a3192db29d13364892 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 31 Jul 2024 09:53:13 +0100 Subject: [PATCH 1/2] fix: don't resolve `node` symlink & fix version error message --- packages/mystmd-py/src/mystmd_py/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mystmd-py/src/mystmd_py/main.py b/packages/mystmd-py/src/mystmd_py/main.py index efb0a76e2..5372909fb 100644 --- a/packages/mystmd-py/src/mystmd_py/main.py +++ b/packages/mystmd-py/src/mystmd_py/main.py @@ -18,7 +18,7 @@ def main(): "We recommend installing the latest LTS release, using your preferred package manager\n" "or following instructions here: https://nodejs.org/en/download" ) - node = pathlib.Path(NODE_LOCATION).resolve() + node = pathlib.Path(NODE_LOCATION).absolute() _version = subprocess.run([node, "-v"], capture_output=True, check=True, text=True).stdout major_version_match = re.match(r"v(\d+).*", _version) @@ -29,7 +29,7 @@ def main(): major_version = int(major_version_match[1]) if not (major_version in {18, 20, 22} or major_version > 22): raise SystemExit( - f"MyST requires node 18, 20, or 22+; you are running node {version[1:3]}.\n\n" + f"MyST requires node 18, 20, or 22+; you are running node {major_version}.\n\n" "Please update to the latest LTS release, using your preferred package manager\n" "or following instructions here: https://nodejs.org/en/download" ) From c5f42452df8053b5db46b4ced5bdc419f6da1d4b Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Wed, 31 Jul 2024 09:55:09 +0100 Subject: [PATCH 2/2] chore: run black --- packages/mystmd-py/src/mystmd_py/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/mystmd-py/src/mystmd_py/main.py b/packages/mystmd-py/src/mystmd_py/main.py index 5372909fb..e334dcbaf 100644 --- a/packages/mystmd-py/src/mystmd_py/main.py +++ b/packages/mystmd-py/src/mystmd_py/main.py @@ -20,9 +20,11 @@ def main(): ) node = pathlib.Path(NODE_LOCATION).absolute() - _version = subprocess.run([node, "-v"], capture_output=True, check=True, text=True).stdout + _version = subprocess.run( + [node, "-v"], capture_output=True, check=True, text=True + ).stdout major_version_match = re.match(r"v(\d+).*", _version) - + if major_version_match is None: raise SystemExit(f"MyST could not determine the version of Node.js: {_version}") @@ -33,8 +35,12 @@ def main(): "Please update to the latest LTS release, using your preferred package manager\n" "or following instructions here: https://nodejs.org/en/download" ) - os.execve(node, [node.name, PATH_TO_BIN_JS, *sys.argv[1:]], {**os.environ, "MYST_LANG": "PYTHON"}) - + os.execve( + node, + [node.name, PATH_TO_BIN_JS, *sys.argv[1:]], + {**os.environ, "MYST_LANG": "PYTHON"}, + ) + if __name__ == "__main__": main()