Skip to content

Commit 13ed70b

Browse files
authored
Fixes help, graphics in 17+, completions, misc version issues (#443)
* Manually bumped to 1.12.3 * Bump version: 1.12.3 → 1.13.0 * Fix various Stata 17+ incompatibility issues - Closes #426: Pass user-agent via header to fetch %help - Closes #428: Display graphs with Stata 17+ - Closes #420: Use 'importlib.resources' insteadof 'pkg_resources' - Autocompletions work in notebooks (empty 'metadata' field passed internally) - Tentative: Various dependency updates. * Minor linter 'fixes' * Updated changelog, bumpver to pyproject.toml * bump version 1.13.0 → 1.14.0 * Updated ubuntu version for tests * Debugging ubuntu version * Debugging python 3.10 read as 3.1 * Updated poetry version * Updated poetry version
1 parent f7be69b commit 13ed70b

File tree

18 files changed

+2112
-1070
lines changed

18 files changed

+2112
-1070
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ on:
1111

1212
jobs:
1313
tests:
14-
runs-on: ubuntu-20.04
14+
runs-on: ubuntu-24.04
1515
strategy:
1616
matrix:
17-
python-version: [3.6, 3.7, 3.8, 3.9]
17+
python-version: ['3.9', '3.10', '3.11']
1818

1919
steps:
2020
- uses: actions/checkout@v2
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Poetry
2828
uses: snok/install-poetry@v1
2929
with:
30-
version: 1.1.10
30+
version: 1.8.1
3131

3232
- name: Install dependencies
3333
run: |

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [1.14.0] - 2025-08-27
4+
5+
- %help works by passing user-agent via headers (#426).
6+
- Graphics work for Stata 17+ (#428).
7+
- Use `importlib.resources` insteadof `pkg_resources` (#420).
8+
- Autocompletions work on notebooks (pass empty 'metadata' field internally).
9+
310
## [1.12.3] - 2021-02-25
411

512
- Simplify kernel installation for conda environments

poetry.lock

Lines changed: 1963 additions & 954 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "stata_kernel"
3-
version = "1.13.0"
3+
version = "1.14.0"
44
description = "A Jupyter kernel for Stata. Works with Windows, macOS, and Linux."
55
authors = [
66
"Kyle Barron <[email protected]>",
@@ -19,38 +19,55 @@ classifiers = [
1919
'Operating System :: Microsoft :: Windows',
2020
'Operating System :: POSIX :: Linux',
2121
'Operating System :: Unix',
22-
'Programming Language :: Python :: 3.6',
23-
'Programming Language :: Python :: 3.7',
24-
'Programming Language :: Python :: 3.8',
2522
'Programming Language :: Python :: 3.9',
23+
'Programming Language :: Python :: 3.10',
24+
'Programming Language :: Python :: 3.11',
2625
]
2726
keywords = ["stata"]
2827
repository = "https://github.com/kylebarron/stata_kernel"
2928
documentation = "https://kylebarron.dev/stata_kernel/"
3029

3130
[tool.poetry.dependencies]
32-
python = "^3.6.1"
31+
python = "^3.9.0"
3332
beautifulsoup4 = "^4.6.3"
34-
pandas = "^1.0"
33+
pandas = ">=1.0"
34+
numpy = ">=1.22.0"
3535
pygments = "^2.2"
3636
pexpect = "^4.6.0"
37-
requests = "^2.19.1"
38-
jupyter-client = "^5.2.3"
39-
IPython = "^7.16.3"
40-
ipykernel = "^4.8.2"
4137
packaging = "^17.1"
4238
pillow = ">=5.2.0"
4339
pywin32 = { version = ">=223", platform = "Windows" }
40+
fake-useragent = "^2.0.0"
41+
IPython = "^7.34"
42+
ipykernel = "^4.8.2"
43+
jupyter-client = "^6.1.12"
44+
jupyter-core = "^5.8.1"
45+
notebook = "^6.5.7"
46+
nbclient = "^0.8"
47+
setuptools = "<81"
4448

4549
[tool.poetry.dev-dependencies]
4650
bumpversion = "^0.6"
4751
mkdocs-material = ">=3.0.3"
4852
mkdocs = ">=1.0"
4953
yapf = ">=0.20.2"
5054
pytest = ">=3.7.1"
51-
# importlib-metadata==0.23
52-
# jupyter_kernel_test==0.3.0
55+
jupyter_kernel_test = "0.3.0"
5356

5457
[build-system]
55-
requires = ["poetry-core>=1.1.10"]
58+
requires = ["poetry-core>=1.8.1"]
5659
build-backend = "poetry.core.masonry.api"
60+
61+
[tool.bumpver]
62+
current_version = "1.14.0"
63+
version_pattern = "MAJOR.MINOR.PATCH"
64+
commit = true
65+
tag = true
66+
commit_message = "bump version {old_version} → {new_version}"
67+
tag_message = "{new_version}"
68+
69+
[tool.bumpver.file_patterns]
70+
"setup.cfg" = ['current_version = {version}']
71+
"stata_kernel/kernel.py" = ["implementation_version = '{version}'"]
72+
"stata_kernel/__init__.py" = ["__version__ = '{version}'"]
73+
"pyproject.toml" = ['version = "{version}"']

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.13.0
2+
current_version = 1.14.0
33
commit = True
44
tag = True
55

stata_kernel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""An example Jupyter kernel"""
22

3-
__version__ = '1.13.0'
3+
__version__ = '1.14.0'

stata_kernel/docs/make_href

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from bs4 import BeautifulSoup as bs
55
import urllib
6+
import urllib.request
67
import re
78
import os
89

stata_kernel/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from shutil import copyfile
88
from pathlib import Path
99
from textwrap import dedent
10-
from pkg_resources import resource_filename
10+
from importlib.resources import files
1111
from IPython.utils.tempdir import TemporaryDirectory
1212
from jupyter_client.kernelspec import KernelSpecManager
1313

@@ -31,7 +31,7 @@ def install_my_kernel_spec(user=True, prefix=None):
3131
json.dump(kernel_json, f, sort_keys=True)
3232

3333
# Copy logo to tempdir to be installed with kernelspec
34-
logo_path = resource_filename('stata_kernel', 'docs/logo-64x64.png')
34+
logo_path = files('stata_kernel').joinpath('docs/logo-64x64.png')
3535
copyfile(logo_path, os.path.join(td, 'logo-64x64.png'))
3636

3737
print('Installing Jupyter kernel spec')

stata_kernel/kernel.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from textwrap import dedent
1111
from datetime import datetime
1212
from xml.etree import ElementTree as ET
13-
from pkg_resources import resource_filename
13+
from importlib.resources import files
1414
from ipykernel.kernelbase import Kernel
1515

1616
from .config import config
@@ -22,7 +22,7 @@
2222

2323
class StataKernel(Kernel):
2424
implementation = 'stata_kernel'
25-
implementation_version = '1.13.0'
25+
implementation_version = '1.14.0'
2626
language = 'stata'
2727
language_info = {
2828
'name': 'stata',
@@ -38,13 +38,12 @@ class StataKernel(Kernel):
3838
def __init__(self, *args, **kwargs):
3939
# Copy syntax highlighting files
4040
from_paths = [
41-
Path(resource_filename('stata_kernel', 'pygments/stata.py')),
42-
Path(resource_filename('stata_kernel', 'codemirror/stata.js'))]
41+
Path(files('stata_kernel').joinpath('pygments/stata.py')),
42+
Path(files('stata_kernel').joinpath('codemirror/stata.js'))]
4343
to_paths = [
44-
Path(resource_filename('pygments', 'lexers/stata.py')),
44+
Path(files('pygments').joinpath('lexers/stata.py')),
4545
Path(
46-
resource_filename(
47-
'notebook',
46+
files('notebook').joinpath(
4847
'static/components/codemirror/mode/stata/stata.js'))]
4948

5049
for from_path, to_path in zip(from_paths, to_paths):
@@ -355,6 +354,7 @@ def do_complete(self, code, cursor_pos):
355354
self.sc_delimit_mode, self.stata.mata_mode)
356355

357356
return {
357+
'metadata': {},
358358
'status': 'ok',
359359
'cursor_start': pos,
360360
'cursor_end': cursor_pos,
@@ -400,7 +400,7 @@ def cleanTail(self, tail, rprompt):
400400
fh.seek(pos + 1, os.SEEK_SET)
401401
fh.truncate()
402402

403-
def do_inspect(self, code, cursor_pos, detail_level=0):
403+
def do_inspect(self, code, cursor_pos, detail_level=0, metadata={}):
404404
inspect_keyword = re.compile(
405405
r'\b(?P<keyword>\w+)\(?\s*$', flags=re.MULTILINE).search
406406

@@ -445,6 +445,6 @@ def do_inspect(self, code, cursor_pos, detail_level=0):
445445
'found': found,
446446
# data can be empty if nothing is found
447447
'data': data,
448-
'metadata': {}}
448+
'metadata': metadata}
449449

450450
return content

stata_kernel/pygments/stata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ class StataLexer(RegexLexer):
143143
],
144144
# Built in functions and statements
145145
'keywords': [
146-
(words(builtins_functions, prefix = r'\b', suffix = r'(?=\()'),
146+
(words(builtins_functions, prefix=r'\b', suffix=r'(?=\()'),
147147
Name.Function),
148-
(words(builtins_base, prefix = r'(^\s*|\s)', suffix = r'\b'),
148+
(words(builtins_base, prefix=r'(^\s*|\s)', suffix=r'\b'),
149149
Keyword),
150150
],
151151
# http://www.stata.com/help.cgi?operators

0 commit comments

Comments
 (0)