def download_css_first(command): class CSSFirst(command): def run(self): self.distribution.run_command("download_css") return command.run(self) return CSSFirst try: from jupyter_packaging import wrap_installers, npm_builder, get_data_files # In develop mode, just run yarn builder = npm_builder(build_cmd="build", npm="jlpm", force=True) cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets) cmdclass["download_css"] = FetchCSS cmdclass["develop"] = download_css_first(cmdclass["develop"]) cmdclass["sdist"] = download_css_first(cmdclass["sdist"]) cmdclass["bdist_wheel"] = download_css_first(cmdclass["bdist_wheel"]) setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec)) except ImportError: setup_args = dict() if __name__ == "__main__": setuptools.setup(**setup_args)
platforms="Linux, Mac OS X, Windows", keywords=["Jupyter", "JupyterLab", "JupyterLab3"], classifiers=[ "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Framework :: Jupyter", ], ) try: from jupyter_packaging import ( wrap_installers, npm_builder, get_data_files ) post_develop = npm_builder( build_cmd="build:prod", source_dir="src", build_dir=lab_path ) 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: pass if __name__ == "__main__": setuptools.setup(**setup_args)
] ensured_targets = [osp.join(HERE, NAME, t) for t in ensured_targets] def post_dist(): target = pjoin(HERE, NAME, 'static', 'package.json') with open(target) as fid: version = json.load(fid)['jupyterlab']['version'] if Version(version) != Version(get_version(f'{NAME}/_version.py')): raise ValueError('Version mismatch, please run `build:update`') npm = ['node', pjoin(HERE, NAME, 'staging', 'yarn.js')] # In develop mode, just run yarn builder = npm_builder(build_cmd=None, npm=npm, force=True) cmdclass = wrap_installers(post_develop=builder, post_dist=post_dist, ensured_targets=ensured_targets) data_files_spec = [ ('share/jupyter/lab/static', f'{NAME}/static', '**'), ('share/jupyter/lab/schemas', f'{NAME}/schemas', '**'), ('share/jupyter/lab/themes', f'{NAME}/themes', '**'), ('etc/jupyter/jupyter_server_config.d', 'jupyter-config/jupyter_server_config.d', f'{NAME}.json'), ('etc/jupyter/jupyter_notebook_config.d', 'jupyter-config/jupyter_notebook_config.d', f'{NAME}.json'), ] setup_args = dict( cmdclass=cmdclass, data_files=get_data_files(data_files_spec)
ensured_targets = [ str(lab_path / "package.json"), str(lab_path / "static" / "style.js"), ] data_files_spec = [ ("share/jupyter/labextensions/%s" % NAME, lab_path, "**"), ("share/jupyter/labextensions/%s" % NAME, HERE, "install.json"), ] try: from jupyter_packaging import wrap_installers, npm_builder, get_data_files # In develop mode, just run yarn builder = npm_builder(build_cmd="build", build_dir=lab_path, source_dir="src") cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets) setup_args = dict( cmdclass=cmdclass, data_files=get_data_files(data_files_spec), ) except ImportError: setup_args = dict() # Get the package info from package.json pkg_json = json.loads((HERE / "package.json").read_bytes()) setup_args["version"] = pkg_json["version"]
from setuptools import setup try: from jupyter_packaging import wrap_installers, npm_builder ensured_targets = ["jupyter_server/static/style/bootstrap.min.css"] cmdclass = wrap_installers(pre_develop=npm_builder(), ensured_targets=ensured_targets) except ImportError: cmdclass = {} setup(cmdclass=cmdclass)
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Framework :: Jupyter", "Framework :: Jupyter :: JupyterLab", "Framework :: Jupyter :: JupyterLab :: 3", "Framework :: Jupyter :: JupyterLab :: Extensions", "Framework :: Jupyter :: JupyterLab :: Extensions :: Mime Renderers", "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", ], ) try: from jupyter_packaging import ( wrap_installers, npm_builder, get_data_files ) builder = npm_builder(HERE, build_cmd="build", npm=["jlpm"]) cmdclass = wrap_installers(pre_develop=builder, ensured_targets=ensured_targets) setup_args['cmdclass'] = cmdclass setup_args['data_files'] = get_data_files(data_files_spec) except ImportError: pass if __name__ == "__main__": setuptools.setup(**setup_args)
jupyterlab_widgets setup """ from jupyter_packaging import (wrap_installers, npm_builder, get_data_files) from pathlib import Path from setuptools import setup HERE = Path(__file__).parent.resolve() IS_REPO = (HERE.parent / '.git').exists() LAB_PATH = HERE / "jupyterlab_widgets" / "labextension" # The name of the project name = "jupyterlab_widgets" labext_name = "@jupyter-widgets/jupyterlab-manager" data_files_spec = [ (f"share/jupyter/labextensions/{labext_name}", LAB_PATH, "**"), (f"share/jupyter/labextensions/{labext_name}", HERE, "install.json"), ] post_develop = npm_builder(build_cmd="install:extension", source_dir="src", build_dir=LAB_PATH) cmdclass = wrap_installers(post_develop=post_develop) if __name__ == "__main__": setup( cmdclass=cmdclass, data_files=get_data_files(data_files_spec), )
data_files_spec = [ ("etc/jupyter/jupyter_server_config.d", "etc/jupyter/jupyter_server_config.d", "voila-gridstack.json"), ("etc/jupyter/jupyter_notebook_config.d", "etc/jupyter/jupyter_notebook_config.d", "voila-gridstack.json"), ("etc/jupyter/nbconfig/notebook.d", "etc/jupyter/nbconfig/notebook.d", "voila-gridstack.json"), ("share/jupyter/nbextensions/voila-gridstack", f"{PACKAGE}/static", "**"), ("share/jupyter/labextensions/%s" % labext_name, str(lab_extension_dest), "**"), ("share/jupyter/labextensions/%s" % labext_name, HERE, "install.json"), ("share/jupyter/nbconvert/templates/gridstack", "share/jupyter/nbconvert/templates/gridstack", "**") ] try: from jupyter_packaging import (wrap_installers, npm_builder, get_data_files) post_develop = npm_builder(build_cmd='install:dev', npm='jlpm', force=True) cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) setup_args = dict(cmdclass=cmdclass, data_files=get_data_files(data_files_spec)) except ImportError: setup_args = dict() if __name__ == "__main__": setuptools.setup(**setup_args)
from jupyter_packaging import wrap_installers, npm_builder from setuptools import find_packages, setup from distutils.util import convert_path import os.path HERE = os.path.abspath(os.path.dirname(__file__)) # Representative files that should exist after a successful build jstargets = [ os.path.join(HERE, "nbgitpuller", "static", "dist", "bundle.js"), ] # https://github.com/jupyter/jupyter-packaging/blob/0.10.4/README.md#as-a-build-requirement jsdeps = npm_builder(build_cmd="webpack") cmdclass = wrap_installers( pre_develop=jsdeps, pre_dist=jsdeps, ensured_targets=jstargets, skip_if_exists=jstargets) # Imports __version__, reference: https://stackoverflow.com/a/24517154/2220152 ns = {} ver_path = convert_path('nbgitpuller/version.py') with open(ver_path) as ver_file: exec(ver_file.read(), ns) __version__ = ns['__version__'] setup( name='nbgitpuller', version=__version__, url='https://github.com/jupyterhub/nbgitpuller', license='3-clause BSD', author='Peter Veerman, YuviPanda',
version = "3.0.2" name = "test-hyphens-underscore" module_name = "test_hyphens_underscore" lab_ext_name = "test-hyphens-underscore" HERE = path.abspath(path.dirname(__file__)) lab_path = path.join(HERE, module_name, "labextension") data_files_spec = [("share/jupyter/labextensions/" + lab_ext_name, lab_path, "**")] setup_args = dict(name=name, version=version, packages=[module_name]) try: from jupyter_packaging import get_data_files, npm_builder, wrap_installers post_develop = npm_builder(build_cmd="build:labextension", build_dir=lab_path, npm=["jlpm"]) cmdclass = wrap_installers(post_develop=post_develop) setup_args.update( dict( cmdclass=cmdclass, data_files=get_data_files(data_files_spec), )) except ImportError: pass setup(**setup_args)
#!/usr/bin/env python # Copyright (c) IPython Development Team. # Copyright (c) Jupyter Development Team. # Distributed under the terms of the Modified BSD License. from jupyter_packaging import (wrap_installers, npm_builder, get_data_files) from pathlib import Path from setuptools import setup HERE = Path(__file__).parent.resolve() IS_REPO = (HERE.parent / '.git').exists() JS_DIR = HERE / 'src' data_files_spec = [('share/jupyter/nbextensions/jupyter-js-widgets', 'widgetsnbextension/static', 'extension.js*'), ('etc/jupyter/nbconfig/notebook.d', '.', 'widgetsnbextension.json')] post_develop = npm_builder(build_cmd="yarn", source_dir="src", build_dir=JS_DIR) cmdclass = wrap_installers(post_develop=post_develop) if __name__ == '__main__': setup( cmdclass=cmdclass, data_files=get_data_files(data_files_spec), )
LOCAL_APP_DIR = HERE / "quetz_frontend" / "app" GLOBAL_APP_DIR = "share/quetz/frontend/app" data_files_spec = [ (GLOBAL_APP_DIR, str(LOCAL_APP_DIR), "static/**"), (GLOBAL_APP_DIR, str(LOCAL_APP_DIR), "themes/**"), (GLOBAL_APP_DIR, str(LOCAL_APP_DIR), "schemas/**") ] # Representative files that should exist after a successful build ensured_targets = [ str(LOCAL_APP_DIR / "templates"), str(LOCAL_APP_DIR / "static"), str(LOCAL_APP_DIR / "themes"), str(LOCAL_APP_DIR / "static" / "package.json"), str(LOCAL_APP_DIR / "static" / "style.js"), ] try: from jupyter_packaging import wrap_installers, npm_builder, get_data_files builder = npm_builder(build_cmd="build:prod", npm=["yarn"]) cmdclass = wrap_installers(post_develop=builder, ensured_targets=ensured_targets) setup_args = {"cmdclass": cmdclass, "data_files": get_data_files(data_files_spec)} except ImportError: setup_args = dict() if __name__ == "__main__": setup(**setup_args)
from jupyter_packaging import ( wrap_installers, npm_builder, get_version, get_data_files, ) # The name of the project name = "jupyter_jsmol" # Get the version version = get_version(pjoin(name, "_version.py")) HERE = os.path.abspath(os.path.dirname(__file__)) builder = npm_builder(path="js") # Representative files that should exist after a successful build jstargets = [ pjoin(HERE, name, "nbextension", "index.js"), pjoin(HERE, "js", "lib", "plugin.js"), ] cmdclass = wrap_installers(pre_develop=builder, pre_dist=builder, ensured_targets=jstargets) # package_data_spec = {name: ["nbextension/**js*", "labextension/**"]} # data_files_spec = [ # ("share/jupyter/nbextensions/jupyter_jsmol", "jupyter_jsmol/nbextension", "**"), # ("share/jupyter/labextensions/jupyter_jsmol", "jupyter_jsmol/labextension", "**"),
# PEP 517/518 build rules. # https://github.com/python-versioneer/python-versioneer/issues/193 sys.path.append(os.path.dirname(__file__)) import versioneer here = os.path.dirname(__file__) # Representative files that should exist after a successful build jstargets = [ os.path.join(here, "binderhub", "static", "dist", "bundle.js"), ] # Automatically rebuild assets in dist if js is modified jsdeps = npm_builder(build_cmd="webpack", build_dir="binderhub/static/dist/", source_dir="binderhub/static/js/") cmdclass = wrap_installers(pre_develop=jsdeps, pre_dist=jsdeps, ensured_targets=jstargets) with open(os.path.join(here, 'requirements.txt')) as f: requirements = [ line.strip() for line in f.readlines() if not line.strip().startswith('#') ] with open(os.path.join(here, 'README.md'), encoding="utf8") as f: readme = f.read() setup(
labext_name = "jupyterlab-sparkmonitor" data_file_spec = [ (f"share/jupyter/labextensions/jupyterlab-sparkmonitor", str(lab_path), "**"), (f"share/jupyter/labextensions/jupyterlab-sparkmonitor", str(HERE), "install.json"), ( "etc/jupyter/jupyter_server_config.d", "jupyter-config", "jupyterlab_sparkmonitor.json", ), ] post_develop = npm_builder(build_cmd="build", source_dir="js", build_dir=lab_path) cmdclass = wrap_installers(post_develop=post_develop, ensured_targets=ensured_targets) long_description = (HERE / "README.md").read_text() pkg_json = json.loads((HERE / "package.json").read_bytes()) setup( name=name, version=pkg_json["version"], description="Spark Monitor Extension for Jupyter Lab", long_description=long_description, long_description_content_type="text/markdown",
data_spec = [ ( "share/jupyter/labextensions/jupyterlab_iframe", lab_path, "**", ), ("etc/jupyter/jupyter_server_config.d", ext_path, "*.json"), ] ensured_targets = [ pjoin("jupyterlab_iframe", "labextension", "package.json"), pjoin("jupyterlab_iframe", "labextension", "static", "style.js"), ] builder = npm_builder(build_cmd="build", path=jshere, source_dir=pjoin(jshere, "src"), build_dir=lab_path) setup( name=name, version="0.4.4", description="IFrame widgets for JupyterLab", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/timkpaine/jupyterlab_iframe", author="Tim Paine", author_email="*****@*****.**", license="Apache 2.0", classifiers=[ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Framework :: Jupyter", "Framework :: Jupyter :: JupyterLab", "Framework :: Jupyter :: JupyterLab :: 3", "Framework :: Jupyter :: JupyterLab :: Extensions", "Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt", ], ) try: from jupyter_packaging import (wrap_installers, npm_builder, get_data_files) post_develop = npm_builder(build_cmd="install:extension", source_dir="src", build_dir=lab_path) 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)
import setuptools import jupyter_packaging as jp HERE = os.path.dirname(os.path.abspath(__file__)) # The name of the project namepy = "qsl" namejs = "qslwidgets" # Representative files that should exist after a successful build jstargets = [ os.path.join(HERE, namepy, "ui", "nbextension", "index.js"), os.path.join(HERE, namepy, "ui", "labextension", "package.json"), ] builder = jp.npm_builder(os.path.join(HERE, namejs), build_cmd="build:prod") cmdclass = jp.wrap_installers( pre_develop=builder, pre_dist=builder, ensured_targets=jstargets, skip_if_exists=jstargets, ) setup_args = dict( name=namepy, description="A package for labeling image data quickly", version=jp.get_version(os.path.join(namepy, "version.py")), scripts=glob.glob(os.path.join("scripts", "*")), cmdclass=cmdclass, data_files=jp.get_data_files( data_specs=[ ("share/jupyter/nbextensions/qslwidgets", "qsl/ui/nbextension", "**"),