Skip to content

Commit 8863bf5

Browse files
authored
Add jupytercad_lite metapackage (#681)
* Add `jupytercad_lite` metapackage * update bump-version * port remaining changes * install jupytercad_lite on build-lite job * install jupytercad_lite on build-lite job * try building jupytercad_lite in build packages * continue installing the labextension in the dev install script * continue installing the package too * install metapackage outside the for loop * condition not needed
1 parent 1611a56 commit 8863bf5

File tree

14 files changed

+156
-10
lines changed

14 files changed

+156
-10
lines changed

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
python/jupytercad_lab/dist/jupytercad*
8686
python/jupytercad_app/dist/jupytercad*
8787
python/jupytercad/dist/jupytercad*
88+
python/jupytercad_lite/dist/jupytercad*
8889
if-no-files-found: error
8990

9091
test_isolated:
@@ -236,6 +237,7 @@ jobs:
236237
cp ./jupytercad_core/dist/jupytercad*.whl jupytercad_core-0.0.1-py3-none-any.whl
237238
cp ./jupytercad_lab/dist/jupytercad*.whl jupytercad_lab-0.0.1-py3-none-any.whl
238239
cp ./jupytercad_app/dist/jupytercad*.whl jupytercad_app-0.0.1-py3-none-any.whl
240+
cp ./jupytercad_lite/dist/jupytercad*.whl jupytercad_lite-0.0.1-py3-none-any.whl
239241
240242
- name: Build the lite site
241243
shell: bash -l {0}

examples/Notebook.ipynb

+20-8
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,29 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": 10,
21+
"execution_count": 4,
2222
"id": "050e5936-f9e1-44ff-8bc9-a8556d7643ee",
2323
"metadata": {},
24-
"outputs": [],
24+
"outputs": [
25+
{
26+
"ename": "ModuleNotFoundError",
27+
"evalue": "No module named 'jupytercad'",
28+
"output_type": "error",
29+
"traceback": [
30+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
31+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
32+
"Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mjupytercad\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m CadDocument\n",
33+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'jupytercad'"
34+
]
35+
}
36+
],
2537
"source": [
26-
"from jupytercad_lab import CadDocument"
38+
"from jupytercad import CadDocument"
2739
]
2840
},
2941
{
3042
"cell_type": "code",
31-
"execution_count": 11,
43+
"execution_count": 5,
3244
"id": "9821d466-6ae7-418f-aea7-9d67153da7d6",
3345
"metadata": {},
3446
"outputs": [],
@@ -38,22 +50,22 @@
3850
},
3951
{
4052
"cell_type": "code",
41-
"execution_count": 12,
53+
"execution_count": 6,
4254
"id": "e30499f0-6732-4611-a25e-46b27e606b08",
4355
"metadata": {},
4456
"outputs": [
4557
{
4658
"data": {
4759
"application/vnd.jupyter.ywidget-view+json": {
48-
"model_id": "c586b4fc0d474786bd7fbf9635e15421",
60+
"model_id": "c0c9e05d08ec4e71bebc1877eec30531",
4961
"version_major": 2,
5062
"version_minor": 0
5163
},
5264
"text/plain": [
53-
"<jupytercad_lab.notebook.cad_document.CadDocument object at 0x110fc7410>"
65+
"<jupytercad_lab.notebook.cad_document.CadDocument object at 0x108aa4800>"
5466
]
5567
},
56-
"execution_count": 12,
68+
"execution_count": 6,
5769
"metadata": {},
5870
"output_type": "execute_result"
5971
}

lite/environment.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ dependencies:
1616
- my-jupyter-shared-drive
1717
- ../jupytercad_core-0.0.1-py3-none-any.whl
1818
- ../jupytercad_lab-0.0.1-py3-none-any.whl
19+
- ../jupytercad_lite-0.0.1-py3-none-any.whl

packages/base/src/widget.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ export class JupyterCadPanel extends SplitPanel {
272272
this.setRelativeSizes([2, 1]);
273273
this._consoleOpened = true;
274274
await consolePanel.console.inject(
275-
`from jupytercad_lab import CadDocument\ndoc = CadDocument("${jcadPath}")`
275+
`from jupytercad import CadDocument\ndoc = CadDocument("${jcadPath}")`
276276
);
277277
consolePanel.console.sessionContext.kernelChanged.connect((_, arg) => {
278278
if (!arg.newValue) {

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ python_packages = [
2323
"python/jupytercad_app:jupytercad_app",
2424
"python/jupytercad_core:jupytercad_core",
2525
"python/jupytercad_lab:jupytercad_lab",
26+
"python/jupytercad_lite:jupytercad",
2627
]
2728

2829
[tool.jupyter-releaser.hooks]

python/jupytercad_lite/LICENSE

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2025, JupyterCAD contributors
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

python/jupytercad_lite/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# JupyterCAD meta-package for JupyterLite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
__version__ = "3.0.1"
2+
3+
from jupytercad_lab import CadDocument # noqa

python/jupytercad_lite/pyproject.toml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling>=1.5.0,<2"]
4+
5+
[project]
6+
classifiers = [
7+
"Framework :: Jupyter",
8+
"Framework :: Jupyter :: JupyterLab",
9+
"Framework :: Jupyter :: JupyterLab :: 4",
10+
"Framework :: Jupyter :: JupyterLab :: Extensions",
11+
"Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt",
12+
"License :: OSI Approved :: BSD License",
13+
"Programming Language :: Python",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.8",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Programming Language :: Python :: 3.12",
20+
]
21+
dependencies = [
22+
"jupytercad_core==3.0.1",
23+
"jupytercad_lab==3.0.1",
24+
"my-jupyter-shared-drive",
25+
]
26+
dynamic = ["version"]
27+
license = {file = "LICENSE"}
28+
name = "jupytercad-lite"
29+
readme = "README.md"
30+
requires-python = ">=3.10"
31+
32+
33+
[tool.hatch.version]
34+
path = "jupytercad/__init__.py"
35+
36+
[tool.hatch.build.targets.wheel]
37+
packages = ["jupytercad"]
38+
39+
[tool.jupyter-releaser.options]
40+
version_cmd = "hatch version"
41+
42+
[tool.check-wheel-contents]
43+
ignore = ["W002"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from pathlib import Path
2+
from subprocess import run
3+
from typing import List
4+
from packaging.version import parse as parse_version
5+
import tomlkit
6+
import argparse
7+
8+
HATCH_VERSION = "hatch version"
9+
ROOT = Path(__file__).parent.parent
10+
11+
12+
def get_version():
13+
cmd = run([HATCH_VERSION], capture_output=True, shell=True, check=True, cwd=ROOT)
14+
return cmd.stdout.decode("utf-8").strip().split("\n")[-1]
15+
16+
17+
def next_version():
18+
v = parse_version(get_version())
19+
if v.is_prerelease:
20+
return f"{v.major}.{v.minor}.{v.micro}{v.pre[0]}{v.pre[1] + 1}"
21+
return f"{v.major}.{v.minor}.{v.micro + 1}"
22+
23+
24+
def bump_jupytercad_deps(py_version: str):
25+
with open(ROOT / "pyproject.toml", "r") as f:
26+
data = tomlkit.load(f)
27+
dependencies: List[str] = data["project"]["dependencies"]
28+
29+
for index, value in enumerate(dependencies):
30+
if value.startswith("jupytercad"):
31+
lib = value.split("==")[0]
32+
dependencies[index] = f"{lib}=={py_version}"
33+
34+
with open(ROOT / "pyproject.toml", "w") as f:
35+
tomlkit.dump(data, f)
36+
37+
38+
def bump():
39+
parser = argparse.ArgumentParser()
40+
parser.add_argument("version")
41+
args = parser.parse_args()
42+
py_version = next_version() if args.version == "next" else args.version
43+
# bump the Python version with hatch
44+
run(f"{HATCH_VERSION}", shell=True, check=True, cwd=ROOT)
45+
# pin jupytercad_* package to the same version
46+
bump_jupytercad_deps(py_version)
47+
48+
49+
if __name__ == "__main__":
50+
bump()

python/jupytercad_lite/setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__import__("setuptools").setup()

scripts/build_packages.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def build_packages():
1717
"jupytercad_lab",
1818
"jupytercad_app",
1919
"jupytercad",
20+
"jupytercad_lite",
2021
]
2122

2223
execute(install_build_deps)

scripts/dev-install.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def install_dev(no_occ_build=False):
3939
f"jupyter labextension develop {python_package_prefix}/{py_package} --overwrite"
4040
)
4141

42+
execute(f"pip install -e {python_package_prefix}/jupytercad")
43+
4244

4345
if __name__ == "__main__":
4446
argv = sys.argv

ui-tests/tests/notebooks/Notebook.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"metadata": {},
88
"outputs": [],
99
"source": [
10-
"from jupytercad_lab import CadDocument\n",
10+
"from jupytercad import CadDocument\n",
1111
"\n",
1212
"doc = CadDocument()\n",
1313
"\n",

0 commit comments

Comments
 (0)