Skip to content

Commit cfc9ee1

Browse files
committed
added auto-enable to pip dev install
1 parent acdcc30 commit cfc9ee1

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jupyter labextension list
4040

4141
- Be sure to be in a Git repository in the filebrowser tab
4242

43-
- Check the server log. If you see a warning with a 404 code similar to:
43+
- Check the server log. If you see a warning with a 404 code similar to:
4444
`[W 00:27:41.800 LabApp] 404 GET /git/server_root?1576081660665`
4545

4646
Explicitly enable the server extension by running:
@@ -106,7 +106,6 @@ cd jupyterlab-git
106106
107107
# Install the server extension in development mode and enable it
108108
pip install -e .[test]
109-
jupyter serverextension enable --py jupyterlab_git
110109
111110
# Build the labextension and dev-mode link it to jlab
112111
jlpm build

setup.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
)
1313

1414
import setuptools
15+
from setuptools.command.develop import develop
1516

1617
# The name of the project
1718
name='jupyterlab_git'
@@ -38,9 +39,36 @@ def runPackLabextension():
3839
pass
3940
pack_labext = command_for_func(runPackLabextension)
4041

42+
class DevelopAndEnable(develop):
43+
def run(self):
44+
develop.run(self)
45+
46+
list_cmd = [
47+
'jupyter',
48+
'serverextension',
49+
'list'
50+
]
51+
enable_cmd = [
52+
'jupyter',
53+
'serverextension',
54+
'enable',
55+
'--py',
56+
'jupyterlab_git'
57+
]
58+
59+
# test if `jupyter` cmd is available
60+
try:
61+
run(list_cmd)
62+
except:
63+
print('`jupyter` cmd not installed, skipping serverextension activation...')
64+
return
65+
66+
print('Enabling serverextension...')
67+
run(enable_cmd)
68+
4169
cmdclass = create_cmdclass('pack_labext', data_files_spec=data_files_spec)
4270
cmdclass['pack_labext'] = pack_labext
43-
cmdclass.pop('develop')
71+
cmdclass['develop'] = DevelopAndEnable
4472

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

0 commit comments

Comments
 (0)