jupyter-opensysml-kernel 0.9.3.dev20261008__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jupyter_opensysml_kernel-0.9.3.dev20261008/LICENSE +202 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/PKG-INFO +129 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/README.md +95 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/__init__.py +14 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/__main__.py +168 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/_version.py +8 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/binary.py +316 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/kernelspec.py +212 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/logo-32x32.png +0 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/logo-64x64.png +0 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/py.typed +0 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel/release-digests.json +165 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/PKG-INFO +129 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/SOURCES.txt +23 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/dependency_links.txt +1 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/entry_points.txt +2 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/requires.txt +5 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/jupyter_opensysml_kernel.egg-info/top_level.txt +1 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/pyproject.toml +79 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/setup.cfg +4 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/setup.py +100 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/tests/test_binary.py +122 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/tests/test_kernelspec.py +152 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/tests/test_launch.py +180 -0
- jupyter_opensysml_kernel-0.9.3.dev20261008/tests/test_wheel.py +166 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Open-MBEE
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jupyter-opensysml-kernel
|
|
3
|
+
Version: 0.9.3.dev20261008
|
|
4
|
+
Summary: Jupyter kernel for SysML v2, backed by the OpenSysML REPL
|
|
5
|
+
Author: Open-MBEE
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/Open-MBEE/OpenSysML
|
|
8
|
+
Project-URL: Repository, https://github.com/Open-MBEE/OpenSysML
|
|
9
|
+
Project-URL: Documentation, https://opensysml.org/guide/12-jupyter/
|
|
10
|
+
Project-URL: Changelog, https://github.com/Open-MBEE/OpenSysML/blob/main/CHANGELOG.md
|
|
11
|
+
Project-URL: Issues, https://github.com/Open-MBEE/OpenSysML/issues
|
|
12
|
+
Keywords: jupyter,kernel,sysml,sysmlv2,kerml,mbse,systems-engineering
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Framework :: Jupyter
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: Operating System :: MacOS
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: jupyter_client>=7.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# jupyter-opensysml-kernel
|
|
36
|
+
|
|
37
|
+
A [Jupyter](https://jupyter.org) kernel for SysML v2, backed by the
|
|
38
|
+
[OpenSysML](https://github.com/Open-MBEE/OpenSysML) REPL. A notebook cell is a
|
|
39
|
+
REPL submission: declarations accumulate into one model across cells, a bare
|
|
40
|
+
expression is evaluated, and every `%` command of the `sysml` REPL — `%eval`,
|
|
41
|
+
`%instantiate`, `%action`, `%render`, `%render-document`, `%load`, … — works as
|
|
42
|
+
it does at the prompt. Views render as Mermaid, Graphviz (SVG), Markdown, CSV
|
|
43
|
+
and JSON; documents as Markdown and HTML.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
Python 3.10 or later and a Jupyter front end (JupyterLab, Notebook, VS Code,
|
|
48
|
+
`nbconvert`, …) are required.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install jupyter-opensysml-kernel
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The wheel for your platform (Linux x64 and arm64, macOS Intel and Apple
|
|
55
|
+
Silicon, Windows x64) bundles the `sysml-jupyter-kernel` binary of the OpenSysML
|
|
56
|
+
release this package was built for and registers the `sysml` kernelspec under
|
|
57
|
+
the Python environment it is installed into, so that is the whole install:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
jupyter kernelspec list # shows: sysml …/share/jupyter/kernels/sysml
|
|
61
|
+
jupyter lab # pick "SysML v2 (OpenSysML)"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Install with the Python that runs your notebook server (or in its environment);
|
|
65
|
+
`pip uninstall` removes the kernel and its kernelspec together.
|
|
66
|
+
|
|
67
|
+
Where no wheel applies, `pip` installs the sdist, which bundles no binary. Then
|
|
68
|
+
one more command downloads the release's binary, verifies it against the SHA-256
|
|
69
|
+
digest the package ships for that release, and registers the kernelspec with the
|
|
70
|
+
binary inside it:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m jupyter_opensysml_kernel install
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Nothing unverified is installed: a download that does not hash to the pinned
|
|
77
|
+
digest is refused, and so is a release the package pins no digest for. The same
|
|
78
|
+
command registers the kernel for the user (`--user`) or under another prefix
|
|
79
|
+
(`--prefix DIR`, `--system`) when the notebook server does not run in the
|
|
80
|
+
environment the package is in, copying the bundled binary when there is one. To
|
|
81
|
+
use a kernel built from source (`go build ./cmd/sysml-jupyter-kernel`) or
|
|
82
|
+
installed another way, pass it explicitly:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python -m jupyter_opensysml_kernel install --binary ./sysml-jupyter-kernel
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`python -m jupyter_opensysml_kernel uninstall` removes a kernelspec `install`
|
|
89
|
+
wrote and the binary in it; `jupyter kernelspec remove sysml` does the same.
|
|
90
|
+
|
|
91
|
+
The conda-forge recipe for this package is kept in the OpenSysML repository
|
|
92
|
+
under `packaging/conda`; once it is accepted there,
|
|
93
|
+
`conda install -c conda-forge jupyter-opensysml-kernel` installs the kernel and
|
|
94
|
+
its kernelspec into the environment directly. Until then, `pip install` inside
|
|
95
|
+
the conda environment registers the kernel under that environment's prefix the
|
|
96
|
+
same way.
|
|
97
|
+
|
|
98
|
+
A development snapshot of this package is published every night as
|
|
99
|
+
`jupyter-opensysml-kernel==<next release>.dev<yyyymmdd>`, which `pip install`
|
|
100
|
+
never picks up on its own; it carries the kernel of the same night's snapshot.
|
|
101
|
+
|
|
102
|
+
## Documentation
|
|
103
|
+
|
|
104
|
+
- [Using SysML in Jupyter](https://opensysml.org/guide/12-jupyter/) — the guide
|
|
105
|
+
chapter: cells, `%` commands, rich output, interrupts.
|
|
106
|
+
- [REPL commands](https://opensysml.org/reference/repl-commands/) — every `%`
|
|
107
|
+
command the kernel serves.
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
pip install -e '.[dev]'
|
|
113
|
+
pytest
|
|
114
|
+
mypy jupyter_opensysml_kernel
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The tests need no network: downloads are served from fixtures, and the wheel
|
|
118
|
+
tests build from a staged stand-in binary (`python -m build` is required). The
|
|
119
|
+
package's copy of `release-digests.json` is synced from
|
|
120
|
+
`client/release-digests.json` by `scripts/sync-release-digests.py`; the release
|
|
121
|
+
pipeline stamps the digests of the kernel binaries it built into the copy, then
|
|
122
|
+
`scripts/build-jupyter-kernel-dist.sh` builds the sdist and, with each binary
|
|
123
|
+
staged under `jupyter_opensysml_kernel/bin/` and
|
|
124
|
+
`JUPYTER_OPENSYSML_KERNEL_PLATFORM=<goos>-<goarch>` set, one wheel per platform
|
|
125
|
+
(`setup.py` tags the wheel and adds the kernelspec as shared data).
|
|
126
|
+
|
|
127
|
+
## License
|
|
128
|
+
|
|
129
|
+
Apache-2.0.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# jupyter-opensysml-kernel
|
|
2
|
+
|
|
3
|
+
A [Jupyter](https://jupyter.org) kernel for SysML v2, backed by the
|
|
4
|
+
[OpenSysML](https://github.com/Open-MBEE/OpenSysML) REPL. A notebook cell is a
|
|
5
|
+
REPL submission: declarations accumulate into one model across cells, a bare
|
|
6
|
+
expression is evaluated, and every `%` command of the `sysml` REPL — `%eval`,
|
|
7
|
+
`%instantiate`, `%action`, `%render`, `%render-document`, `%load`, … — works as
|
|
8
|
+
it does at the prompt. Views render as Mermaid, Graphviz (SVG), Markdown, CSV
|
|
9
|
+
and JSON; documents as Markdown and HTML.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Python 3.10 or later and a Jupyter front end (JupyterLab, Notebook, VS Code,
|
|
14
|
+
`nbconvert`, …) are required.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install jupyter-opensysml-kernel
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The wheel for your platform (Linux x64 and arm64, macOS Intel and Apple
|
|
21
|
+
Silicon, Windows x64) bundles the `sysml-jupyter-kernel` binary of the OpenSysML
|
|
22
|
+
release this package was built for and registers the `sysml` kernelspec under
|
|
23
|
+
the Python environment it is installed into, so that is the whole install:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
jupyter kernelspec list # shows: sysml …/share/jupyter/kernels/sysml
|
|
27
|
+
jupyter lab # pick "SysML v2 (OpenSysML)"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Install with the Python that runs your notebook server (or in its environment);
|
|
31
|
+
`pip uninstall` removes the kernel and its kernelspec together.
|
|
32
|
+
|
|
33
|
+
Where no wheel applies, `pip` installs the sdist, which bundles no binary. Then
|
|
34
|
+
one more command downloads the release's binary, verifies it against the SHA-256
|
|
35
|
+
digest the package ships for that release, and registers the kernelspec with the
|
|
36
|
+
binary inside it:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
python -m jupyter_opensysml_kernel install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Nothing unverified is installed: a download that does not hash to the pinned
|
|
43
|
+
digest is refused, and so is a release the package pins no digest for. The same
|
|
44
|
+
command registers the kernel for the user (`--user`) or under another prefix
|
|
45
|
+
(`--prefix DIR`, `--system`) when the notebook server does not run in the
|
|
46
|
+
environment the package is in, copying the bundled binary when there is one. To
|
|
47
|
+
use a kernel built from source (`go build ./cmd/sysml-jupyter-kernel`) or
|
|
48
|
+
installed another way, pass it explicitly:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m jupyter_opensysml_kernel install --binary ./sysml-jupyter-kernel
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`python -m jupyter_opensysml_kernel uninstall` removes a kernelspec `install`
|
|
55
|
+
wrote and the binary in it; `jupyter kernelspec remove sysml` does the same.
|
|
56
|
+
|
|
57
|
+
The conda-forge recipe for this package is kept in the OpenSysML repository
|
|
58
|
+
under `packaging/conda`; once it is accepted there,
|
|
59
|
+
`conda install -c conda-forge jupyter-opensysml-kernel` installs the kernel and
|
|
60
|
+
its kernelspec into the environment directly. Until then, `pip install` inside
|
|
61
|
+
the conda environment registers the kernel under that environment's prefix the
|
|
62
|
+
same way.
|
|
63
|
+
|
|
64
|
+
A development snapshot of this package is published every night as
|
|
65
|
+
`jupyter-opensysml-kernel==<next release>.dev<yyyymmdd>`, which `pip install`
|
|
66
|
+
never picks up on its own; it carries the kernel of the same night's snapshot.
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
- [Using SysML in Jupyter](https://opensysml.org/guide/12-jupyter/) — the guide
|
|
71
|
+
chapter: cells, `%` commands, rich output, interrupts.
|
|
72
|
+
- [REPL commands](https://opensysml.org/reference/repl-commands/) — every `%`
|
|
73
|
+
command the kernel serves.
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install -e '.[dev]'
|
|
79
|
+
pytest
|
|
80
|
+
mypy jupyter_opensysml_kernel
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The tests need no network: downloads are served from fixtures, and the wheel
|
|
84
|
+
tests build from a staged stand-in binary (`python -m build` is required). The
|
|
85
|
+
package's copy of `release-digests.json` is synced from
|
|
86
|
+
`client/release-digests.json` by `scripts/sync-release-digests.py`; the release
|
|
87
|
+
pipeline stamps the digests of the kernel binaries it built into the copy, then
|
|
88
|
+
`scripts/build-jupyter-kernel-dist.sh` builds the sdist and, with each binary
|
|
89
|
+
staged under `jupyter_opensysml_kernel/bin/` and
|
|
90
|
+
`JUPYTER_OPENSYSML_KERNEL_PLATFORM=<goos>-<goarch>` set, one wheel per platform
|
|
91
|
+
(`setup.py` tags the wheel and adds the kernelspec as shared data).
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""Jupyter kernel for SysML v2, backed by the OpenSysML REPL.
|
|
2
|
+
|
|
3
|
+
The kernel itself is the `sysml-jupyter-kernel` binary every OpenSysML release
|
|
4
|
+
publishes. A platform wheel of this package bundles the build for its machine
|
|
5
|
+
and registers it as the `sysml` kernelspec when it is installed. An install
|
|
6
|
+
from the sdist, or on another platform, downloads the build for the machine,
|
|
7
|
+
verifies it against the digest pinned here for that release, and registers it::
|
|
8
|
+
|
|
9
|
+
python -m jupyter_opensysml_kernel install
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from ._version import VERSION as __version__
|
|
13
|
+
|
|
14
|
+
__all__ = ["__version__"]
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""`python -m jupyter_opensysml_kernel`: start the bundled kernel, or install or remove the kernelspec.
|
|
2
|
+
|
|
3
|
+
Given the kernel's own flags (`-connection-file FILE`, the form the kernelspec a
|
|
4
|
+
platform wheel installs uses), the bundled `sysml-jupyter-kernel` is started
|
|
5
|
+
with them; given a subcommand, the kernelspec is managed.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import stat
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
from collections.abc import Sequence
|
|
17
|
+
|
|
18
|
+
from . import kernelspec
|
|
19
|
+
from ._version import VERSION
|
|
20
|
+
from .binary import BINARY_MODE, KernelBinaryError, binary_name, bundled_binary
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
24
|
+
parser = argparse.ArgumentParser(
|
|
25
|
+
prog="jupyter-opensysml-kernel",
|
|
26
|
+
description="Install the SysML v2 (OpenSysML) Jupyter kernel.",
|
|
27
|
+
epilog="Kernel flags (-connection-file FILE, -version, ...) start the kernel bundled in this package.",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument("--version", action="version", version=f"%(prog)s {VERSION}")
|
|
30
|
+
commands = parser.add_subparsers(dest="command", required=True)
|
|
31
|
+
|
|
32
|
+
install = commands.add_parser(
|
|
33
|
+
"install",
|
|
34
|
+
help="register the kernelspec, with the bundled kernel binary or a verified download of the release's",
|
|
35
|
+
)
|
|
36
|
+
where = install.add_mutually_exclusive_group()
|
|
37
|
+
where.add_argument("--user", action="store_true", help="install for the current user")
|
|
38
|
+
where.add_argument("--sys-prefix", action="store_true", help="install into the current Python environment")
|
|
39
|
+
where.add_argument("--prefix", metavar="DIR", help="install under DIR/share/jupyter")
|
|
40
|
+
where.add_argument("--system", action="store_true", help="install system-wide")
|
|
41
|
+
install.add_argument("--binary", metavar="PATH", help="install this sysml-jupyter-kernel instead of the bundled or downloaded one")
|
|
42
|
+
install.add_argument("--release", metavar="TAG", help="download the kernel of this release (default: the bundled kernel, or the release this package pins)")
|
|
43
|
+
install.add_argument("--name", default=kernelspec.KERNEL_NAME, help="kernelspec name (default: %(default)s)")
|
|
44
|
+
install.add_argument("--display-name", default=kernelspec.DISPLAY_NAME, help="name shown by front ends (default: %(default)s)")
|
|
45
|
+
|
|
46
|
+
uninstall = commands.add_parser("uninstall", help="remove the kernelspec and the kernel binary in it")
|
|
47
|
+
uninstall.add_argument("--name", default=kernelspec.KERNEL_NAME, help="kernelspec name (default: %(default)s)")
|
|
48
|
+
|
|
49
|
+
commands.add_parser("kernelspec", help="print the kernel.json an install writes")
|
|
50
|
+
return parser
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def is_kernel_invocation(argv: Sequence[str]) -> bool:
|
|
54
|
+
"""Whether the arguments are the kernel's (single-dash flags), not a subcommand."""
|
|
55
|
+
return bool(argv) and argv[0].startswith("-") and not argv[0].startswith("--") and argv[0] != "-h"
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# The kernel's flags the launcher forwards: the one Jupyter passes, and the
|
|
59
|
+
# ones that only print. Those of the native `-install` are not among them; the
|
|
60
|
+
# `install` subcommand is the package's way to the same end.
|
|
61
|
+
CONNECTION_FILE_FLAG = "-connection-file"
|
|
62
|
+
KERNEL_SWITCHES = frozenset({"-verbose", "-version", "-man", "-print-kernelspec"})
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class KernelArgumentError(KernelBinaryError):
|
|
66
|
+
"""Arguments that are not the kernel's flags, so are not passed to it."""
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def kernel_arguments(argv: Sequence[str]) -> list[str]:
|
|
70
|
+
"""The kernel's command line for the arguments, each checked against its flag.
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
KernelArgumentError: If an argument is not a kernel flag, or names no
|
|
74
|
+
connection file
|
|
75
|
+
"""
|
|
76
|
+
command: list[str] = []
|
|
77
|
+
connection_file: str | None = None
|
|
78
|
+
args = iter(argv)
|
|
79
|
+
for arg in args:
|
|
80
|
+
flag, has_value, value = arg.partition("=")
|
|
81
|
+
if flag == CONNECTION_FILE_FLAG:
|
|
82
|
+
if not has_value:
|
|
83
|
+
value = next(args, "")
|
|
84
|
+
if connection_file is not None:
|
|
85
|
+
raise KernelArgumentError(f"kernel flag {flag} is given twice")
|
|
86
|
+
if not value or not os.path.isfile(value):
|
|
87
|
+
raise KernelArgumentError(f"kernel flag {flag} needs the connection file Jupyter wrote, not {value!r}")
|
|
88
|
+
connection_file = value
|
|
89
|
+
command += [flag, value]
|
|
90
|
+
elif flag in KERNEL_SWITCHES and not has_value:
|
|
91
|
+
command.append(flag)
|
|
92
|
+
else:
|
|
93
|
+
raise KernelArgumentError(
|
|
94
|
+
f"{arg!r} is not a kernel flag; the kernel takes {CONNECTION_FILE_FLAG} FILE and "
|
|
95
|
+
+ ", ".join(sorted(KERNEL_SWITCHES))
|
|
96
|
+
)
|
|
97
|
+
return command
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def launch(argv: Sequence[str]) -> int:
|
|
101
|
+
"""Run the bundled kernel with the given arguments, in this process where the OS allows.
|
|
102
|
+
|
|
103
|
+
Raises:
|
|
104
|
+
KernelBinaryError: If this install bundles no kernel, or the arguments
|
|
105
|
+
are not its flags
|
|
106
|
+
"""
|
|
107
|
+
path = bundled_binary()
|
|
108
|
+
if path is None:
|
|
109
|
+
raise KernelBinaryError(
|
|
110
|
+
f"this install of {kernelspec.PACKAGE} bundles no {binary_name()} (it was not installed "
|
|
111
|
+
"from a platform wheel); `python -m jupyter_opensysml_kernel install` registers a verified one"
|
|
112
|
+
)
|
|
113
|
+
command = [path, *kernel_arguments(argv)]
|
|
114
|
+
if sys.platform == "win32":
|
|
115
|
+
process = subprocess.Popen(command)
|
|
116
|
+
try:
|
|
117
|
+
return process.wait()
|
|
118
|
+
except BaseException:
|
|
119
|
+
process.terminate()
|
|
120
|
+
raise
|
|
121
|
+
if stat.S_IMODE(os.stat(path).st_mode) != BINARY_MODE:
|
|
122
|
+
try:
|
|
123
|
+
os.chmod(path, BINARY_MODE)
|
|
124
|
+
except OSError:
|
|
125
|
+
# Another user's, or a read-only, install: not ours to tighten, as long as it runs.
|
|
126
|
+
if not os.access(path, os.X_OK):
|
|
127
|
+
raise
|
|
128
|
+
os.execv(path, command)
|
|
129
|
+
return 0 # pragma: no cover - execv does not return
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
133
|
+
if argv is None:
|
|
134
|
+
argv = sys.argv[1:]
|
|
135
|
+
try:
|
|
136
|
+
if is_kernel_invocation(argv):
|
|
137
|
+
return launch(argv)
|
|
138
|
+
args = build_parser().parse_args(argv)
|
|
139
|
+
if args.command == "install":
|
|
140
|
+
prefix = args.prefix
|
|
141
|
+
if args.sys_prefix:
|
|
142
|
+
prefix = sys.prefix
|
|
143
|
+
user = args.user
|
|
144
|
+
if args.system:
|
|
145
|
+
prefix = "/usr/local" if sys.platform != "win32" else sys.prefix
|
|
146
|
+
path = kernelspec.install(
|
|
147
|
+
binary=args.binary,
|
|
148
|
+
version=args.release,
|
|
149
|
+
user=user,
|
|
150
|
+
prefix=prefix,
|
|
151
|
+
name=args.name,
|
|
152
|
+
display_name=args.display_name,
|
|
153
|
+
)
|
|
154
|
+
print(f"Installed kernelspec {args.name} in {path}")
|
|
155
|
+
elif args.command == "uninstall":
|
|
156
|
+
path = kernelspec.uninstall(args.name)
|
|
157
|
+
print(f"Removed kernelspec {args.name} from {path}")
|
|
158
|
+
else:
|
|
159
|
+
json.dump(kernelspec.kernel_json(binary_name()), sys.stdout, indent=2, sort_keys=True)
|
|
160
|
+
print()
|
|
161
|
+
except (KernelBinaryError, kernelspec.InvalidKernelNameError) as e:
|
|
162
|
+
print(f"error: {e}", file=sys.stderr)
|
|
163
|
+
return 1
|
|
164
|
+
return 0
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
sys.exit(main())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""The one place the jupyter-opensysml-kernel version is written.
|
|
2
|
+
|
|
3
|
+
The package is released in lockstep with the core and the opensysml client:
|
|
4
|
+
`client/python/scripts/check_version.py --jupyter-kernel` compares this value
|
|
5
|
+
with the tag and with client/python/opensysml/_version.py before a release.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
VERSION = "0.9.3.dev20261008"
|