Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a jlpm "bootstrap" entrypoint that can run during eg pip install of jupyterlab #105

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ ENV/

# Rope project settings
.ropeproject

# ms IDE stuff
*.code-workspace
.history
.vscode
43 changes: 43 additions & 0 deletions jupyter_packaging/jlpmapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# coding: utf-8
"""A Jupyter-aware wrapper for the yarn package manager"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import sys

import os
from jupyterlab_server.process import which, subprocess

HERE = os.path.dirname(os.path.abspath(__file__))
YARN_PATH = os.path.join(HERE, 'yarn.js')


def execvp(cmd, argv):
"""Execvp, except on Windows where it uses Popen.

The first argument, by convention, should point to the filename
associated with the file being executed.

Python provides execvp on Windows, but its behavior is problematic
(Python bug#9148).
"""
cmd = which(cmd)
if os.name == 'nt':
import signal
import sys
p = subprocess.Popen([cmd] + argv[1:])
# Don't raise KeyboardInterrupt in the parent process.
# Set this after spawning, to avoid subprocess inheriting handler.
signal.signal(signal.SIGINT, signal.SIG_IGN)
p.wait()
sys.exit(p.returncode)
else:
os.execvp(cmd, argv)


def main(argv=None):
"""Run node and return the result.
"""
# Make sure node is available.
argv = argv or sys.argv[1:]
execvp('node', ['node', YARN_PATH] + argv)
Loading