Skip to content

Commit 9e64a86

Browse files
committed
Package extensions as a Python package
1 parent b4cbd22 commit 9e64a86

File tree

13 files changed

+2187
-84
lines changed

13 files changed

+2187
-84
lines changed

.gitignore

+106-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,112 @@
1+
*.bundle.*
2+
lib/
3+
node_modules/
4+
*.egg-info/
5+
.ipynb_checkpoints
6+
*.tsbuildinfo
7+
jupyterlab-renderers/labextensions
8+
9+
# Created by https://www.gitignore.io/api/python
10+
# Edit at https://www.gitignore.io/?templates=python
11+
12+
### Python ###
13+
# Byte-compiled / optimized / DLL files
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
18+
# C extensions
19+
*.so
20+
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
pip-wheel-metadata/
36+
share/python-wheels/
37+
.installed.cfg
38+
*.egg
139
MANIFEST
2-
build
3-
dist
4-
lib
5-
jupyterlab/build
640

7-
node_modules
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.nox/
55+
.coverage
56+
.coverage.*
857
.cache
9-
.vscode
10-
*.py[co]
11-
__pycache__
12-
*.egg-info
13-
*~
14-
*.bak
15-
.ipynb_checkpoints
16-
.DS_Store
17-
\#*#
18-
.#*
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
.hypothesis/
62+
.pytest_cache/
63+
64+
# Translations
65+
*.mo
66+
*.pot
67+
68+
# Scrapy stuff:
69+
.scrapy
1970

20-
*.swp
21-
*.map
22-
.idea/
71+
# Sphinx documentation
72+
docs/_build/
2373

24-
test/coverage
25-
docs/_build
26-
docs/api
27-
packages/services/examples/node/config.json
74+
# PyBuilder
75+
target/
2876

29-
lerna-debug.log
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Spyder project settings
87+
.spyderproject
88+
.spyproject
89+
90+
# Rope project settings
91+
.ropeproject
92+
93+
# Mr Developer
94+
.mr.developer.cfg
95+
.project
96+
.pydevproject
97+
98+
# mkdocs documentation
99+
/site
100+
101+
# mypy
102+
.mypy_cache/
103+
.dmypy.json
104+
dmypy.json
105+
106+
# Pyre type checker
107+
.pyre/
108+
109+
# End of https://www.gitignore.io/api/python
110+
111+
# OSX files
112+
.DS_Store

MANIFEST.in

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
include LICENSE
2+
include README.md
3+
include pyproject.toml
4+
include jupyter-config/jupyterlab-renderers.json
5+
6+
include package.json
7+
include install.json
8+
include ts*.json
9+
include yarn.lock
10+
11+
graft jupyterlab-renderers/labextension
12+
13+
# Javascript files
14+
graft src
15+
graft style
16+
prune **/node_modules
17+
prune lib
18+
19+
# Patterns to exclude from any directory
20+
global-exclude *~
21+
global-exclude *.pyc
22+
global-exclude *.pyo
23+
global-exclude .git
24+
global-exclude .ipynb_checkpoints

install.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"packageManager": "python",
3+
"packageName": "jupyterlab-renderers",
4+
"uninstallInstructions": "Use your Python package manager (pip, conda, etc.) to uninstall the package jupyterlab-renderers"
5+
}

jupyterlab-renderers/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from ._version import __version__
2+
3+
4+
def _jupyter_labextension_paths():
5+
return [{
6+
"src": "labextension/@jupyterlab/fasta-extension",
7+
"dest": "@jupyterlab/fasta-extension"
8+
}]

