Skip to content

Commit d7b1177

Browse files
committed
Compile standalone extension with builder to avoid intrusive builds for JLab
1 parent efb4807 commit d7b1177

File tree

8 files changed

+32
-25
lines changed

8 files changed

+32
-25
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ build/
22
dist/
33
node_modules/
44
package-lock.json
5-
/qgrid/static/
5+
/js/static
6+
/js/static_nb
67
*.egg-info/
78
/clean.sh
89
__pycache__/
10+
.*

MANIFEST.in

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
include README.rst
22
include LICENSE
3-
include requirements*.txt
4-
5-
recursive-include qgrid/static *.*
3+
include requirements.txt

install.json

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

js/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
],
1717
"scripts": {
1818
"clean": "rimraf dist/",
19-
"prepare": "webpack",
19+
"prepare": "webpack && jupyter labextension build .",
2020
"test": "echo \"Error: no test specified\" && exit 1"
2121
},
2222
"devDependencies": {
23+
"@jupyterlab/builder": "^4",
2324
"css-loader": "^6.10.0",
2425
"expose-loader": "^5.0.0",
2526
"file-loader": "^6.2.0",
@@ -31,7 +32,7 @@
3132
"webpack-cli": "^5.1.4"
3233
},
3334
"dependencies": {
34-
"@jupyter-widgets/base": "^6.0.6",
35+
"@jupyter-widgets/base": "^6",
3536
"@jupyter-widgets/controls": "^3.1.5",
3637
"jquery": "^3.7.1",
3738
"jquery-ui-dist": "^1.13.2",

js/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = [
3838
entry: './src/extension.js',
3939
output: {
4040
filename: 'extension.js',
41-
path: path.resolve(__dirname, '..', 'qgrid', 'static'),
41+
path: path.resolve(__dirname, 'static_nb'),
4242
libraryTarget: 'amd'
4343
},
4444
plugins: plugins,
@@ -53,7 +53,7 @@ module.exports = [
5353
entry: './src/index.js',
5454
output: {
5555
filename: 'index.js',
56-
path: path.resolve(__dirname, '..', 'qgrid', 'static'),
56+
path: path.resolve(__dirname, 'static_nb'),
5757
libraryTarget: 'amd'
5858
},
5959
devtool: 'source-map',

qgrid/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ def _jupyter_nbextension_paths():
1818
{
1919
"section": "notebook",
2020
"src": "static",
21-
"dest": "qgrid",
22-
"require": "qgrid/extension",
21+
"dest": "qgridnext",
22+
"require": "qgridnext/extension",
2323
}
2424
]
2525

qgridnext.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"load_extensions": {
3+
"qgridnext/extension": true
4+
}
5+
}

setup.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from setuptools import setup, find_packages, Command
1+
from setuptools import setup, find_packages, Command, find_namespace_packages
22
from setuptools.command.sdist import sdist
33
from setuptools.command.build_py import build_py
44
from setuptools.command.egg_info import egg_info
55
from subprocess import check_call
66
import os
77
import sys
88
import platform
9+
from glob import glob
910
from os.path import (
1011
join, dirname, abspath, exists
1112
)
@@ -68,8 +69,8 @@ class NPM(Command):
6869
node_modules = join(node_root, 'node_modules')
6970

7071
targets = [
71-
join(here, 'qgrid', 'static', 'extension.js'),
72-
join(here, 'qgrid', 'static', 'index.js')
72+
join(here, 'js', 'static_nb', 'extension.js'),
73+
join(here, 'js', 'static_nb', 'index.js')
7374
]
7475

7576
def initialize_options(self):
@@ -122,31 +123,27 @@ def read_requirements(basename):
122123
with open(reqs_file) as f:
123124
return [req.strip() for req in f.readlines()]
124125

125-
def package_files(directory):
126-
paths = []
127-
for (path, directories, filenames) in os.walk(directory):
128-
for filename in filenames:
129-
paths.append(os.path.join(path, filename))
130-
return paths
131-
132126
setup_args = {
133127
'name': 'qgridnext',
134128
'version': version_ns['__version__'],
135129
'description': 'An Interactive Grid for Sorting and Filtering DataFrames in Jupyter',
136130
'long_description': LONG_DESCRIPTION,
137131
'include_package_data': True,
138132
'data_files': [
139-
('share/jupyter/nbextensions/qgrid', package_files('qgrid/static')),
133+
('etc/jupyter/nbconfig/notebook.d' , ['qgridnext.json']),
134+
('share/jupyter/nbextensions/qgridnext', glob('js/static_nb/*.*')),
135+
('share/jupyter/labextensions/qgridnext', glob('js/static/*.*') + ['install.json']),
136+
('share/jupyter/labextensions/qgridnext/static', glob('js/static/static/*.*'))
140137
],
141-
"python_requires": ">=3.6",
138+
"python_requires": ">=3.7",
142139
'install_requires': read_requirements('requirements.txt'),
143140
'extras_require': {
144141
"test": [
145142
"pytest>=2.8.5",
146143
"flake8>=3.6.0"
147144
],
148145
},
149-
'packages': find_packages(exclude=['qgrid.static']),
146+
'packages': find_packages(),
150147
'zip_safe': False,
151148
'cmdclass': {
152149
'build_py': js_prerelease(build_py),
@@ -157,7 +154,7 @@ def package_files(directory):
157154

158155
'author': 'Quantopian Inc.',
159156
'author_email': '[email protected]',
160-
'url': 'https://github.com/quantopian/qgrid',
157+
'url': 'https://github.com/zhihanyue/qgridnext',
161158
'license': 'Apache-2.0',
162159
'keywords': [
163160
'ipython',
@@ -173,7 +170,6 @@ def package_files(directory):
173170
'Topic :: Scientific/Engineering :: Information Analysis',
174171
'Topic :: Multimedia :: Graphics',
175172
'Programming Language :: Python :: 3',
176-
'Programming Language :: Python :: 3.6',
177173
'Programming Language :: Python :: 3.7',
178174
'Programming Language :: Python :: 3.8',
179175
'Programming Language :: Python :: 3.9',

0 commit comments

Comments
 (0)