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

Remove duplication of the labextension #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlite_xeus_python/labextension

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
Expand Down Expand Up @@ -119,3 +118,6 @@ python_data.data
xpython_wasm.js
xpython_wasm.wasm
xeus_python.worker.js

# Labextension
share
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include yarn.lock
include webpack.config.js
recursive-include tests *.py

graft jupyterlite_xeus_python/labextension
graft share

graft docs

Expand Down
14 changes: 10 additions & 4 deletions jupyterlite_xeus_python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import sys
import json
from pathlib import Path

from ._version import __version__

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

with (HERE / "labextension" / "package.json").open() as fid:
data = json.load(fid)


def _jupyter_labextension_paths():
return [{"src": "labextension", "dest": data["name"]}]
prefix = sys.prefix
# For when in dev mode
if (HERE.parent / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel').parent.exists():
prefix = HERE.parent

return [{
'src': prefix / 'share' / 'jupyter' / 'labextensions' / '@jupyterlite' / 'xeus-python-kernel',
'dest': '@jupyterlite/xeus-python-kernel',
}]
23 changes: 10 additions & 13 deletions jupyterlite_xeus_python/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@
def _fetchVersion():
HERE = Path(__file__).parent.resolve()

for settings in HERE.rglob("package.json"):
try:
with settings.open() as f:
version = json.load(f)["version"]
return (
version.replace("-alpha.", "a")
.replace("-beta.", "b")
.replace("-rc.", "rc")
)
except FileNotFoundError:
pass

raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")
try:
with open(HERE / "package.json", "r") as f:
version = json.load(f)["version"]
return (
version.replace("-alpha.", "a")
.replace("-beta.", "b")
.replace("-rc.", "rc")
)
except FileNotFoundError:
pass


__version__ = _fetchVersion()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
},
"jupyterlab": {
"extension": true,
"outputDir": "jupyterlite_xeus_python/labextension",
"outputDir": "share/jupyter/labextensions/@jupyterlite/xeus-python-kernel",
"webpackConfig": "./webpack.config.js",
"sharedPackages": {
"@jupyterlite/kernel": {
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
build-backend = "jupyter_packaging.build_api"

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

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

[tool.check-manifest]
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"]
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"]
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# The name of the project
name = "jupyterlite-xeus-python"

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

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

labext_name = "jupyterlite-xeus-python"
labext_name = "@jupyterlite/xeus-python-kernel"

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