|
1 | 1 | """ |
2 | 2 | Setup Module to setup Python Handlers (Git Handlers) for the Git Plugin. |
3 | 3 | """ |
4 | | -from os.path import join as pjoin |
| 4 | +from pathlib import Path |
| 5 | +from subprocess import CalledProcessError |
5 | 6 |
|
6 | 7 | from setupbase import ( |
7 | | - create_cmdclass, ensure_python, get_version, |
8 | | - HERE |
| 8 | + command_for_func, create_cmdclass, ensure_python, |
| 9 | + get_version, HERE, run |
9 | 10 | ) |
10 | 11 |
|
11 | 12 | import setuptools |
|
17 | 18 | ensure_python('>=3.5') |
18 | 19 |
|
19 | 20 | # Get our version |
20 | | -version = get_version(pjoin(name, '_version.py')) |
| 21 | +version = get_version(str(Path(name) / '_version.py')) |
21 | 22 |
|
22 | | -lab_path = pjoin(HERE, name, 'labextension') |
| 23 | +lab_path = Path(HERE) / name / 'labextension' |
23 | 24 |
|
24 | 25 | data_files_spec = [ |
25 | | - ('share/jupyter/lab/extensions', lab_path, '*.tgz'), |
| 26 | + ('share/jupyter/lab/extensions', str(lab_path), '*.tgz'), |
26 | 27 | ('etc/jupyter/jupyter_notebook_config.d', |
27 | 28 | 'jupyter-config/jupyter_notebook_config.d', 'jupyterlab_git.json'), |
28 | 29 | ] |
29 | 30 |
|
30 | | -cmdclass = create_cmdclass(data_files_spec=data_files_spec) |
| 31 | +def runPackLabextension(): |
| 32 | + if Path('package.json').is_file(): |
| 33 | + try: |
| 34 | + run(['jlpm', 'build:labextension']) |
| 35 | + except CalledProcessError: |
| 36 | + pass |
| 37 | +pack_labext = command_for_func(runPackLabextension) |
| 38 | + |
| 39 | +cmdclass = create_cmdclass('pack_labext', data_files_spec=data_files_spec) |
| 40 | +cmdclass['pack_labext'] = pack_labext |
| 41 | +cmdclass.pop('develop') |
31 | 42 |
|
32 | 43 | with open("README.md", "r") as fh: |
33 | 44 | long_description = fh.read() |
|
0 commit comments