Skip to content

Commit

Permalink
Clean up packaging and add py312 support
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Jan 16, 2024
1 parent d455f4e commit 3c8c5d4
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 203 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- "3.9"
- "3.10"
- "3.11"
- "3.12"

runs-on: ubuntu-latest

Expand All @@ -58,23 +59,22 @@ jobs:
${{ runner.os }}-python
${{ runner.os }}-
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools wheel

- name: Install dependencies
run: |
pip install --upgrade -r requirements.txt -r requirements-test.txt
pip install -e .
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: Build docs
run: hatch run docs:build

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
81 changes: 0 additions & 81 deletions Makefile

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
87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[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 = "BSD"
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.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.

91 changes: 1 addition & 90 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,2 @@
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.

import os
import sys
from setuptools import setup

here = os.path.abspath(os.path.dirname(__file__))

version_ns = {}
with open(os.path.join(here, 'kernel_gateway', '_version.py')) as f:
exec(f.read(), {}, version_ns)

setup_args = dict(
name='jupyter_kernel_gateway',
author='Jupyter Development Team',
author_email='[email protected]',
url='http://github.com/jupyter-incubator/kernel_gateway',
description='A web server for spawning and communicating with Jupyter kernels',
long_description='''\
Jupyter Kernel Gateway is a web server that supports different mechanisms for
spawning and communicating with Jupyter kernels, such as:
* A Jupyter Notebook server-compatible HTTP API used for requesting kernels
and talking the `Jupyter kernel protocol <https://jupyter-client.readthedocs.io/en/latest/messaging.html>`_
with the kernels over Websockets
* A HTTP API defined by annotated notebook cells that maps HTTP verbs and
resources to code to execute on a kernel
The server launches kernels in its local process/filesystem space. It can be
containerized and scaled out using common technologies like
`tmpnb <https://github.com/jupyter/tmpnb>`_,
`Cloud Foundry <https://github.com/cloudfoundry>`_, and
`Kubernetes <http://kubernetes.io/>`_.
''',
version=version_ns['__version__'],
license='BSD',
platforms="Linux, Mac OS X, Windows",
keywords=['Interactive', 'Interpreter', 'Kernel', 'Web', 'Cloud'],
packages=[
'kernel_gateway',
'kernel_gateway.base',
'kernel_gateway.jupyter_websocket',
'kernel_gateway.notebook_http',
'kernel_gateway.notebook_http.cell',
'kernel_gateway.notebook_http.swagger',
'kernel_gateway.services',
'kernel_gateway.services.kernels',
'kernel_gateway.services.kernelspecs',
'kernel_gateway.services.sessions',
],
scripts=[
'scripts/jupyter-kernelgateway'
],
install_requires=[
'jupyter_client>=7.4.4',
'jupyter_core>=4.12,!=5.0.*',
'jupyter_server>=2.0',
'traitlets>=5.6.0',
'tornado>=6.2.0',
'requests>=2.7,<3.0'
],
python_requires='>=3.8',
classifiers=[
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Intended Audience :: Science/Research',
'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',
],
include_package_data=True,
)

if 'setuptools' in sys.modules:
# setupstools turns entrypoint scripts into executables on windows
setup_args['entry_points'] = {
'console_scripts': [
'jupyter-kernelgateway = kernel_gateway:launch_instance'
]
}
# Don't bother installing the .py scripts if if we're using entrypoints
setup_args.pop('scripts', None)

if __name__ == '__main__':
setup(**setup_args)
setup()

0 comments on commit 3c8c5d4

Please sign in to comment.