mystmd 1.3.10__py3-none-any.whl → 1.3.12__py3-none-any.whl
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.dist-info → mystmd-1.3.12.dist-info}/METADATA +1 -1
- mystmd-1.3.12.dist-info/RECORD +9 -0
- mystmd_py/main.py +21 -93
- mystmd_py/myst.cjs +1971 -2046
- mystmd_py/nodeenv.py +25 -17
- mystmd-1.3.10.dist-info/RECORD +0 -9
- {mystmd-1.3.10.dist-info → mystmd-1.3.12.dist-info}/WHEEL +0 -0
- {mystmd-1.3.10.dist-info → mystmd-1.3.12.dist-info}/entry_points.txt +0 -0
- {mystmd-1.3.10.dist-info → mystmd-1.3.12.dist-info}/licenses/LICENSE +0 -0
mystmd_py/nodeenv.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import os
|
2
2
|
import pathlib
|
3
|
+
import platform
|
3
4
|
import shutil
|
4
5
|
import subprocess
|
5
6
|
import sys
|
6
7
|
|
7
8
|
|
8
|
-
NODEENV_VERSION = "18.0.0"
|
9
9
|
INSTALL_NODEENV_KEY = "MYSTMD_ALLOW_NODEENV"
|
10
10
|
|
11
11
|
|
@@ -15,16 +15,20 @@ class PermissionDeniedError(Exception): ...
|
|
15
15
|
class NodeEnvCreationError(Exception): ...
|
16
16
|
|
17
17
|
|
18
|
+
def is_windows():
|
19
|
+
return platform.system() == "Windows"
|
20
|
+
|
21
|
+
|
18
22
|
def find_installed_node():
|
19
|
-
|
23
|
+
# shutil.which can find things with PATHEXT, but 3.12.0 breaks this by preferring NODE over NODE.EXE on Windows
|
24
|
+
return shutil.which("node.exe") if is_windows() else shutil.which("node")
|
20
25
|
|
21
26
|
|
22
|
-
def find_nodeenv_path():
|
27
|
+
def find_nodeenv_path(version: str):
|
23
28
|
# The conda packaging of this package does not need to install node!
|
24
29
|
import platformdirs
|
25
|
-
|
26
|
-
|
27
|
-
)
|
30
|
+
|
31
|
+
return platformdirs.user_data_path(appname="myst", appauthor=False, version=version)
|
28
32
|
|
29
33
|
|
30
34
|
def ask_to_install_node(path):
|
@@ -34,13 +38,13 @@ def ask_to_install_node(path):
|
|
34
38
|
return input(f"❔ Install Node.js in '{path}'? (y/N): ").lower() == "y"
|
35
39
|
|
36
40
|
|
37
|
-
def create_nodeenv(env_path):
|
41
|
+
def create_nodeenv(env_path, version):
|
38
42
|
command = [
|
39
43
|
sys.executable,
|
40
44
|
"-m",
|
41
45
|
"nodeenv",
|
42
46
|
"-v",
|
43
|
-
f"--node={
|
47
|
+
f"--node={version}",
|
44
48
|
"--prebuilt",
|
45
49
|
"--clean-src",
|
46
50
|
env_path,
|
@@ -53,24 +57,28 @@ def create_nodeenv(env_path):
|
|
53
57
|
return env_path
|
54
58
|
|
55
59
|
|
56
|
-
def find_any_node(binary_path):
|
60
|
+
def find_any_node(binary_path, nodeenv_version):
|
57
61
|
node_path = find_installed_node()
|
58
62
|
if node_path is not None:
|
59
63
|
return pathlib.Path(node_path).absolute(), binary_path
|
60
64
|
|
61
|
-
nodeenv_path = find_nodeenv_path()
|
65
|
+
nodeenv_path = find_nodeenv_path(nodeenv_version)
|
62
66
|
if not nodeenv_path.exists():
|
63
67
|
print("❗ Node.js (node) is required to run MyST, but could not be found`.")
|
64
68
|
if ask_to_install_node(nodeenv_path):
|
65
|
-
print(f"⚙️
|
66
|
-
create_nodeenv(nodeenv_path)
|
67
|
-
print(f"ℹ️
|
69
|
+
print(f"⚙️ Attempting to install Node.js in {nodeenv_path} ...")
|
70
|
+
create_nodeenv(nodeenv_path, nodeenv_version)
|
71
|
+
print(f"ℹ️ Successfully installed Node.js {nodeenv_version}")
|
68
72
|
else:
|
69
73
|
raise PermissionDeniedError("Node.js installation was not permitted")
|
70
74
|
|
75
|
+
# Find the executable path
|
76
|
+
new_node_path = (
|
77
|
+
(nodeenv_path / "Scripts" / "node.exe")
|
78
|
+
if is_windows()
|
79
|
+
else (nodeenv_path / "bin" / "node")
|
80
|
+
)
|
71
81
|
new_path = os.pathsep.join(
|
72
|
-
[*binary_path.split(os.pathsep), str(
|
82
|
+
[*binary_path.split(os.pathsep), str(new_node_path.parent)]
|
73
83
|
)
|
74
|
-
return
|
75
|
-
|
76
|
-
|
84
|
+
return new_node_path, new_path
|
mystmd-1.3.10.dist-info/RECORD
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
mystmd_py/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
mystmd_py/main.py,sha256=o4Kz4iw3TEAw63qPsTuX0lrrq-tFEbrUbrxC4dTlXB8,4855
|
3
|
-
mystmd_py/myst.cjs,sha256=dLlb4fweN5gA2kbOXRP4HJBPTOoYKa5dOSmC7q05kCU,13118366
|
4
|
-
mystmd_py/nodeenv.py,sha256=3dJ9ZmO5u4smh5EkmOPDYOuHR8-5or181ifPHY-TBaA,2089
|
5
|
-
mystmd-1.3.10.dist-info/METADATA,sha256=oIMyvLspLq1OFTh07bkBScB8DRQT50W4_ksu0PMnTuI,3020
|
6
|
-
mystmd-1.3.10.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
7
|
-
mystmd-1.3.10.dist-info/entry_points.txt,sha256=eC2ol2gqS2q5E-ktkMrBSvV0tckGUcNGS-c4hEQ-_V4,45
|
8
|
-
mystmd-1.3.10.dist-info/licenses/LICENSE,sha256=4BcikqvulW5nh_MxaocO-lC7ydIX23dMbcqtNTUSxr4,1082
|
9
|
-
mystmd-1.3.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|