Skip to content

Commit c49ae10

Browse files
bollwyvlkrassowski
authored andcommitted
Add azure pipelines, remove python-jsonrpc-server (#58)
* re-add azure, make r conditional (for travis) * update conda before creating env * add pytest-timeout for cleaner exits on windows * fix env name * add -y to conda install * try cargo-culting win line ending fix from unmerged upstream pr * add r channel * need r? * linting * some more cover skipping * wait even longer * try without posix path * try string * get rid of r channel * add some debugging * add some debugging * more debugging * try non-blocking * add a little waiting * clean up * rewrite jsonrpc streams * back to tornado queues * close streams * sleep in test * don't worry about canceling sleep * coverage * clean up text handling * 3.8 doesn't seem to fail on a canceled sleep
1 parent 175310d commit c49ae10

File tree

16 files changed

+362
-131
lines changed

16 files changed

+362
-131
lines changed

azure-pipelines.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
trigger:
2+
batch: true
3+
branches:
4+
include:
5+
- master
6+
- refs/tags/v*
7+
8+
pr:
9+
- master
10+
11+
variables:
12+
PYTHONUNBUFFERED: 1
13+
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
14+
JLSP_VERSION: 0.5.0
15+
16+
jobs:
17+
- template: ci/job.test.yml

ci/env-test.yml.in

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: jupyterlab-lsp
2+
3+
channels:
4+
- conda-forge
5+
- defaults
6+
7+
dependencies:
8+
# runtime dependencies
9+
- python {}
10+
- jupyterlab >=1.1,<1.2
11+
# build dependencies
12+
- nodejs
13+
# for python language server (and development)
14+
- flake8 >=3.5
15+
- python-language-server
16+
# for R language server and kernel
17+
- r
18+
- r-irkernel
19+
- r-languageserver
20+
- rpy2
21+
# test tools
22+
- pytest-asyncio
23+
- pytest-azurepipelines
24+
- pytest-cov
25+
- pytest-flake8
26+
- pytest-runner

ci/env_template.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pathlib import Path
2+
import sys
3+
4+
Path("..", "env-test.yml").write_text(
5+
Path("env-test.yml.in").read_text().format(sys.argv[1])
6+
)

ci/job.test.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
parameters:
2+
platforms:
3+
- name: Linux
4+
vmImage: ubuntu-16.04
5+
activate: source activate
6+
- name: MacOSX
7+
vmImage: macos-10.13
8+
activate: source activate
9+
- name: Windows
10+
vmImage: vs2017-win2016
11+
activate: call activate
12+
pythons:
13+
- name: ThreeSix
14+
spec: '>=3.6,<3.7.0a0'
15+
- name: ThreeSeven
16+
spec: '>=3.7,<3.8.0a0'
17+
18+
jobs:
19+
- ${{ each platform in parameters.platforms }}:
20+
- ${{ each python in parameters.pythons}}:
21+
- job: ${{ platform.name }}${{ python.name }}
22+
pool:
23+
vmImage: ${{ platform.vmImage }}
24+
steps:
25+
- ${{ if eq(platform.name, 'Linux') }}:
26+
- bash: echo "##vso[task.prependpath]$CONDA/bin"
27+
displayName: conda $PATH
28+
29+
- ${{ if eq(platform.name, 'MacOSX') }}:
30+
- bash: echo "##vso[task.prependpath]$CONDA/bin"
31+
displayName: conda $PATH
32+
33+
- bash: sudo chown -R $USER $CONDA
34+
displayName: own conda
35+
36+
- ${{ if eq(platform.name, 'Windows') }}:
37+
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
38+
displayName: conda %PATH%
39+
40+
- script: conda install -yn base -c conda-forge conda python-libarchive-c
41+
displayName: update conda
42+
43+
- script: ${{ platform.activate }} && cd ci && python env_template.py "${{ python.spec }}"
44+
displayName: update environment with python version
45+
46+
- script: conda env update -n jupyterlab-lsp --file env-test.yml --quiet
47+
displayName: update conda environment with test dependencies
48+
49+
- script: conda info && conda list -n jupyterlab-lsp
50+
displayName: list conda packages and info
51+
52+
- task: CacheBeta@0
53+
inputs:
54+
key: yarn | $(Agent.OS) | yarn.lock
55+
path: $(YARN_CACHE_FOLDER)
56+
displayName: restore cached yarn packages
57+
58+
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm
59+
displayName: install npm dependencies
60+
61+
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm build
62+
displayName: build typescript
63+
64+
- script: ${{ platform.activate }} jupyterlab-lsp && python setup.py sdist bdist_wheel
65+
displayName: build python distributions
66+
67+
- script: ${{ platform.activate }} jupyterlab-lsp && cd dist && npm pack ..
68+
displayName: build npm bundle
69+
70+
- script: ${{ platform.activate }} jupyterlab-lsp && cd dist && python -m pip install jupyter_lsp-$(JLSP_VERSION)-py3-none-any.whl --no-deps
71+
displayName: install python wheel
72+
73+
- script: ${{ platform.activate }} jupyterlab-lsp && jlpm tslint:check && jlpm test:jest
74+
displayName: run frontend unit tests
75+
76+
- script: ${{ platform.activate }} jupyterlab-lsp && jupyter serverextension list
77+
displayName: list server extensions
78+
79+
- script: ${{ platform.activate }} jupyterlab-lsp && python -m pytest --pyargs jupyter_lsp --cov jupyter_lsp --cov-report term-missing:skip-covered -p no:warnings --flake8 --cov-fail-under=100 -vv
80+
displayName: run python tests
81+
82+
- script: ${{ platform.activate }} jupyterlab-lsp && cd dist && jupyter labextension install krassowski-jupyterlab-lsp-$(JLSP_VERSION).tgz @krassowski/jupyterlab_go_to_definition
83+
displayName: build lab
84+
85+
- script: ${{ platform.activate }} jupyterlab-lsp && jupyter labextension list
86+
displayName: list labextensions

environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ dependencies:
2323
- pyls-isort
2424
- pyls-mypy
2525
# for R language server and kernel
26-
- rpy2
27-
- r-languageserver
26+
- r
2827
- r-irkernel
28+
- r-languageserver
29+
- rpy2

py_src/jupyter_lsp/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# jupyter-lsp
22

33
> a Multi-[Language Server][language-server] WebSocket proxy for your Jupyter
4-
> `notebook` or `lab` server. For Python 3.5+, powered by [python-jsonrpc-server][].
4+
> `notebook` or `lab` server. For Python 3.5+.
55
66
See the parent of this repository, [jupyterlab-lsp](../../README.md) for the
77
reference client implementation for [JupyterLab][]
@@ -36,7 +36,6 @@ Don't see an implementation for the language server you want? You can
3636

3737
[language-server]: https://microsoft.github.io/language-server-protocol/specification
3838
[jupyter-server-proxy]: https://github.com/jupyterhub/jupyter-server-proxy
39-
[python-jsonrpc-server]: https://github.com/palantir/python-jsonrpc-server
4039
[lsp-implementations]: https://microsoft.github.io/language-server-protocol/implementors/servers
4140
[jupyter-lsp]: https://github.com/krassowski/jupyterlab-lsp.git
4241
[jupyterlab]: https://github.com/jupyterlab/jupyterlab

py_src/jupyter_lsp/jsonrpc.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

py_src/jupyter_lsp/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" A configurable frontend for `python-jsonrpc-server`
1+
""" A configurable frontend for stdio-based Language Servers
22
"""
33
import typing
44

py_src/jupyter_lsp/non_blocking.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""
2+
Derived from
3+
4+
> https://github.com/rudolfwalter/pygdbmi/blob/0.7.4.2/pygdbmi/gdbcontroller.py
5+
> MIT License https://github.com/rudolfwalter/pygdbmi/blob/master/LICENSE
6+
> Copyright (c) 2016 Chad Smith <grassfedcode <at> gmail.com>
7+
"""
8+
import os
9+
10+
if os.name == "nt": # pragma: no cover
11+
import msvcrt
12+
from ctypes import windll, byref, wintypes, WinError, POINTER
13+
from ctypes.wintypes import HANDLE, DWORD, BOOL
14+
else: # pragma: no cover
15+
import fcntl
16+
17+
18+
def make_non_blocking(file_obj): # pragma: no cover
19+
"""
20+
make file object non-blocking
21+
22+
Windows doesn't have the fcntl module, but someone on
23+
stack overflow supplied this code as an answer, and it works
24+
http://stackoverflow.com/a/34504971/2893090
25+
"""
26+
27+
if os.name == "nt":
28+
LPDWORD = POINTER(DWORD)
29+
PIPE_NOWAIT = wintypes.DWORD(0x00000001)
30+
31+
SetNamedPipeHandleState = windll.kernel32.SetNamedPipeHandleState
32+
SetNamedPipeHandleState.argtypes = [HANDLE, LPDWORD, LPDWORD, LPDWORD]
33+
SetNamedPipeHandleState.restype = BOOL
34+
35+
h = msvcrt.get_osfhandle(file_obj.fileno())
36+
37+
res = windll.kernel32.SetNamedPipeHandleState(h, byref(PIPE_NOWAIT), None, None)
38+
if res == 0:
39+
raise ValueError(WinError())
40+
41+
else:
42+
# Set the file status flag (F_SETFL) on the pipes to be non-blocking
43+
# so we can attempt to read from a pipe with no new data without locking
44+
# the program up
45+
fcntl.fcntl(file_obj, fcntl.F_SETFL, os.O_NONBLOCK)

0 commit comments

Comments
 (0)