Skip to content

Commit 5f7701a

Browse files
committed
added autobuild of labextension when installing with pip directly in repo
- also will do autobuild for various other setup.py commands (eg `python setup.py sdist bdist_wheel`) - no autobuild for dev install (eg `pip install -e .`)
1 parent a1f35cf commit 5f7701a

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ before_install:
99
- nvm install 10
1010
install: pip install pytest "jupyterlab~=1.1"
1111
script:
12-
# Build the labextension and bundle it
13-
- jlpm build:labextension
1412
# Build the sdist (identical to what will be uploaded to eg pypi on release)
1513
- python setup.py sdist
1614
# Install the extension from the sdist ensuring the cache is unused
1715
- pip install jupyterlab_git[test] --pre --no-index --find-links=dist --no-deps --no-cache-dir -v
1816
# Install the extension dependencies based on the current setup.py
19-
- pip install .[test]
17+
- pip install jupyterlab_git[test]
2018
- jupyter labextension list
2119
- jupyter lab build
2220
- pytest jupyterlab_git -r ap

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ pip install --upgrade jupyterlab-git
2424
jupyter lab build
2525
```
2626

27-
### Troubleshoot
27+
### Troubleshooting
2828

29-
- When you run JupyterLab, if you can see the Git sidepanel UI but you cannot get it to work, you may need to explicitly enable the serverextension. Do:
29+
- When you run JupyterLab, if you can see the Git sidepanel UI but you cannot get it to work, you may need to explicitly enable the serverextension by running:
3030

3131
```bash
3232
jupyter serverextension enable --py jupyterlab_git

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
],
1414
"scripts": {
1515
"build": "jlpm install && tsc",
16-
"build:clean": "jlpm install && jlpm clean && tsc",
17-
"build:labextension": "jlpm build:clean && jlpm clean:labextension && mkdirp jupyterlab_git/labextension && cd jupyterlab_git/labextension && npm pack ../..",
16+
"build:labextension": "jlpm build && jlpm clean:labextension && mkdirp jupyterlab_git/labextension && cd jupyterlab_git/labextension && npm pack ../..",
1817
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
19-
"clean:more": "jlpm clean && rimraf build && rimraf dist && rimraf package && rimraf *.tgz",
18+
"clean:more": "jlpm clean && rimraf build && rimraf dist",
2019
"clean:labextension": "rimraf jupyterlab_git/labextension",
2120
"clean:slate": "jlpm clean:more && jlpm clean:labextension && rimraf node_modules",
2221
"watch": "tsc -w",

setup.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""
22
Setup Module to setup Python Handlers (Git Handlers) for the Git Plugin.
33
"""
4-
from os.path import join as pjoin
4+
from pathlib import Path
5+
from subprocess import CalledProcessError
56

67
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
910
)
1011

1112
import setuptools
@@ -17,17 +18,27 @@
1718
ensure_python('>=3.5')
1819

1920
# Get our version
20-
version = get_version(pjoin(name, '_version.py'))
21+
version = get_version(str(Path(name) / '_version.py'))
2122

22-
lab_path = pjoin(HERE, name, 'labextension')
23+
lab_path = Path(HERE) / name / 'labextension'
2324

2425
data_files_spec = [
25-
('share/jupyter/lab/extensions', lab_path, '*.tgz'),
26+
('share/jupyter/lab/extensions', str(lab_path), '*.tgz'),
2627
('etc/jupyter/jupyter_notebook_config.d',
2728
'jupyter-config/jupyter_notebook_config.d', 'jupyterlab_git.json'),
2829
]
2930

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')
3142

3243
with open("README.md", "r") as fh:
3344
long_description = fh.read()

0 commit comments

Comments
 (0)