Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion python/pminit/post-install-hook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import subprocess
import sys
import shutil

def execute(cmd: str):
popen = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT,
Expand All @@ -14,7 +15,25 @@ def execute(cmd: str):
raise subprocess.CalledProcessError(return_code, cmd)

def main():
execute("cd pythonmonkey && npm i --no-package-lock") # do not update package-lock.json
node_package_manager = 'npm'
# check if npm is installed on the system
if (shutil.which(node_package_manager) is None):
print("""

PythonMonkey Build Error:


* It appears npm is not installed on this system.
* npm is required for PythonMonkey to build.
* Please install NPM and Node.js before installing PythonMonkey.
* Refer to the documentation for installing NPM and Node.js here: https://nodejs.org/en/download


""")
raise Exception("PythonMonkey build error: Unable to find npm on the system.")
else:
execute(f"cd pythonmonkey && {node_package_manager} i --no-package-lock") # do not update package-lock.json

if __name__ == "__main__":
main()