1
1
"""
2
- clear_cell_outputs setup
2
+ jupyterlab_examples_toolbar_button setup
3
3
"""
4
4
import json
5
- from pathlib import Path
5
+ import os
6
6
7
+ from jupyter_packaging import (
8
+ create_cmdclass , install_npm , ensure_targets ,
9
+ combine_commands , skip_if_exists
10
+ )
7
11
import setuptools
8
12
9
- HERE = Path ( __file__ ). parent . resolve ( )
13
+ HERE = os . path . abspath ( os . path . dirname ( __file__ ) )
10
14
11
15
# The name of the project
12
- name = "jupyterlab_examples_toolbar_button"
16
+ name = "jupyterlab_examples_toolbar_button"
17
+
18
+ # Get our version
19
+ with open (os .path .join (HERE , 'package.json' )) as f :
20
+ version = json .load (f )['version' ]
13
21
14
- lab_path = (HERE / name . replace ( "-" , "_" ) / "labextension" )
22
+ lab_path = os . path . join (HERE , name , "labextension" )
15
23
16
24
# Representative files that should exist after a successful build
17
- ensured_targets = [
18
- str (lab_path / "package.json" ),
19
- str (lab_path / "static/style.js" )
25
+ jstargets = [
26
+ os .path .join (lab_path , "package.json" ),
20
27
]
21
28
29
+ package_data_spec = {
30
+ name : [
31
+ "*"
32
+ ]
33
+ }
34
+
22
35
labext_name = "@jupyterlab-examples/toolbar-button"
23
36
24
37
data_files_spec = [
25
- ("share/jupyter/labextensions/%s" % labext_name , str ( lab_path ) , "**" ),
26
- ("share/jupyter/labextensions/%s" % labext_name , str ( HERE ) , "install.json" ),
38
+ ("share/jupyter/labextensions/%s" % labext_name , lab_path , "**" ),
39
+ ("share/jupyter/labextensions/%s" % labext_name , HERE , "install.json" ),
27
40
]
28
41
29
- long_description = (HERE / "README.md" ).read_text ()
42
+ cmdclass = create_cmdclass ("jsdeps" ,
43
+ package_data_spec = package_data_spec ,
44
+ data_files_spec = data_files_spec
45
+ )
46
+
47
+ js_command = combine_commands (
48
+ install_npm (HERE , build_cmd = "build:prod" , npm = ["jlpm" ]),
49
+ ensure_targets (jstargets ),
50
+ )
51
+
52
+ is_repo = os .path .exists (os .path .join (HERE , ".git" ))
53
+ if is_repo :
54
+ cmdclass ["jsdeps" ] = js_command
55
+ else :
56
+ cmdclass ["jsdeps" ] = skip_if_exists (jstargets , js_command )
30
57
31
- # Get the package info from package.json
32
- pkg_json = json . loads (( HERE / "package.json" ). read_bytes () )
58
+ with open ( "README.md" , "r" ) as fh :
59
+ long_description = fh . read ( )
33
60
34
61
setup_args = dict (
35
62
name = name ,
36
- version = pkg_json ["version" ],
37
- url = pkg_json ["homepage" ],
38
- author = pkg_json ["author" ]["name" ],
39
- author_email = pkg_json ["author" ]["email" ],
40
- description = pkg_json ["description" ],
41
- license = pkg_json ["license" ],
42
- long_description = long_description ,
63
+ version = version ,
64
+ url = "https://github.com/jupyterlab/extension-examples.git" ,
65
+ author = "Project Jupyter Contributors" ,
66
+ description = "minimal lab example" ,
67
+ long_description = long_description ,
43
68
long_description_content_type = "text/markdown" ,
69
+ cmdclass = cmdclass ,
44
70
packages = setuptools .find_packages (),
45
71
install_requires = [
46
- "jupyter_server>=1.6,<2"
72
+ "jupyterlab>=3.0.0rc15,==3.*" ,
47
73
],
48
74
zip_safe = False ,
49
75
include_package_data = True ,
50
76
python_requires = ">=3.6" ,
77
+ license = "BSD-3-Clause" ,
51
78
platforms = "Linux, Mac OS X, Windows" ,
52
79
keywords = ["Jupyter" , "JupyterLab" , "JupyterLab3" ],
53
80
classifiers = [
57
84
"Programming Language :: Python :: 3.6" ,
58
85
"Programming Language :: Python :: 3.7" ,
59
86
"Programming Language :: Python :: 3.8" ,
60
- "Programming Language :: Python :: 3.9" ,
61
87
"Framework :: Jupyter" ,
62
88
],
63
89
)
64
90
65
- try :
66
- from jupyter_packaging import (
67
- wrap_installers ,
68
- npm_builder ,
69
- get_data_files
70
- )
71
- post_develop = npm_builder (
72
- build_cmd = "install:extension" , source_dir = "src" , build_dir = lab_path
73
- )
74
- setup_args ['cmdclass' ] = wrap_installers (post_develop = post_develop , ensured_targets = ensured_targets )
75
- setup_args ['data_files' ] = get_data_files (data_files_spec )
76
- except ImportError as e :
77
- pass
78
91
79
92
if __name__ == "__main__" :
80
- setuptools .setup (** setup_args )
93
+ setuptools .setup (** setup_args )
0 commit comments