Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

Commit 930bcb5

Browse files
authored
Remove duplication of the labextension (#15)
* Remove duplication of the labextension * Update pyproject.toml * Add ignore on the package.json file * Remove package.json from the site-packages We don't need this
1 parent d267f9b commit 930bcb5

File tree

7 files changed

+30
-25
lines changed

7 files changed

+30
-25
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ node_modules/
44
*.egg-info/
55
.ipynb_checkpoints
66
*.tsbuildinfo
7-
jupyterlite_xeus_python/labextension
87

98
# Created by https://www.gitignore.io/api/python
109
# Edit at https://www.gitignore.io/?templates=python
@@ -119,3 +118,6 @@ python_data.data
119118
xpython_wasm.js
120119
xpython_wasm.wasm
121120
xeus_python.worker.js
121+
122+
# Labextension
123+
share

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include yarn.lock
99
include webpack.config.js
1010
recursive-include tests *.py
1111

12-
graft jupyterlite_xeus_python/labextension
12+
graft share
1313

1414
graft docs
1515

jupyterlite_xeus_python/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
import sys
12
import json
23
from pathlib import Path
34

45
from ._version import __version__
56

67
HERE = Path(__file__).parent.resolve()
78

8-
with (HERE / "labextension" / "package.json").open() as fid:
9-
data = json.load(fid)
10-
119

1210
def _jupyter_labextension_paths():
13-
return [{"src": "labextension", "dest": data["name"]}]
11+
prefix = sys.prefix
12+
# For when in dev mode
13+
if (HERE.parent / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel').parent.exists():
14+
prefix = HERE.parent
15+
16+
return [{
17+
'src': prefix / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel',
18+
'dest': '@jupyterlite/xeus-python-kernel',
19+
}]

jupyterlite_xeus_python/_version.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@
77
def _fetchVersion():
88
HERE = Path(__file__).parent.resolve()
99

10-
for settings in HERE.rglob("package.json"):
11-
try:
12-
with settings.open() as f:
13-
version = json.load(f)["version"]
14-
return (
15-
version.replace("-alpha.", "a")
16-
.replace("-beta.", "b")
17-
.replace("-rc.", "rc")
18-
)
19-
except FileNotFoundError:
20-
pass
21-
22-
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")
10+
try:
11+
with open(HERE / "package.json", "r") as f:
12+
version = json.load(f)["version"]
13+
return (
14+
version.replace("-alpha.", "a")
15+
.replace("-beta.", "b")
16+
.replace("-rc.", "rc")
17+
)
18+
except FileNotFoundError:
19+
pass
2320

2421

2522
__version__ = _fetchVersion()

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
},
8383
"jupyterlab": {
8484
"extension": true,
85-
"outputDir": "jupyterlite_xeus_python/labextension",
85+
"outputDir": "share/jupyter/labextensions/@jupyterlite/xeus-python-kernel",
8686
"webpackConfig": "./webpack.config.js",
8787
"sharedPackages": {
8888
"@jupyterlite/kernel": {

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
33
build-backend = "jupyter_packaging.build_api"
44

55
[tool.jupyter-packaging.options]
6-
skip-if-exists = ["jupyterlite_xeus_python/labextension/static/style.js"]
7-
ensured-targets = ["jupyterlite_xeus_python/labextension/static/style.js", "jupyterlite_xeus_python/labextension/package.json"]
6+
skip-if-exists = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/static/style.js"]
7+
ensured-targets = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/static/style.js", "share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/package.json"]
88

99
[tool.jupyter-packaging.builder]
1010
factory = "jupyter_packaging.npm_builder"
@@ -14,4 +14,4 @@ build_cmd = "build:prod"
1414
npm = ["jlpm"]
1515

1616
[tool.check-manifest]
17-
ignore = ["jupyterlite_xeus_python/labextension/**", "yarn.lock", ".*", "package-lock.json", "Dockerfile", "src/xeus_python.worker.js", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/python_data.data", "src/python_data.js", "*.sh"]
17+
ignore = ["share/jupyter/labextensions/@jupyterlite/xeus-python-kernel/**", "yarn.lock", ".*", "package-lock.json", "Dockerfile", "src/xeus_python.worker.js", "src/xpython_wasm.js", "src/xpython_wasm.wasm", "src/python_data.data", "src/python_data.js", "*.sh"]

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
# The name of the project
1313
name = "jupyterlite-xeus-python"
1414

15-
lab_path = (HERE / name.replace("-", "_") / "labextension")
15+
lab_path = (HERE / "share" / "jupyter" / "labextensions" / "@jupyterlite" / "xeus-python-kernel")
1616

1717
# Representative files that should exist after a successful build
1818
ensured_targets = [
1919
str(lab_path / "package.json"),
2020
str(lab_path / "static/style.js")
2121
]
2222

23-
labext_name = "jupyterlite-xeus-python"
23+
labext_name = "@jupyterlite/xeus-python-kernel"
2424

2525
data_files_spec = [
2626
("share/jupyter/labextensions/%s" % labext_name, str(lab_path.relative_to(HERE)), "**"),

0 commit comments

Comments
 (0)