Skip to content

Commit

Permalink
kernelspec: ensure path is writable before writing kernel.json.
Browse files Browse the repository at this point in the history
  • Loading branch information
jellelicht committed Feb 18, 2021
1 parent da44c7c commit f22374a
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit f22374a

Please sign in to comment.