Skip to content

Commit

Permalink
Merge pull request #389 from blink1073/update-packaging
Browse files Browse the repository at this point in the history
Clean up packaging and add py312 support
  • Loading branch information
blink1073 authored Jan 16, 2024
2 parents d455f4e + 70302e0 commit b4f4fa6
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 252 deletions.
53 changes: 8 additions & 45 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,8 @@ on:
- main

jobs:
check_duplicate_runs:
name: Check for duplicate runs
continue-on-error: true
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: always
cancel_others: true
skip_after_successful_duplicate: true
paths_ignore: '["**/README.md", "**/CHANGELOG.md", "**/LICENSE.md"]'
do_not_skip: '["pull_request"]'

tests:
name: Run tests (Python ${{matrix.python}})
needs: check_duplicate_runs
if: ${{ needs.check_duplicate_runs.outputs.should_skip != 'true' }}

strategy:
matrix:
Expand All @@ -35,48 +17,29 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}
restore-keys: |
${{ runner.os }}-python-${{ matrix.python }}-pip-${{ hashFiles('**/requirements*.txt') }}
${{ runner.os }}-python-${{ matrix.python }}-pip-
${{ runner.os }}-python
${{ runner.os }}-
- name: Checkout
uses: actions/checkout@v4

- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: |
pip install --upgrade -r requirements.txt -r requirements-test.txt
pip install -e .
pip freeze
- name: Show help
run: jupyter kernelgateway --help

- name: Run tests
run: pytest -vv -W default --cov kernel_gateway --cov-branch --cov-report term-missing:skip-covered
run: hatch run cov:test
env:
ASYNC_TEST_TIMEOUT: 10

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Build docs
run: hatch run docs:build
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ repos:
rev: v4.4.0
hooks:
- id: end-of-file-fixer

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
81 changes: 0 additions & 81 deletions Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions codecov.yml

This file was deleted.

6 changes: 4 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"myst_parser"
]

myst_enable_extensions = ["attrs_block", "attrs_inline"]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down Expand Up @@ -71,7 +73,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down Expand Up @@ -362,7 +364,7 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3/': None}
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}

# Read The Docs
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
Expand Down
2 changes: 2 additions & 0 deletions docs/source/http-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The `REQUEST` object currently contains the following properties:
* `path` - An object of key-value pairs representing path parameters and their values.
* `headers` - An object of key-value pairs where a key is a HTTP header name and a value is the HTTP header value. If there are multiple values are specified for a header, the value will be an array.

{#request-content-type-and-request-body-processing}

### Request Content-Type and Request Body Processing

If the HTTP request to the kernel gateway has a `Content-Type` header the value of `REQUEST.body` may change. Below is the list of outcomes for various mime-types:
Expand Down
15 changes: 13 additions & 2 deletions kernel_gateway/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

version_info = (2, 6, 0, 'dev0')
import re
from typing import List

__version__ = '.'.join(map(str, version_info))
# Version string must appear intact for automatic versioning
__version__ = "2.6.0.dev0"

# Build up version_info tuple for backwards compatibility
pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)"
match = re.match(pattern, __version__)
assert match is not None
parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]]
if match["rest"]:
parts.append(match["rest"])
version_info = tuple(parts)
3 changes: 1 addition & 2 deletions kernel_gateway/gatewayapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import ssl
import threading
from base64 import encodebytes
from distutils.util import strtobool

import nbformat
from jupyter_server.services.kernels.kernelmanager import MappingKernelManager
Expand Down Expand Up @@ -189,7 +188,7 @@ def expose_headers_default(self):
)
@default('trust_xheaders')
def trust_xheaders_default(self):
return strtobool(os.getenv(self.trust_xheaders_env, 'False'))
return os.getenv(self.trust_xheaders_env, 'False').lower() == 'true'


max_age_env = 'KG_MAX_AGE'
Expand Down
90 changes: 90 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
[build-system]
requires = ["hatchling>=1.5"]
build-backend = "hatchling.build"

[project]
name = "jupyter-kernel-gateway"
dynamic = ["version"]
description = "A web server for spawning and communicating with Jupyter kernels"
readme = "README.md"
license = { file = "LICENSE.md" }
requires-python = ">=3.8"
authors = [
{ name = "Jupyter Development Team", email = "[email protected]" },
]
keywords = [
"Cloud",
"Interactive",
"Interpreter",
"Kernel",
"Web",
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dependencies = [
"jupyter_client>=7.4.4",
"jupyter_core>=4.12,!=5.0.*",
"jupyter_server>=2.0",
"requests>=2.7,<3.0",
"tornado>=6.2.0",
"traitlets>=5.6.0",
]

[project.scripts]
jupyter-kernelgateway = "kernel_gateway:launch_instance"

[project.urls]
Homepage = "http://github.com/jupyter-incubator/kernel_gateway"

[project.optional-dependencies]
test = [
"coverage",
"pytest",
"pytest-cov",
"pytest_jupyter",
"pytest-timeout",
"ipykernel",
]
docs = [
"sphinx_rtd_theme",
"sphinx",
"myst-parser",
]

[tool.hatch.version]
path = "kernel_gateway/_version.py"

[tool.hatch.build.targets.sdist]
include = [
"/kernel_gateway",
]

[tool.hatch.build.targets.wheel]
packages = ["kernel_gateway"]

[tool.hatch.envs.docs]
features = ["docs"]
[tool.hatch.envs.docs.scripts]
build = "make -C docs html SPHINXOPTS='-W'"

[tool.hatch.envs.test]
features = ["test"]
[tool.hatch.envs.test.scripts]
test = "python -m pytest -vv {args}"

[tool.hatch.envs.cov]
features = ["test"]
dependencies = ["coverage[toml]", "pytest-cov"]
[tool.hatch.envs.cov.scripts]
test = "python -m pytest -vv --cov kernel_gateway --cov-branch --cov-report term-missing:skip-covered {args}"
3 changes: 0 additions & 3 deletions requirements-doc.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements-test.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit b4f4fa6

Please sign in to comment.