Skip to content

Commit 49e3261

Browse files
committed
fixed up the unified build and bundle for release on pypi
- No more pointless ts/js sources outside of the bundled labextension .tar.gz - No more pointless Typescript rebuilds/npm packing (eg when creating a wheel from the sdist) - The enduser no longer needs node to build from the sdist - Single unified versioning, based on the current python package version - Added release.py script to paritally automate release
1 parent a78cac8 commit 49e3261

File tree

6 files changed

+115
-57
lines changed

6 files changed

+115
-57
lines changed

.travis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ 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
14+
# Build the sdist (identical to what will be uploaded to eg pypi on release)
1215
- python setup.py sdist
13-
# Install the extension ensuring the cache is unused
16+
# Install the extension from the sdist ensuring the cache is unused
1417
- pip install jupyterlab_git[test] --pre --no-index --find-links=dist --no-deps --no-cache-dir -v
15-
# Install the extension dependencies
16-
- pip install jupyterlab_git[test]
18+
# Install the extension dependencies based on the current setup.py
19+
- pip install .[test]
1720
- jupyter labextension list
1821
- jupyter lab build
1922
- pytest jupyterlab_git -r ap

MANIFEST.in

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,8 @@ include README.md
33

44
include setupbase.py
55

6-
include package.json
7-
include *.config.js
8-
include setupJest.js
9-
include ts*.json
106
include jupyterlab_git/labextension/*.tgz
117

12-
# Tests
13-
graft tests
14-
prune tests/build
15-
16-
# Javascript files
17-
graft schema
18-
graft src
19-
graft style
20-
prune **/node_modules
21-
prune lib
22-
238
# Patterns to exclude from any directory
249
global-exclude *~
2510
global-exclude *.pyc

README.md

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

27+
### Troubleshoot
28+
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:
30+
31+
```bash
32+
jupyter serverextension enable --py jupyterlab_git
33+
```
34+
2735
## Development
2836

2937
### Contributing
@@ -55,17 +63,19 @@ If you would like to be listed, please submit a pull request with your informati
5563
Requires node 4+ and npm 4+
5664

5765
```bash
66+
# Install new-ish JupyterLab
67+
pip install -U jupyterlab
68+
5869
# Clone the repo to your local environment
5970
git clone https://github.com/jupyterlab/jupyterlab-git.git
6071
cd jupyterlab-git
61-
# Install JupyterLab
62-
pip install jupyterlab
63-
# Install Javascript dependencies
64-
jlpm install
65-
# Install the server extension in development mode
72+
73+
# Install the server extension in development mode and enable it
6674
pip install -e .[test]
6775
jupyter serverextension enable --py jupyterlab_git
68-
# Link your development version of the extension with JupyterLab
76+
77+
# Build the labextension and dev-mode link it to jlab
78+
jlpm build
6979
jupyter labextension link .
7080
```
7181

