mystmd 1.3.10__tar.gz → 1.3.12__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mystmd-1.3.10 → mystmd-1.3.12}/PKG-INFO +1 -1
- {mystmd-1.3.10 → mystmd-1.3.12}/_package.json +2 -2
- mystmd-1.3.12/src/mystmd_py/main.py +79 -0
- {mystmd-1.3.10 → mystmd-1.3.12}/src/mystmd_py/myst.cjs +1971 -2046
- {mystmd-1.3.10 → mystmd-1.3.12}/src/mystmd_py/nodeenv.py +25 -17
- mystmd-1.3.10/src/mystmd_py/main.py +0 -151
- {mystmd-1.3.10 → mystmd-1.3.12}/.gitignore +0 -0
- {mystmd-1.3.10 → mystmd-1.3.12}/LICENSE +0 -0
- {mystmd-1.3.10 → mystmd-1.3.12}/README.md +0 -0
- {mystmd-1.3.10 → mystmd-1.3.12}/pyproject.toml +0 -0
- {mystmd-1.3.10 → mystmd-1.3.12}/src/mystmd_py/__init__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mystmd",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.12",
|
4
4
|
"description": "Command line tools for MyST Markdown",
|
5
5
|
"author": "Rowan Cockett <rowan@curvenote.com>",
|
6
6
|
"license": "MIT",
|
@@ -45,6 +45,6 @@
|
|
45
45
|
"commander": "^10.0.1",
|
46
46
|
"core-js": "^3.31.1",
|
47
47
|
"js-yaml": "^4.1.0",
|
48
|
-
"myst-cli": "^1.3.
|
48
|
+
"myst-cli": "^1.3.12"
|
49
49
|
}
|
50
50
|
}
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import os
|
2
|
+
import pathlib
|
3
|
+
import platform
|
4
|
+
import subprocess
|
5
|
+
import sys
|
6
|
+
import re
|
7
|
+
import textwrap
|
8
|
+
|
9
|
+
from .nodeenv import find_any_node, PermissionDeniedError, NodeEnvCreationError
|
10
|
+
|
11
|
+
|
12
|
+
NODEENV_VERSION = "18.0.0"
|
13
|
+
|
14
|
+
|
15
|
+
def ensure_valid_version(node_path, node_env):
|
16
|
+
# Check version
|
17
|
+
_version = subprocess.run(
|
18
|
+
[node_path, "-v"], capture_output=True, check=True, text=True, env=node_env
|
19
|
+
).stdout
|
20
|
+
major_version_match = re.match(r"v(\d+).*", _version)
|
21
|
+
|
22
|
+
if major_version_match is None:
|
23
|
+
raise SystemExit(f"MyST could not determine the version of Node.js: {_version}")
|
24
|
+
major_version = int(major_version_match[1])
|
25
|
+
if not (major_version in {18, 20, 22} or major_version > 22):
|
26
|
+
raise SystemExit(
|
27
|
+
f"MyST requires node 18, 20, or 22+; you are running node {major_version}.\n\n"
|
28
|
+
"Please update to the latest LTS release, using your preferred package manager\n"
|
29
|
+
"or following instructions here: https://nodejs.org/en/download"
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
def main():
|
34
|
+
# Find NodeJS (and potential new PATH)
|
35
|
+
binary_path = os.environ.get("PATH", os.defpath)
|
36
|
+
try:
|
37
|
+
node_path, os_path = find_any_node(binary_path, nodeenv_version=NODEENV_VERSION)
|
38
|
+
except NodeEnvCreationError as err:
|
39
|
+
message = textwrap.indent(err.args[0], " ")
|
40
|
+
raise SystemExit(
|
41
|
+
"💥 The attempt to install Node.js was unsuccessful.\n"
|
42
|
+
f"🔍 Underlying error:\n{message}\n\n"
|
43
|
+
"ℹ️ We recommend installing the latest LTS release, using your preferred package manager "
|
44
|
+
"or following instructions here: https://nodejs.org\n\n"
|
45
|
+
) from err
|
46
|
+
except PermissionDeniedError as err:
|
47
|
+
raise SystemExit(
|
48
|
+
"💥 The attempt to install Node.js failed because the user denied the request.\n"
|
49
|
+
"ℹ️ We recommend installing the latest LTS release, using your preferred package manager "
|
50
|
+
"or following instructions here: https://nodejs.org\n\n"
|
51
|
+
) from err
|
52
|
+
|
53
|
+
# Build new env dict
|
54
|
+
node_env = {**os.environ, "PATH": os_path}
|
55
|
+
|
56
|
+
# Ensure Node.js is compatible
|
57
|
+
ensure_valid_version(node_path, node_env)
|
58
|
+
|
59
|
+
# Find path to compiled JS
|
60
|
+
js_path = (pathlib.Path(__file__).parent / "myst.cjs").resolve()
|
61
|
+
|
62
|
+
# Build args for Node.js process
|
63
|
+
myst_node_args = [js_path, *sys.argv[1:]]
|
64
|
+
myst_env = {**node_env, "MYST_LANG": "PYTHON"}
|
65
|
+
|
66
|
+
# Invoke appropriate binary for platform
|
67
|
+
if platform.system() == "Windows":
|
68
|
+
result = subprocess.run([node_path, *myst_node_args], env=myst_env)
|
69
|
+
sys.exit(result.returncode)
|
70
|
+
else:
|
71
|
+
os.execve(
|
72
|
+
node_path,
|
73
|
+
[node_path.name, *myst_node_args],
|
74
|
+
myst_env,
|
75
|
+
)
|
76
|
+
|
77
|
+
|
78
|
+
if __name__ == "__main__":
|
79
|
+
main()
|