Skip to content

Commit

Permalink
Merge pull request #81 from fcollonval/fix/setup
Browse files Browse the repository at this point in the history
Update Python setup for Python 3.10
  • Loading branch information
ildipo committed Jun 14, 2022
2 parents 014aa6d + a2b75b4 commit 61d4433
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 83 deletions.
15 changes: 15 additions & 0 deletions beakerx_widgets/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
include setup.py
graft beakerx/static
graft beakerx/labextension

graft beakerx/js

# Javascript files
graft js
prune **/node_modules
prune js/lib
prune js/css
prune js/dist

include LICENSE
include NOTICE
include pyproject.toml
include beakerx.json

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
6 changes: 5 additions & 1 deletion beakerx_widgets/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
"name": "@beakerx/beakerx-widgets",
"version": "2.3.11",
"description": "BeakerX: Beaker EasyForms, Magics, Plots and Spark Extension for Jupyter Lab 2.x",
"homepage": "http://beakerx.com/",
"keywords": [
"jupyter",
"jupyterlab",
"jupyterlab notebook",
"jupyterlab-extension"
],
"author": "Two Sigma Open Source, LLC",
"author": {
"name": "Two Sigma Open Source, LLC",
"email": "beakerx-feedback@twosigma.com"
},
"main": "lib/jupyterlab-plugin",
"license": "Apache-2.0",
"repository": {
Expand Down
11 changes: 11 additions & 0 deletions beakerx_widgets/js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const path = require('path');
const pkg = require('./package.json');

const crypto = require('crypto');

// Workaround for loaders using "md4" by default, which is not supported in FIPS-compliant OpenSSL
// Xref: https://github.com/jupyterlab/jupyterlab/pull/11249
const cryptoOrigCreateHash = crypto.createHash;
crypto.createHash = (algorithm) => cryptoOrigCreateHash(algorithm == 'md4' ? 'sha256' : algorithm);

var rules = [
{
test: /\.css$/i,
Expand Down Expand Up @@ -72,6 +79,7 @@ module.exports = [
filename: 'extension.js',
path: BEAKERX_STATIC_PATH,
libraryTarget: 'amd',
hashFunction: 'sha256',
},
devtool: 'inline-source-map',
externals: [
Expand All @@ -97,6 +105,7 @@ module.exports = [
filename: 'tree-extension.js',
path: BEAKERX_STATIC_PATH,
libraryTarget: 'amd',
hashFunction: 'sha256',
},
devtool: 'inline-source-map',
module: {
Expand All @@ -112,6 +121,7 @@ module.exports = [
filename: 'index.js',
path: BEAKERX_STATIC_PATH,
libraryTarget: 'amd',
hashFunction: 'sha256',
},
devtool: 'inline-source-map',
module: {
Expand All @@ -128,6 +138,7 @@ module.exports = [
path: BEAKERX_DIST_PATH,
libraryTarget: 'amd',
// publicPath: 'https://unpkg.com/' + pkg.name + '@' + pkg.version + '/dist/'
hashFunction: 'sha256',
},
devtool: 'inline-source-map',
module: {
Expand Down
17 changes: 15 additions & 2 deletions beakerx_widgets/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.0.0,==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
build-backend = "jupyter_packaging.build_api"

[tool.jupyter-packaging.options]
ensured-targets = ["beakerx/static/index.js", "beakerx/labextension/package.json"]

[tool.jupyter-packaging.builder]
factory = "jupyter_packaging.npm_builder"

[tool.jupyter-packaging.build-args]
path = "js"
build_cmd = "build:labextension"
npm = ["yarn"]
build_dir = "js/dist"
source_dir = "js/src"
File renamed without changes.
174 changes: 94 additions & 80 deletions beakerx_widgets/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,107 +15,121 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from os import path
import json
import sys
from pathlib import Path

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

from setuptools import setup, find_packages
import setuptools

# The name of the project
name = 'beakerx'
npm_name = '@beakerx/beakerx-widgets'
HERE = Path(__file__).parent.resolve()

HERE = path.dirname(path.abspath(__file__))
# Get the package info from package.json
pkg_json_path = HERE / "js/package.json"
pkg_json = json.loads(pkg_json_path.read_bytes())

# Ensure a valid python version
ensure_python('>=3.6')

# Get our version
version = get_version(path.join(name, '_version.py'))
# The name of the project
name = "beakerx"

nb_path = path.join(HERE, name, 'static')
lab_path = path.join(HERE, name, 'labextension')
lab_path = (pkg_json_path.parent / pkg_json["jupyterlab"]["outputDir"]).resolve()
nb_path = HERE / name / "static"

# Representative files that should exist after a successful build
jstargets = [
path.join(nb_path, 'index.js'),
path.join(lab_path, 'package.json'),
ensured_targets = [
str(nb_path / "index.js"),
str(lab_path / "package.json"),
]

package_data_spec = {
name: [
'static/*',
'labextension/*'
]
}
labext_name = pkg_json["name"]

data_files_spec = [
('share/jupyter/nbextensions/beakerx', nb_path, '**'),
("share/jupyter/labextensions/" + npm_name, lab_path, "**"),
('etc/jupyter/nbconfig/notebook.d', HERE, 'beakerx.json')
(
"share/jupyter/nbextensions/beakerx",
str(nb_path.relative_to(HERE)),
"**",
),
(
"share/jupyter/labextensions/%s" % labext_name,
str(lab_path.relative_to(HERE)),
"**",
),
("etc/jupyter/nbconfig/notebook.d", str(HERE), "beakerx.json"),
]

cmdclass = create_cmdclass('js', package_data_spec=package_data_spec, data_files_spec=data_files_spec)
cmdclass['js'] = combine_commands(
install_npm(
path=path.join(HERE, 'js'),
npm=["yarn"],
build_cmd="build:labextension",
build_dir=path.join(HERE, 'js', 'dist'),
source_dir=path.join(HERE, 'js', 'src')
),
ensure_targets(jstargets),
version = (
pkg_json["version"]
.replace("-alpha.", "a")
.replace("-beta.", "b")
.replace("-rc.", "rc")
)

setup_args = dict(
name=name,
description='BeakerX: Beaker Extensions for Jupyter Notebook',
long_description='BeakerX: Beaker Extensions for Jupyter Notebook',
version=version,
author='Two Sigma Open Source, LLC',
author_email='beakerx-feedback@twosigma.com',
url='http://beakerx.com',
keywords=[
'ipython',
'jupyter',
'widgets'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Framework :: IPython',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Topic :: Multimedia :: Graphics',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7'
],
entry_points={
'console_scripts': [
'beakerx = beakerx:run'
]
},
url=pkg_json["homepage"],
author=pkg_json["author"]["name"],
author_email=pkg_json["author"]["email"],
description=pkg_json["description"],
license=pkg_json["license"],
license_file="LICENSE",
long_description=pkg_json["description"],
packages=setuptools.find_packages(),
install_requires=[
'beakerx_base>=2.0.1',
'requests',
'pandas',
'bottle',
'pyspark',
'jupyter-server'
"beakerx_base>=2.0.1",
"requests",
"pandas",
"bottle",
"pyspark",
"jupyter-server",
],
python_requires='>=3',
zip_safe=False,
include_package_data=True,
packages=find_packages(),
cmdclass=cmdclass
python_requires=">=3",
platforms="Linux, Mac OS X, Windows",
keywords=["ipython", "jupyter", "widgets"],
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Development Status :: 5 - Production/Stable",
"Framework :: IPython",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Multimedia :: Graphics",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
entry_points={"console_scripts": ["beakerx = beakerx:run"]},
)

if __name__ == '__main__':
setup(**setup_args)
try:
from jupyter_packaging import wrap_installers, npm_builder, get_data_files

post_develop = npm_builder(
path=str(pkg_json_path.parent),
build_cmd="build:labextension",
source_dir=str(pkg_json_path.parent / "src"),
build_dir=str(pkg_json_path.parent / "dist"),
npm=["yarn"],
)
setup_args["cmdclass"] = wrap_installers(
post_develop=post_develop, ensured_targets=ensured_targets
)
setup_args["data_files"] = get_data_files(data_files_spec)
except ImportError as e:
import logging

logging.basicConfig(format="%(levelname)s: %(message)s")
logging.warning(
"Build tool `jupyter-packaging` is missing. Install it with pip or conda."
)
if not ("--name" in sys.argv or "--version" in sys.argv):
raise e

if __name__ == "__main__":
setuptools.setup(**setup_args)

0 comments on commit 61d4433

Please sign in to comment.