jupyterlab-renderers/_version.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
from pathlib import Path
3+
4+
__all__ = ["__version__"]
5+
6+
def _fetchVersion():
7+
HERE = Path(__file__).parent.resolve()
8+
9+
for settings in HERE.rglob("package.json"):
10+
try:
11+
with settings.open() as f:
12+
return json.load(f)["version"]
13+
except FileNotFoundError:
14+
pass
15+
16+
raise FileNotFoundError(f"Could not find package.json under dir {HERE!s}")
17+
18+
__version__ = _fetchVersion()
19+

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
],
66
"scripts": {
77
"build": "lerna run --parallel build",
8+
"build:prod": "lerna run --parallel build:prod",
89
"link": "lerna exec --parallel -- jupyter labextension link . --no-build",
910
"precommit": "lint-staged",
1011
"prettier": "prettier --write '{!(package),packages/*/!(package),packages/*/!(lib)/**}{.js,.jsx,.ts,.tsx,.css,.json,.md}'",

packages/fasta-extension/package.json

+35-11
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,49 @@
2525
"files": [
2626
"lib/*.d.ts",
2727
"lib/*.js",
28-
"style/*.*"
28+
"style/*.*",
29+
"style/index.js"
2930
],
3031
"scripts": {
31-
"build": "tsc",
32-
"clean": "rimraf lib",
32+
"build": "jlpm run build:lib && jlpm run build:labextension:dev",
33+
"build:labextension": "jupyter labextension build .",
34+
"build:labextension:dev": "jupyter labextension build --development True .",
35+
"build:lib": "tsc",
36+
"build:prod": "jlpm run build:lib && jlpm run build:labextension",
37+
"clean": "jlpm run clean:lib",
38+
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
39+
"clean:labextension": "rimraf ../../jupyterlab-renderers/labextensions/@jupyterlab/fasta-extension",
40+
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
41+
"eslint": "eslint . --ext .ts,.tsx --fix",
42+
"eslint:check": "eslint . --ext .ts,.tsx",
43+
"install:extension": "jupyter labextension develop --overwrite .",
3344
"prepack": "npm run clean && npm run build",
34-
"watch": "tsc -w"
45+
"prepare": "jlpm run clean && jlpm run build:prod",
46+
"watch": "run-p watch:src watch:labextension",
47+
"watch:labextension": "jupyter labextension watch .",
48+
"watch:src": "tsc -w"
3549
},
3650
"dependencies": {
37-
"@jupyterlab/rendermime-interfaces": "^3.0.0",
38-
"@lumino/messaging": "^1.2.2",
39-
"@lumino/widgets": "^1.11.0",
51+
"@jupyterlab/rendermime-interfaces": "^3.0.5",
52+
"@lumino/messaging": "^1.4.3",
53+
"@lumino/widgets": "^1.16.1",
4054
"msa": "^1.0.3"
4155
},
4256
"devDependencies": {
43-
"rimraf": "~2.6.2",
57+
"@jupyterlab/builder": "^3.0.0",
58+
"@typescript-eslint/eslint-plugin": "^4.8.1",
59+
"@typescript-eslint/parser": "^4.8.1",
60+
"eslint": "^7.14.0",
61+
"eslint-config-prettier": "^6.15.0",
62+
"eslint-plugin-prettier": "^3.1.4",
63+
"npm-run-all": "^4.1.5",
64+
"prettier": "^2.1.1",
65+
"rimraf": "^3.0.2",
4466
"typescript": "~4.1.3"
4567
},
4668
"jupyterlab": {
47-
"mimeExtension": true
48-
}
49-
}
69+
"mimeExtension": true,
70+
"outputDir": "../../jupyterlab-renderers/labextensions/@jupyterlab/fasta-extension"
71+
},
72+
"styleModule": "style/index.js"
73+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
Copyright (c) Jupyter Development Team.
3+
Distributed under the terms of the Modified BSD License.
4+
*/
5+
6+
/* Add CSS variables to :root */
7+
:root {
8+
--jp-icon-msa: url('./msa.svg');
9+
}
10+
11+
/* Base styles */
12+
.jp-RenderedMSA {
13+
/*width: 100%;
14+
height: 100%;*/
15+
margin: 10px;
16+
overflow-y: auto;
17+
}
18+
19+
/* Document styles */
20+
.jp-MimeDocument .jp-RenderedMSA {
21+
}
22+
23+
/* Output styles */
24+
.jp-OutputArea .jp-RenderedMSA {
25+
}
26+
27+
/* Document icon */
28+
.jp-MSAIcon {
29+
background-image: var(--jp-icon-msa);
30+
/*background-size: 24px;
31+
background-position: center !important;*/
32+
}

packages/fasta-extension/style/index.css

+1-27
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,4 @@
33
Distributed under the terms of the Modified BSD License.
44
*/
55

6-
/* Add CSS variables to :root */
7-
:root {
8-
--jp-icon-msa: url('./msa.svg');
9-
}
10-
11-
/* Base styles */
12-
.jp-RenderedMSA {
13-
/*width: 100%;
14-
height: 100%;*/
15-
margin: 10px;
16-
overflow-y: auto;
17-
}
18-
19-
/* Document styles */
20-
.jp-MimeDocument .jp-RenderedMSA {
21-
}
22-
23-
/* Output styles */
24-
.jp-OutputArea .jp-RenderedMSA {
25-
}
26-
27-
/* Document icon */
28-
.jp-MSAIcon {
29-
background-image: var(--jp-icon-msa);
30-
/*background-size: 24px;
31-
background-position: center !important;*/
32-
}
6+
@import url('./base.css');
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './base.css';

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
3+
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)