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

kernelspec: ensure path is writable before writing kernel.json. #593

Merged
merged 1 commit into from
Feb 18, 2021
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
kernelspec: ensure path is writable before writing kernel.json.
  • Loading branch information
jellelicht committed Feb 18, 2021
commit c9102ddeb55bd4f39d3b6c8499a3f1a8353edec9
7 changes: 7 additions & 0 deletions ipykernel/kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import shutil
import stat
import sys
import tempfile

Expand Down Expand Up @@ -70,6 +71,12 @@ def write_kernel_spec(path=None, overrides=None, extra_arguments=None):

# stage resources
shutil.copytree(RESOURCES, path)

# ensure path is writable
mask = os.stat(path).st_mode
if not mask & stat.S_IWUSR:
os.chmod(path, mask | stat.S_IWUSR)

# write kernel.json
kernel_dict = get_kernel_dict(extra_arguments)

Expand Down