This repository has been archived by the owner on Jul 9, 2024. It is now read-only.
forked from NERSC/jupyterlab-recents
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Enhance setup * Fix pyproject * Fix build workflow * Fix manifest
- Loading branch information
1 parent
e648d43
commit 7bca36f
Showing
5 changed files
with
148 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
[build-system] | ||
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "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] | ||
skip-if-exists = ["jupyterlab_recents/labextension/static/style.js"] | ||
ensured-targets = ["jupyterlab_recents/labextension/static/style.js", "jupyterlab_recents/labextension/package.json"] | ||
|
||
[tool.jupyter-packaging.builder] | ||
factory = "jupyter_packaging.npm_builder" | ||
|
||
[tool.jupyter-packaging.build-args] | ||
build_cmd = "build:prod" | ||
npm = ["jlpm"] | ||
|
||
[tool.check-manifest] | ||
ignore = ["jupyterlab_recents/labextension/**", "yarn.lock", ".*", "package-lock.json"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,94 @@ | ||
""" | ||
jupyterlab_recents setup | ||
jlab_enhanced_launcher setup | ||
""" | ||
import json | ||
import sys | ||
from pathlib import Path | ||
|
||
from jupyter_packaging import ( | ||
create_cmdclass, | ||
install_npm, | ||
ensure_targets, | ||
combine_commands, | ||
skip_if_exists | ||
) | ||
import setuptools | ||
|
||
HERE = Path(__file__).parent.resolve() | ||
|
||
# The name of the project | ||
name = "jupyterlab_recents" | ||
name="jupyterlab_recents" | ||
|
||
lab_path = (HERE / name / "labextension") | ||
lab_path = HERE / name.replace("-", "_") / "labextension" | ||
|
||
# Representative files that should exist after a successful build | ||
jstargets = [ | ||
str(lab_path / "package.json"), | ||
] | ||
|
||
package_data_spec = { | ||
name: ["*"], | ||
} | ||
ensured_targets = [str(lab_path / "package.json"), str(lab_path / "static/style.js")] | ||
|
||
labext_name = "@jlab-enhanced/recents" | ||
|
||
data_files_spec = [ | ||
("share/jupyter/labextensions/%s" % labext_name, str(lab_path), "**"), | ||
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"), | ||
( | ||
"share/jupyter/labextensions/%s" % labext_name, | ||
str(lab_path.relative_to(HERE)), | ||
"**", | ||
), | ||
("share/jupyter/labextensions/%s" % labext_name, str("."), "install.json"), | ||
] | ||
|
||
cmdclass = create_cmdclass("jsdeps", | ||
package_data_spec=package_data_spec, | ||
data_files_spec=data_files_spec | ||
) | ||
|
||
js_command = combine_commands( | ||
install_npm(HERE, build_cmd="build:prod", npm=["jlpm"]), | ||
ensure_targets(jstargets), | ||
) | ||
|
||
is_repo = (HERE / ".git").exists() | ||
if is_repo: | ||
cmdclass["jsdeps"] = js_command | ||
else: | ||
cmdclass["jsdeps"] = skip_if_exists(jstargets, js_command) | ||
|
||
long_description = (HERE / "README.md").read_text() | ||
|
||
# Get the package info from package.json | ||
pkg_json = json.loads((HERE / "package.json").read_bytes()) | ||
version = ( | ||
pkg_json["version"] | ||
.replace("-alpha.", "a") | ||
.replace("-beta.", "b") | ||
.replace("-rc.", "rc") | ||
) | ||
|
||
setup_args = dict( | ||
name=name, | ||
version=pkg_json["version"], | ||
version=version, | ||
url=pkg_json["homepage"], | ||
author=pkg_json["author"]["name"], | ||
description=pkg_json["description"], | ||
license=pkg_json["license"], | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
cmdclass=cmdclass, | ||
packages=setuptools.find_packages(), | ||
install_requires=[ | ||
"jupyterlab~=3.0", | ||
], | ||
zip_safe=False, | ||
include_package_data=True, | ||
python_requires=">=3.6", | ||
python_requires=">=3.7", | ||
platforms="Linux, Mac OS X, Windows", | ||
keywords=pkg_json["keywords"], | ||
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", | ||
"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) |