@@ -81,4 +91,4 @@ To execute the tests
8191
```bash
8292
pytest jupyterlab_git
8393
jlpm run test
84-
```
94+
```

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
"jupyterlab-extension"
1313
],
1414
"scripts": {
15-
"build": "jlpm run build:lib",
16-
"build:labextension": "cd jupyterlab_git && rimraf labextension && mkdirp labextension && cd labextension && npm pack ../..",
17-
"build:lib": "tsc",
18-
"build:all": "jlpm run build:labextension",
19-
"clean": "jlpm run clean:lib",
20-
"clean:lib": "rimraf lib && rimraf tsconfig.tsbuildinfo",
15+
"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 ../..",
18+
"clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
19+
"clean:more": "jlpm clean && rimraf build && rimraf dist && rimraf package && rimraf *.tgz",
2120
"clean:labextension": "rimraf jupyterlab_git/labextension",
22-
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
23-
"prepare": "jlpm run clean && jlpm run build",
21+
"clean:slate": "jlpm clean:more && jlpm clean:labextension && rimraf node_modules",
2422
"watch": "tsc -w",
2523
"test": "jest",
2624
"lint": "tslint --project .",

release.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python
2+
3+
import json
4+
import subprocess
5+
6+
from setupbase import get_version
7+
8+
def buildBundle():
9+
subprocess.run(['jlpm', 'clean:slate'])
10+
subprocess.run(['jlpm', 'build:labextension'])
11+
12+
def tag(version, kind=None):
13+
"""git tagging
14+
"""
15+
kw = {'version': version, 'kind': kind}
16+
tag = "{kind}_v{version}".format(**kw) if kind else "v{version}".format(**kw)
17+
18+
subprocess.run(['git', 'tag', tag])
19+
subprocess.run(['git', 'push', 'origin', tag])
20+
21+
def pypi(bdist=True, test=False):
22+
"""release on pypi
23+
"""
24+
if bdist:
25+
# build the source (sdist) and binary wheel (bdist) releases
26+
subprocess.run(['python', 'setup.py', 'sdist', 'bdist_wheel'])
27+
else:
28+
# build just the source release
29+
subprocess.run(['python', 'setup.py', 'sdist'])
30+
31+
if test:
32+
# release to the test server
33+
subprocess.run(['twine', 'upload', '--repository-url', 'https://test.pypi.org/legacy/', 'dist/*'])
34+
else:
35+
# release to the production server
36+
subprocess.run(['twine', 'upload', 'dist/*'])
37+
38+
def npmjs(dryRun=False):
39+
"""release on npmjs
40+
"""
41+
if dryRun:
42+
# dry run build and release
43+
subprocess.run(['npm', 'publish', '--access', 'public', '--dry-run'])
44+
else:
45+
# build and release
46+
subprocess.run(['npm', 'publish', '--access', 'public'])
47+
48+
def labExtensionVersion(version=None):
49+
if version:
50+
# force the labextension version to match the supplied version
51+
subprocess.run(['npm', '--no-git-tag-version', 'version', version, '--force', '--allow-same-version'])
52+
else:
53+
# get single source of truth from the Typescript labextension
54+
with open('package.json') as f:
55+
info = json.load(f)
56+
57+
version = info['version']
58+
59+
return version
60+
61+
def serverExtensionVersion():
62+
# get single source of truth from the Python serverextension
63+
return get_version('jupyterlab_hdf/_version.py')
64+
65+
def doRelease():
66+
# do a clean build of the bundle
67+
buildBundle()
68+
69+
# treat the serverextension version as the "real" single source of truth
70+
version = serverExtensionVersion()
71+
# force the labextension version to agree with the serverextension version
72+
labExtensionVersion(version=version)
73+
74+
# tag with version and push the tag
75+
tag(version=version)
76+
77+
# release to pypi and npmjs
78+
pypi()
79+
npmjs()
80+
81+
if __name__=="__main__":
82+
doRelease()

setup.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
from os.path import join as pjoin
55

66
from setupbase import (
7-
create_cmdclass, install_npm, ensure_targets,
8-
combine_commands, ensure_python, get_version,
7+
create_cmdclass, ensure_python, get_version,
98
HERE
109
)
1110

@@ -22,32 +21,13 @@
2221

2322
lab_path = pjoin(HERE, name, 'labextension')
2423

25-
# Representative files that should exist after a successful build
26-
jstargets = [
27-
pjoin(HERE, 'lib', 'git.js'),
28-
]
29-
30-
package_data_spec = {
31-
name: [
32-
'*'
33-
]
34-
}
35-
3624
data_files_spec = [
3725
('share/jupyter/lab/extensions', lab_path, '*.tgz'),
3826
('etc/jupyter/jupyter_notebook_config.d',
3927
'jupyter-config/jupyter_notebook_config.d', 'jupyterlab_git.json'),
4028
]
4129

42-
cmdclass = create_cmdclass('jsdeps',
43-
package_data_spec=package_data_spec,
44-
data_files_spec=data_files_spec
45-
)
46-
47-
cmdclass['jsdeps'] = combine_commands(
48-
install_npm(HERE, build_cmd='build:all', npm='jlpm'),
49-
ensure_targets(jstargets),
50-
)
30+
cmdclass = create_cmdclass(data_files_spec=data_files_spec)
5131

5232
with open("README.md", "r") as fh:
5333
long_description = fh.read()
@@ -76,7 +56,7 @@
7656
'Programming Language :: Python :: 3.7',
7757
'Framework :: Jupyter',
7858
],
79-
include_package_data = True,
59+
# include_package_data = True,
8060
install_requires = [
8161
'notebook',
8262
'nbdime >= 1.1.0',
@@ -85,7 +65,7 @@
8565
extras_require = {
8666
'test': [
8767
'pytest',
88-
'jupyterlab~=1.0',
68+
'jupyterlab~=1.1',
8969
],
9070
},
9171
)

0 commit comments

Comments
 (0)