CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
73 lines
2.0 KiB
Python
73 lines
2.0 KiB
Python
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
import os
|
|
import json
|
|
import sys
|
|
import argparse
|
|
from tempfile import TemporaryDirectory
|
|
from jupyter_client.kernelspec import KernelSpecManager
|
|
|
|
|
|
def install_my_kernel_spec(user=True, prefix=None):
|
|
"""Install the kernel spec for user in given prefix."""
|
|
print("Installing llvm-tblgen IPython kernel spec")
|
|
|
|
kernel_json = {
|
|
"argv": [
|
|
sys.executable, "-m", "tablegen_kernel", "-f", "{connection_file}"
|
|
],
|
|
"display_name": "LLVM TableGen",
|
|
"language": "tablegen",
|
|
"language_info": {
|
|
"name": "tablegen",
|
|
"codemirror_mode": "tablegen",
|
|
"mimetype": "text/x-tablegen",
|
|
"file_extension": ".td",
|
|
"pygments_lexer": "text"
|
|
}
|
|
}
|
|
|
|
with TemporaryDirectory() as tmpdir:
|
|
json_path = os.path.join(tmpdir, "kernel.json")
|
|
with open(json_path, 'w') as json_file:
|
|
json.dump(kernel_json, json_file)
|
|
KernelSpecManager().install_kernel_spec(
|
|
tmpdir, "tablegen", user=user, prefix=prefix
|
|
)
|
|
|
|
|
|
def _is_root():
|
|
"""Returns whether the current user is root."""
|
|
try:
|
|
return os.geteuid() == 0
|
|
except AttributeError:
|
|
# Return false wherever unknown.
|
|
return False
|
|
|
|
|
|
def main(argv=None):
|
|
parser = argparse.ArgumentParser(
|
|
description="Install KernelSpec for LLVM TableGen Kernel"
|
|
)
|
|
prefix_locations = parser.add_mutually_exclusive_group()
|
|
|
|
prefix_locations.add_argument(
|
|
"--user", help="Install in user home directory", action="store_true"
|
|
)
|
|
prefix_locations.add_argument(
|
|
"--prefix", help="Install directory prefix", default=None
|
|
)
|
|
|
|
args = parser.parse_args(argv)
|
|
|
|
user = args.user or not _is_root()
|
|
prefix = args.prefix
|
|
|
|
install_my_kernel_spec(user=user, prefix=prefix)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|