Skip to content

Commit 1021684

Browse files
authored
Revert "Write our own minimum copy of npm in Python to remove dependency on Node.js during installation"
1 parent 35530a7 commit 1021684

File tree

4 files changed

+35
-76
lines changed

4 files changed

+35
-76
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Read this if you want to build a local version.
7474
- rust
7575
- python3.8 or later with header files (python3-dev)
7676
- spidermonkey latest from mozilla-central
77+
- npm (nodejs)
7778
- [Poetry](https://python-poetry.org/docs/#installation)
7879
- [poetry-dynamic-versioning](https://github.com/mtkennerly/poetry-dynamic-versioning)
7980

python/pminit/pmpm.py

Lines changed: 0 additions & 67 deletions
This file was deleted.

python/pminit/post-install-hook.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
1-
import os
2-
import pmpm
1+
import subprocess
2+
import sys
3+
import shutil
34

4-
WORK_DIR = os.path.join(
5-
os.path.realpath(os.path.dirname(__file__)),
6-
"pythonmonkey"
7-
)
5+
def execute(cmd: str):
6+
popen = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,
7+
shell = True, text = True )
8+
for stdout_line in iter(popen.stdout.readline, ""):
9+
sys.stdout.write(stdout_line)
10+
sys.stdout.flush()
11+
12+
popen.stdout.close()
13+
return_code = popen.wait()
14+
if return_code:
15+
raise subprocess.CalledProcessError(return_code, cmd)
816

917
def main():
10-
pmpm.main(WORK_DIR) # cd pythonmonkey && npm i
18+
node_package_manager = 'npm'
19+
# check if npm is installed on the system
20+
if (shutil.which(node_package_manager) is None):
21+
print("""
22+
23+
PythonMonkey Build Error:
24+
25+
26+
* It appears npm is not installed on this system.
27+
* npm is required for PythonMonkey to build.
28+
* Please install NPM and Node.js before installing PythonMonkey.
29+
* Refer to the documentation for installing NPM and Node.js here: https://nodejs.org/en/download
30+
31+
32+
""")
33+
raise Exception("PythonMonkey build error: Unable to find npm on the system.")
34+
else:
35+
execute(f"cd pythonmonkey && {node_package_manager} i --no-package-lock") # do not update package-lock.json
1136

1237
if __name__ == "__main__":
13-
main()
38+
main()
39+

python/pminit/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ documentation = "https://docs.pythonmonkey.io/"
1111
repository = "https://github.com/Distributive-Network/PythonMonkey"
1212

1313
include = [
14-
"pmpm.py",
1514
# Install extra files into the pythonmonkey package
1615
"pythonmonkey/package*.json",
1716
{ path = "pythonmonkey/node_modules/**/*", format = "wheel" },

0 commit comments

Comments
 (0)