Skip to content

Commit

Permalink
build: migrate to pyproject.toml based build process
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko authored and maartenbreddels committed Dec 23, 2024
1 parent 5c8af3b commit 9592340
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 99 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install twine wheel jupyter-packaging jupyterlab
pip install hatch
- name: Build
run: |
python setup.py sdist bdist_wheel
hatch build
- name: Upload builds
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
Expand Down Expand Up @@ -93,19 +93,18 @@ jobs:
- linux: codestyle
coverage: false
- linux: py37-test
runs-on: ubuntu-22.04
- linux: py38-test
- linux: py313-test
- macos: py37-test
- macos: py310-test
- macos: py312-test
- windows: py39-test
- windows: py311-test
- linux: py37-notebooks
- linux: py38-notebooks
runs-on: ubuntu-22.04
- macos: py38-notebooks
- macos: py37-notebooks
runs-on: macos-13
- windows: py39-notebooks
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
*.egg-info
bqplot_image_gl/static
bqplot_image_gl/labextension
bqplot_image_gl/nbextension
dist
node_modules
.tox
.ipynb_checkpoints
.tmp
__pycache__
share
File renamed without changes.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"jupyterlab": {
"extension": "lib/labplugin",
"outputDir": "../share/jupyter/labextensions/bqplot-image-gl",
"outputDir": "../bqplot_image_gl/labextension",
"sharedPackages": {
"@jupyter-widgets/base": {
"bundled": false,
Expand Down
4 changes: 2 additions & 2 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = [
entry: './lib/extension.js',
output: {
filename: 'extension.js',
path: path.resolve(__dirname, '../share/jupyter/nbextensions/bqplot-image-gl'),
path: path.resolve(__dirname, '../bqplot_image_gl/nbextension'),
libraryTarget: 'amd',
devtoolModuleFilenameTemplate: 'webpack://jupyter-widgets/bqplot-image-gl/[resource-path]?[loaders]',
publicPath: "",
Expand All @@ -36,7 +36,7 @@ module.exports = [
entry: './lib/index.js',
output: {
filename: 'index.js',
path: path.resolve(__dirname, '../share/jupyter/nbextensions/bqplot-image-gl'),
path: path.resolve(__dirname, '../bqplot_image_gl/nbextension'),
libraryTarget: 'amd',
devtoolModuleFilenameTemplate: 'webpack://jupyter-widgets/bqplot-image-gl/[resource-path]?[loaders]',
publicPath: "",
Expand Down
89 changes: 84 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,85 @@
[build-system]
requires = ["jupyter_packaging>=0.10.6",
"jupyterlab>=3.6",
"setuptools>=40.8.0",
"wheel"]
build-backend = "setuptools.build_meta"
requires = [
"jupyterlab>=3.6",
"hatchling",
]
build-backend = "hatchling.build"

[project]
name = "bqplot-image-gl"
dynamic = ["version"]
description = "An ipywidget image widget for astronomical purposes"
readme = "README.md"
authors = [
{name = "Maarten A. Breddels", email = "[email protected]"},
]
requires-python = ">=3.7"
keywords = ["ipython", "jupyter", "widgets"]
license = {text = "MIT"} # Add appropriate license
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: IPython",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Multimedia :: Graphics",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
]
dependencies = [
"ipywidgets>=7.0.0",
"bqplot>=0.12",
"pillow"
]

[project.urls]
Homepage = "https://github.com/glue-viz/bqplot-image-gl"

[tool.hatch.version]
path = "bqplot_image_gl/_version.py"

[tool.hatch.build.targets.sdist]
exclude = [
".github",
]

[tool.hatch.build.targets.wheel]
include = [
"bqplot_image_gl",
"etc",
"js",
]

[tool.hatch.build]
artifacts = [
"bqplot_image_gl/nbextension",
"bqplot_image_gl/labextension",
]

[tool.hatch.build.targets.wheel.shared-data]
"bqplot_image_gl/nbextension" = "share/jupyter/nbextensions/bqplot-image-gl"
"bqplot_image_gl/labextension" = "share/jupyter/labextensions/bqplot-image-gl"
"./bqplot-image-gl.json" = "etc/jupyter/nbconfig/notebook.d/bqplot-image-gl.json"

[tool.hatch.build.hooks.jupyter-builder]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = [
"bqplot_image_gl/nbextension/index.js",
"bqplot_image_gl/labextension/package.json",
]
skip-if-exists = [
"bqplot_image_gl/nbextension/index.js",
"bqplot_image_gl/labextension/package.json",
]
dependencies = [
"hatch-jupyter-builder>=0.5.0",
]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
path = "./js"
build_cmd = "build"
85 changes: 2 additions & 83 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,2 @@
from __future__ import print_function
from os.path import join as pjoin
from setuptools import setup, find_packages, Command
import os

from jupyter_packaging import (
create_cmdclass,
install_npm,
ensure_targets,
combine_commands,
get_version,
skip_if_exists,
)

LONG_DESCRIPTION = 'An ipywidget image widget for astronomical purposes'
here = os.path.dirname(os.path.abspath(__file__))
name = 'bqplot-image-gl'
package_name = name.replace('-', '_')
version = get_version(pjoin(package_name, '_version.py'))

js_dir = pjoin(here, 'js')

# Representative files that should exist after a successful build
jstargets = [
pjoin('share', 'jupyter', 'nbextensions', f'{name}', 'index.js'),
# pjoin('share', 'jupyter', 'labextensions', f'{name}', 'package.json'),
]

data_files_spec = [
(f'share/jupyter/nbextensions/{name}', f'share/jupyter/nbextensions/{name}', '*.js'),
(f'share/jupyter/labextensions/{name}/', f'share/jupyter/labextensions/{name}/', '**'),
(f'etc/jupyter/nbconfig/notebook.d', f'etc/jupyter/nbconfig/notebook.d', f'{name}.json'),
]

js_command = combine_commands(
install_npm(js_dir, build_dir='share/jupyter/', source_dir='js/src', build_cmd='build'), ensure_targets(jstargets),
)

cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec)
is_repo = os.path.exists(os.path.join(here, '.git'))
if is_repo:
cmdclass['jsdeps'] = js_command
else:
cmdclass['jsdeps'] = skip_if_exists(jstargets, js_command)

setup(
name=name,
version=version,
description='An ipywidget image widget for astronomical purposes',
long_description=LONG_DESCRIPTION,
include_package_data=True,
install_requires=[
'ipywidgets>=7.0.0',
'bqplot>=0.12',
'pillow',
],
packages=find_packages(),
zip_safe=False,
cmdclass=cmdclass,
author='Maarten A. Breddels',
author_email='[email protected]',
url='https://github.com/glue-viz/bqplot-image-gl',
keywords=[
'ipython',
'jupyter',
'widgets',
],
classifiers=[
'Development Status :: 4 - Beta',
'Framework :: IPython',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Multimedia :: Graphics',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
],
)
# setup.py shim for use with applications that require it.
__import__("setuptools").setup()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist = py{36,37,38,39,310}-{test,notebooks}
requires = pip >= 18.0
setuptools >= 30.3.0
hatchling
isolated_build = true

[testenv]
Expand Down

0 comments on commit 9592340

Please sign in to comment.