Skip to content

Commit bb12521

Browse files
authored
Merge pull request #3138 from jasongrout/newpackaging
Modernize the packaging for ipywidgets
2 parents d31600e + c4d9c21 commit bb12521

File tree

17 files changed

+217
-419
lines changed

17 files changed

+217
-419
lines changed

.github/workflows/packaging.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,23 @@ jobs:
4949
5050
- name: Install dependencies
5151
run: |
52-
python -m pip install --upgrade pip wheel
53-
python -m pip install setuptools jupyter_packaging "jupyterlab>=3,<4"
52+
python -m pip install --upgrade pip wheel build jupyterlab~=3.0
5453
- name: Build PyPI distributions for ipywidgets
5554
run: |
56-
python setup.py sdist bdist_wheel
55+
python -m build
56+
- name: Build and link packages
57+
run: |
58+
yarn install
59+
yarn run build
5760
- name: Build PyPI distributions for jupyterlab_widgets
5861
run: |
59-
jlpm
60-
jlpm run build
6162
cd jupyterlab_widgets
62-
python setup.py sdist bdist_wheel
63+
python -m build
6364
cp ./dist/* ../dist
6465
- name: Build PyPI distributions for widgetsnbextension
6566
run: |
66-
jlpm
67-
jlpm run build
6867
cd widgetsnbextension
69-
python setup.py sdist bdist_wheel
68+
python -m build
7069
cp ./dist/* ../dist
7170
- name: Build checksum file
7271
run: |

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,18 @@ Examples of custom widget libraries built upon ipywidgets are
6969
The stable version of ipywidgets can be installed with [pip](#with-pip) or [conda](#with-conda).
7070
If using JupyterLab, review the [Front-end extension for JupyterLab](#front-end-extension-for-jupyterlab) section.
7171

72-
### With pip
72+
With pip:
7373

7474
```sh
7575
pip install ipywidgets
76-
# Skip the next step if using JupyterLab or Classic notebook version 5.3 and above
77-
jupyter nbextension enable --py --sys-prefix widgetsnbextension
7876
```
7977

80-
### With conda
78+
With conda:
8179

8280
```sh
8381
conda install -c conda-forge ipywidgets
8482
```
8583

86-
### Front-end extension for JupyterLab
87-
88-
Install the front-end extension to JupyterLab (note that this requires nodejs
89-
to be installed):
90-
91-
- For JupyterLab 1.0.x and 1.1.x, use `jupyter labextension install @jupyter-widgets/[email protected]`
92-
- For JupyterLab 1.2.x, use `jupyter labextension install @jupyter-widgets/[email protected]`
93-
- For JupyterLab 2.x, use `jupyter labextension install @jupyter-widgets/[email protected]`
94-
95-
See the [Installation](docs/source/user_install.md) section of the documentation
96-
for additional details.
97-
9884
### Developer install from source
9985

10086
Installing from source is more complicated and requires a developer install,

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ numpy
77
recommonmark
88
sphinx>=1.4.6
99
sphinx_rtd_theme
10+
packaging

docs/source/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535

3636
_release = {}
3737
exec(compile(open('../../ipywidgets/_version.py').read(), '../../ipywidgets/_version.py', 'exec'), _release)
38-
version = '.'.join(map(str, _release['version_info'][:2]))
38+
from packaging.version import Version
39+
v = Version(_release['__version__'])
40+
version = f'{v.major}.{v.minor}'
3941
release = _release['__version__']
4042

4143
# Add any paths that contain templates here, relative to this directory.

docs/source/dev_release.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Lerna will prompt you for version numbers for each of the changed npm packages i
5959

6060
Go into the `jupyterlab_widgets` directory. Change `jupyterlab_widgets/_version.py` to reflect the new version number.
6161
```
62-
python setup.py sdist bdist_wheel
63-
twine check dist/*
62+
pip install build
63+
python -m build
6464
twine upload dist/*
6565
```
6666

@@ -73,7 +73,8 @@ curl -s https://pypi.org/pypi/jupyterlab-widgets/json | jq -r '[.releases[][] |
7373

7474
Go into the `widgetsnbextension` directory. Change `widgetsnbextension/_version.py` to reflect the new version number.
7575
```
76-
python setup.py sdist bdist_wheel
76+
pip install build
77+
python -m build
7778
twine upload dist/*
7879
```
7980

@@ -87,7 +88,8 @@ curl -s https://pypi.org/pypi/widgetsnbextension/json | jq -r '[.releases[][] |
8788
Change `ipywidgets/_version.py` to reflect the new version number, and if necessary, a new `__html_manager_version__`. Change the `install_requires` parameter in `setup.py` reference the new widgetsnbextension version.
8889

8990
```
90-
python setup.py sdist bdist_wheel
91+
pip install build
92+
python -m build
9193
twine upload dist/*
9294
```
9395

ipywidgets/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
accessible as a `value` attribute.
1818
"""
1919

20-
import os
20+
# Must import __version__ first to avoid errors importing this file during the build process. See https://github.com/pypa/setuptools/issues/1724#issuecomment-627241822
21+
from ._version import __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__
2122

23+
import os
2224
from IPython import get_ipython
23-
from ._version import version_info, __version__, __protocol_version__, __jupyter_widgets_controls_version__, __jupyter_widgets_base_version__
2425
from .widgets import *
2526
from traitlets import link, dlink
2627

ipywidgets/_version.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
33

4-
5-
version_info = (8, 0, 0, 'alpha', 3)
6-
7-
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
8-
9-
__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
10-
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
4+
__version__ = '8.0.0a3'
115

126
__protocol_version__ = '2.0.0'
137

ipywidgets/widgets/tests/test_widget_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def test_append_display_data():
202202

203203
# Now try appending an Image.
204204
image_data = b"foobar"
205-
image_data_b64 = image_data if sys.version_info[0] < 3 else 'Zm9vYmFy\n'
205+
image_data_b64 = 'Zm9vYmFy\n'
206206

207207
widget.append_display_data(Image(image_data, width=123, height=456))
208208
expected += (

jupyterlab_widgets/setup.cfg

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[metadata]
2+
name = jupyterlab_widgets
3+
version = attr: jupyterlab_widgets._version.__version__
4+
author = Jupyter Development Team
5+
author_email = [email protected]
6+
url = https://github.com/jupyter-widgets/ipywidgets
7+
description = Jupyter interactive widgets for JupyterLab
8+
long_description = file: README.md
9+
long_description_content_type = text/markdown
10+
license_file = LICENSE
11+
license = BSD-3-Clause
12+
platforms = Linux, Mac OS X, Windows
13+
keywords = Interactive, Interpreter, Shell, Web, notebook, widgets, Jupyter, JupyterLab, JupyterLab3
14+
classifiers =
15+
Intended Audience :: Developers
16+
Intended Audience :: System Administrators
17+
Intended Audience :: Science/Research
18+
License :: OSI Approved :: BSD License
19+
Programming Language :: Python
20+
Programming Language :: Python :: 3
21+
Programming Language :: Python :: 3.6
22+
Programming Language :: Python :: 3.7
23+
Programming Language :: Python :: 3.8
24+
Programming Language :: Python :: 3.9
25+
Programming Language :: Python :: 3 :: Only
26+
Framework :: Jupyter
27+
28+
[options]
29+
python_requires = >=3.6
30+
zip_safe=False
31+
include_package_data = True
32+
packages = find:

jupyterlab_widgets/setup.py

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,33 @@
1+
# Copyright (c) Jupyter Development Team.
2+
# Distributed under the terms of the Modified BSD License.
3+
14
"""
25
jupyterlab_widgets setup
36
"""
4-
import os
5-
67
from jupyter_packaging import (
78
create_cmdclass, install_npm, ensure_targets,
89
combine_commands, ensure_python, get_version,
910
skip_if_exists
1011
)
11-
import setuptools
12+
from pathlib import Path
13+
from setuptools import setup
1214

13-
HERE = os.path.abspath(os.path.dirname(__file__))
15+
HERE = Path(__file__).parent.resolve()
16+
IS_REPO = (HERE.parent / '.git').exists()
17+
LAB_PATH = HERE / "jupyterlab_widgets" / "labextension"
1418

1519
# The name of the project
1620
name = "jupyterlab_widgets"
17-
18-
# Ensure a valid python version
19-
ensure_python(">=3.6")
20-
21-
# Get our version
22-
version = get_version(os.path.join(name, "_version.py"))
23-
24-
lab_path = os.path.join(HERE, name, "labextension")
21+
labext_name = "@jupyter-widgets/jupyterlab-manager"
2522

2623
# Representative files that should exist after a successful build
27-
jstargets = [
28-
os.path.join(lab_path, "package.json"),
29-
]
24+
jstargets = [LAB_PATH / "package.json"]
3025

31-
package_data_spec = {
32-
name: [
33-
"*"
34-
]
35-
}
36-
37-
labext_name = "@jupyter-widgets/jupyterlab-manager"
26+
package_data_spec = {name: ["*"]}
3827

3928
data_files_spec = [
40-
("share/jupyter/labextensions/%s" % labext_name, lab_path, "**"),
41-
("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"),
29+
(f"share/jupyter/labextensions/{labext_name}", LAB_PATH, "**"),
30+
(f"share/jupyter/labextensions/{labext_name}", HERE, "install.json"),
4231
]
4332

4433
cmdclass = create_cmdclass(
@@ -55,43 +44,10 @@
5544
ensure_targets(jstargets),
5645
)
5746

58-
is_repo = os.path.exists(os.path.join(HERE, os.pardir, ".git"))
59-
if is_repo:
47+
if IS_REPO:
6048
cmdclass["jsdeps"] = js_command
6149
else:
6250
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command)
6351

64-
with open("README.md", "r") as fh:
65-
long_description = fh.read()
66-
67-
setup_args = dict(
68-
name=name,
69-
version=version,
70-
url="https://github.com/jupyter-widgets/ipywidgets",
71-
author="Jupyter Development Team",
72-
description="A JupyterLab extension.",
73-
long_description= long_description,
74-
long_description_content_type="text/markdown",
75-
cmdclass=cmdclass,
76-
packages=setuptools.find_packages(),
77-
install_requires=[],
78-
zip_safe=False,
79-
include_package_data=True,
80-
python_requires=">=3.6",
81-
license="BSD-3-Clause",
82-
platforms="Linux, Mac OS X, Windows",
83-
keywords=["Jupyter", "JupyterLab", "JupyterLab3"],
84-
classifiers=[
85-
"License :: OSI Approved :: BSD License",
86-
"Programming Language :: Python",
87-
"Programming Language :: Python :: 3",
88-
"Programming Language :: Python :: 3.6",
89-
"Programming Language :: Python :: 3.7",
90-
"Programming Language :: Python :: 3.8",
91-
"Framework :: Jupyter",
92-
],
93-
)
94-
95-
9652
if __name__ == "__main__":
97-
setuptools.setup(**setup_args)
53+
setup(cmdclass=cmdclass)

0 commit comments

Comments
 (0)