Skip to content

Commit 6baa8ef

Browse files
committed
add .pth file
1 parent dc8149e commit 6baa8ef

File tree

3 files changed

+43
-39
lines changed

3 files changed

+43
-39
lines changed

idom_jupyter.pth

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import idom_jupyter

notebooks/introduction.ipynb

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cells": [
33
{
4+
"attachments": {},
45
"cell_type": "markdown",
56
"metadata": {},
67
"source": [
@@ -13,55 +14,33 @@
1314
"\n",
1415
"# Getting Started\n",
1516
"\n",
16-
"The first thing we need must do in order to run IDOM in a Jupyter Notebook is `import idom_jupyter`. After that, you'll be able to use IDOM components like any other [Jupyter Widget](https://ipywidgets.readthedocs.io/en/latest/#)."
17-
]
18-
},
19-
{
20-
"cell_type": "code",
21-
"execution_count": 1,
22-
"metadata": {},
23-
"outputs": [],
24-
"source": [
25-
"import idom_jupyter"
26-
]
27-
},
28-
{
29-
"cell_type": "markdown",
30-
"metadata": {},
31-
"source": [
17+
"The first thing we need must do in order to run IDOM in a Jupyter Notebook is install `idom_jupyter` Jupyter with PIP:\n",
18+
"\n",
19+
"```bash\n",
20+
"pip install idom-jupyter\n",
21+
"```\n",
22+
"\n",
23+
"Once this is done you'll be able to use IDOM components like any other [Jupyter Widget](https://ipywidgets.readthedocs.io/en/latest/#).\n",
24+
"\n",
3225
"# At a Glance\n",
3326
"\n",
3427
"To get a rough idea of how to write apps in IDOM, take a look at the tiny [“hello world”](https://en.wikipedia.org/wiki/%22Hello,_World!%22_program) application below:"
3528
]
3629
},
3730
{
3831
"cell_type": "code",
39-
"execution_count": 2,
32+
"execution_count": 1,
4033
"metadata": {},
4134
"outputs": [
4235
{
4336
"data": {
4437
"text/plain": [
45-
"App(7f911920b6a0)"
38+
"App(7fe7b39a65c0)"
4639
]
4740
},
48-
"execution_count": 2,
41+
"execution_count": 1,
4942
"metadata": {},
5043
"output_type": "execute_result"
51-
},
52-
{
53-
"data": {
54-
"application/vnd.jupyter.widget-view+json": {
55-
"model_id": "14bfdffe5d5148b8bf923dc95fbfd788",
56-
"version_major": 2,
57-
"version_minor": 0
58-
},
59-
"text/plain": [
60-
"LayoutWidget(Layout(App(7f911920b6a0)))"
61-
]
62-
},
63-
"metadata": {},
64-
"output_type": "display_data"
6544
}
6645
],
6746
"source": [

setup.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
from setuptools import setup, find_packages
4+
from setuptools.command.build_py import build_py
45
from pathlib import Path
56

67
from jupyter_packaging import (
@@ -102,12 +103,35 @@
102103
),
103104
]
104105

105-
cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec)
106-
cmdclass["jsdeps"] = combine_commands(
107-
install_npm(JS_DIR, npm=["yarn"], build_cmd="build:prod"),
108-
ensure_targets(jstargets),
109-
)
110-
package["cmdclass"] = cmdclass
106+
package["cmdclass"] = {
107+
**create_cmdclass("jsdeps", data_files_spec=data_files_spec),
108+
"jsdeps": combine_commands(
109+
install_npm(JS_DIR, npm=["yarn"], build_cmd="build:prod"),
110+
ensure_targets(jstargets),
111+
),
112+
}
113+
114+
# --------------------------------------------------------------------------------------
115+
# Build Pth File
116+
# --------------------------------------------------------------------------------------
117+
118+
BuildPyBase: type[build_py] = package["cmdclass"]["build_py"]
119+
120+
121+
class BuildPy(BuildPyBase):
122+
"""Include the .pth file for this project, in the generated wheel."""
123+
124+
def run(self):
125+
super().run()
126+
pth_file = f"{NAME}.pth"
127+
self.copy_file(
128+
str(ROOT_DIR / pth_file),
129+
str(Path(self.build_lib) / pth_file),
130+
preserve_mode=0,
131+
)
132+
133+
134+
package["cmdclass"] = {**package["cmdclass"], "build_py": BuildPy}
111135

112136
# -----------------------------------------------------------------------------
113137
# Install It

0 commit comments

Comments
 (0)