Skip to content

Commit

Permalink
Remove install.py and cleanup (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Mar 2, 2024
1 parent b483ceb commit 6e880d7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 70 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
include:
- os: windows-latest
python-version: "3.9"
python-version: "3.10"
- os: ubuntu-latest
python-version: "pypy-3.8"
python-version: "pypy-3.9"
- os: macos-latest
python-version: "3.10"
python-version: "3.11"
steps:
- uses: actions/checkout@v2
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
Expand All @@ -44,9 +44,6 @@ jobs:
run: |
cd $HOME
jupyter kernelspec list | grep echo
jupyter kernelspec remove -y echo
python -m echo_kernel.install
jupyter kernelspec list | grep echo
check_release:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changes in jupyter-core
# Changes in echo kernel

<!-- <START NEW CHANGELOG ENTRY> -->

Expand Down
59 changes: 0 additions & 59 deletions echo_kernel/install.py

This file was deleted.

33 changes: 30 additions & 3 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,40 @@
from hatchling.builders.hooks.plugin.interface import BuildHookInterface


import argparse
import json
import os
import sys
import shutil

from jupyter_client.kernelspec import KernelSpecManager
from tempfile import TemporaryDirectory

kernel_json = {
"argv": [sys.executable, "-m", "echo_kernel", "-f", "{connection_file}"],
"display_name": "Echo",
"language": "text",
}

class CustomHook(BuildHookInterface):
def initialize(self, version, build_data):
here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, here)
prefix = os.path.join(here, 'data_kernelspec')

from echo_kernel.install import install_my_kernel_spec
with TemporaryDirectory() as td:
os.chmod(td, 0o755) # Starts off as 700, not user readable
with open(os.path.join(td, 'kernel.json'), 'w') as f:
json.dump(kernel_json, f, sort_keys=True)
print('Installing Jupyter kernel spec')

prefix = os.path.join(here, 'data_kernelspec')
install_my_kernel_spec(False, prefix)
# Requires logo files in kernel root directory
cur_path = os.path.dirname(os.path.realpath(__file__))
for logo in ["logo-32x32.png", "logo-64x64.png"]:
try:
shutil.copy(os.path.join(cur_path, logo), td)
except FileNotFoundError:
print("Custom logo files not found. Default logos will be used.")

KernelSpecManager().install_kernel_spec(td, 'echo', user=False, prefix=prefix)

0 comments on commit 6e880d7

Please sign in to comment.