-
-
Notifications
You must be signed in to change notification settings - Fork 5
Develop command working #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
9f8adcb
first commit
cronan03 d5165b0
Merge branch 'jupyterlab:main' into main
cronan03 8571083
Automatic application of license header
github-actions[bot] e10bba8
federated_extensions dependencies
cronan03 8119f81
develop
cronan03 d47a9bf
Merge branch 'main' of https://github.com/cronan03/jupyterlab-builder
cronan03 4edfbec
Automatic application of license header
github-actions[bot] 1a9e92b
develop working
cronan03 4336e07
Automatic application of license header
github-actions[bot] 5d68804
Update jupyter_builder/base_extension_app.py
cronan03 8de736f
Update jupyter_builder/base_extension_app.py
cronan03 8b0a743
Update jupyter_builder/base_extension_app.py
cronan03 7ac388a
Update jupyter_builder/commands.py
cronan03 e740379
Update jupyter_builder/federated_extensions_requirements.py
cronan03 4804e4f
Update jupyter_builder/commands.py
cronan03 bc18c97
Update jupyter_builder/base_extension_app.py
cronan03 aa53f62
Update jupyter_builder/base_extension_app.py
cronan03 c4d073a
Update jupyter_builder/base_extension_app.py
cronan03 6a08a03
Update jupyter_builder/base_extension_app.py
cronan03 83b7c2c
Update jupyter_builder/base_extension_app.py
cronan03 546e9bc
Update jupyter_builder/base_extension_app.py
cronan03 9c011fa
Update jupyter_builder/base_extension_app.py
cronan03 d9099af
Update jupyter_builder/base_extension_app.py
cronan03 e0106ba
Update jupyter_builder/base_extension_app.py
cronan03 a92d458
remove unwanted files
cronan03 06e9ced
Merge branch 'main' of https://github.com/cronan03/jupyterlab-builder
cronan03 3b526ec
tests
cronan03 baeb60f
test_tpl
cronan03 6f21193
test_lint
cronan03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
|
|
||
|
|
||
| """Jupyter LabExtension Entry Points.""" | ||
|
|
||
| # Copyright (c) Jupyter Development Team. | ||
| # Distributed under the terms of the Modified BSD License. | ||
|
|
||
| import os | ||
| import sys | ||
| from copy import copy | ||
|
|
||
| from jupyter_core.application import JupyterApp, base_aliases, base_flags | ||
| from traitlets import Bool, Instance, List, Unicode, default | ||
| from jupyter_core.paths import jupyter_path | ||
|
|
||
| #from .coreconfig import CoreConfig | ||
| from .debug_log_file_mixin import DebugLogFileMixin | ||
|
|
||
| # from .commands import ( | ||
| # HERE, # done | ||
| # AppOptions,# in prog | ||
| # build, # | ||
| # check_extension, | ||
| # disable_extension, | ||
| # enable_extension, | ||
| # get_app_version, # 170 - 183 108 162-163 | ||
| # install_extension, | ||
| # link_package, | ||
| # list_extensions, | ||
| # lock_extension, | ||
| # uninstall_extension, | ||
| # unlink_package, | ||
| # unlock_extension, | ||
| # update_extension, | ||
| # ) | ||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| HERE = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
|
|
||
| # from .federated_labextensions import build_labextension, develop_labextension_py, watch_labextension | ||
| #from .labapp import LabApp #TO BE DONE -------------line 255 | ||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| flags = dict(base_flags) | ||
| flags["no-build"] = ( | ||
| {"BaseExtensionApp": {"should_build": False}}, | ||
| "Defer building the app after the action.", | ||
| ) | ||
| flags["dev-build"] = ( | ||
| {"BaseExtensionApp": {"dev_build": True}}, | ||
| "Build in development mode.", | ||
| ) | ||
| flags["no-minimize"] = ( | ||
| {"BaseExtensionApp": {"minimize": False}}, | ||
| "Do not minimize a production build.", | ||
| ) | ||
| flags["clean"] = ( | ||
| {"BaseExtensionApp": {"should_clean": True}}, | ||
| "Cleanup intermediate files after the action.", | ||
| ) | ||
| flags["splice-source"] = ( | ||
| {"BaseExtensionApp": {"splice_source": True}}, | ||
| "Splice source packages into app directory.", | ||
| ) | ||
|
|
||
| check_flags = copy(flags) | ||
| check_flags["installed"] = ( | ||
| {"CheckLabExtensionsApp": {"should_check_installed_only": True}}, | ||
| "Check only if the extension is installed.", | ||
| ) | ||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| develop_flags = copy(flags) | ||
| develop_flags["overwrite"] = ( | ||
| {"DevelopLabExtensionApp": {"overwrite": True}}, | ||
| "Overwrite files", | ||
| ) | ||
|
|
||
| update_flags = copy(flags) | ||
| update_flags["all"] = ( | ||
| {"UpdateLabExtensionApp": {"all": True}}, | ||
| "Update all extensions", | ||
| ) | ||
|
|
||
| uninstall_flags = copy(flags) | ||
| uninstall_flags["all"] = ( | ||
| {"UninstallLabExtensionApp": {"all": True}}, | ||
| "Uninstall all extensions", | ||
| ) | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| aliases = dict(base_aliases) | ||
| aliases["app-dir"] = "BaseExtensionApp.app_dir" | ||
| aliases["dev-build"] = "BaseExtensionApp.dev_build" | ||
| aliases["minimize"] = "BaseExtensionApp.minimize" | ||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| aliases["debug-log-path"] = "DebugLogFileMixin.debug_log_path" | ||
|
|
||
| install_aliases = copy(aliases) | ||
| install_aliases["pin-version-as"] = "InstallLabExtensionApp.pin" | ||
|
|
||
| enable_aliases = copy(aliases) | ||
| enable_aliases["level"] = "EnableLabExtensionsApp.level" | ||
|
|
||
| disable_aliases = copy(aliases) | ||
| disable_aliases["level"] = "DisableLabExtensionsApp.level" | ||
|
|
||
| lock_aliases = copy(aliases) | ||
| lock_aliases["level"] = "LockLabExtensionsApp.level" | ||
|
|
||
| unlock_aliases = copy(aliases) | ||
| unlock_aliases["level"] = "UnlockLabExtensionsApp.level" | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #VERSION = get_app_version() | ||
| VERSION = 1 | ||
|
|
||
| LABEXTENSION_COMMAND_WARNING = "Users should manage prebuilt extensions with package managers like pip and conda, and extension authors are encouraged to distribute their extensions as prebuilt packages" | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| class BaseExtensionApp(JupyterApp, DebugLogFileMixin): | ||
| version = VERSION | ||
| flags = flags | ||
| aliases = aliases | ||
| name = "lab" | ||
|
|
||
| # Not configurable! | ||
| #core_config = Instance(CoreConfig, allow_none=True) | ||
|
|
||
| app_dir = Unicode("", config=True, help="The app directory to target") | ||
|
|
||
| # should_build = Bool(True, config=True, help="Whether to build the app after the action") | ||
|
|
||
| dev_build = Bool( | ||
| None, | ||
| allow_none=True, | ||
| config=True, | ||
| help="Whether to build in dev mode. Defaults to True (dev mode) if there are any locally linked extensions, else defaults to False (production mode).", | ||
| ) | ||
|
|
||
| minimize = Bool( | ||
| True, | ||
| config=True, | ||
| help="Whether to minimize a production build (defaults to True).", | ||
| ) | ||
|
|
||
| # should_clean = Bool( | ||
| # False, | ||
| # config=True, | ||
| # help="Whether temporary files should be cleaned up after building jupyterlab", | ||
| # ) | ||
|
|
||
| # splice_source = Bool(False, config=True, help="Splice source packages into app directory.") | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| labextensions_path = List( | ||
| Unicode(), | ||
| help="The standard paths to look in for prebuilt JupyterLab extensions", | ||
| ) | ||
|
|
||
| # @default("labextensions_path") | ||
| # def _default_labextensions_path(self): | ||
| # lab = LabApp() | ||
| # lab.load_config_file() | ||
| # return lab.extra_labextensions_path + lab.labextensions_path | ||
| @default("labextensions_path") | ||
| def _default_labextensions_path(self) -> list[str]: | ||
| return jupyter_path("labextensions") | ||
|
|
||
| @default("splice_source") | ||
| def _default_splice_source(self): | ||
| # version = get_app_version(AppOptions(app_dir=self.app_dir)) | ||
| # return version.endswith("-spliced") | ||
| return "Ronan" | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def start(self): | ||
| if self.app_dir and self.app_dir.startswith(HERE): | ||
| msg = "Cannot run lab extension commands in core app" | ||
| raise ValueError(msg) | ||
| with self.debug_logging(): | ||
| ans = self.run_task() | ||
| # if ans and self.should_build: | ||
| # production = None if self.dev_build is None else not self.dev_build | ||
| # app_options = AppOptions( | ||
| # app_dir=self.app_dir, | ||
| # logger=self.log, | ||
| # core_config=self.core_config, | ||
| # splice_source=self.splice_source, | ||
| # ) | ||
| # build( | ||
| # clean_staging=self.should_clean, | ||
| # production=production, | ||
| # minimize=self.minimize, | ||
| # app_options=app_options, | ||
| # ) | ||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def run_task(self): | ||
| pass | ||
|
|
||
| def deprecation_warning(self, msg): | ||
| return self.log.warning( | ||
| "\033[33m(Deprecated) %s\n\n%s \033[0m", msg, LABEXTENSION_COMMAND_WARNING | ||
| ) | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def _log_format_default(self): | ||
| """A default format for messages""" | ||
| return "%(message)s" | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| """JupyterLab command handler""" | ||
|
|
||
| # Copyright (c) Jupyter Development Team. | ||
| # Distributed under the terms of the Modified BSD License. | ||
|
|
||
| import itertools | ||
| import logging | ||
| from jupyterlab.semver import Range, gt, gte, lt, lte | ||
| from traitlets import Bool, HasTraits, Instance, List, Unicode, default | ||
| from .coreconfig import CoreConfig | ||
| from threading import Event | ||
|
|
||
| # Default Yarn registry used in default yarn.lock | ||
| YARN_DEFAULT_REGISTRY = "https://registry.yarnpkg.com" | ||
|
|
||
|
|
||
cronan03 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| def _test_overlap(spec1, spec2, drop_prerelease1=False, drop_prerelease2=False): | ||
| """Test whether two version specs overlap. | ||
|
|
||
| Returns `None` if we cannot determine compatibility, | ||
| otherwise whether there is an overlap | ||
| """ | ||
| cmp = _compare_ranges( | ||
| spec1, spec2, drop_prerelease1=drop_prerelease1, drop_prerelease2=drop_prerelease2 | ||
| ) | ||
| if cmp is None: | ||
| return | ||
| return cmp == 0 | ||
|
|
||
| def _compare_ranges(spec1, spec2, drop_prerelease1=False, drop_prerelease2=False): # noqa | ||
| """Test whether two version specs overlap. | ||
|
|
||
| Returns `None` if we cannot determine compatibility, | ||
| otherwise return 0 if there is an overlap, 1 if | ||
| spec1 is lower/older than spec2, and -1 if spec1 | ||
| is higher/newer than spec2. | ||
| """ | ||
| # Test for overlapping semver ranges. | ||
| r1 = Range(spec1, True) | ||
| r2 = Range(spec2, True) | ||
|
|
||
| # If either range is empty, we cannot verify. | ||
| if not r1.range or not r2.range: | ||
| return | ||
|
|
||
| # Set return_value to a sentinel value | ||
| return_value = False | ||
|
|
||
| # r1.set may be a list of ranges if the range involved an ||, so we need to test for overlaps between each pair. | ||
| for r1set, r2set in itertools.product(r1.set, r2.set): | ||
| x1 = r1set[0].semver | ||
| x2 = r1set[-1].semver | ||
| y1 = r2set[0].semver | ||
| y2 = r2set[-1].semver | ||
|
|
||
| if x1.prerelease and drop_prerelease1: | ||
| x1 = x1.inc("patch") | ||
|
|
||
| if y1.prerelease and drop_prerelease2: | ||
| y1 = y1.inc("patch") | ||
|
|
||
| o1 = r1set[0].operator | ||
| o2 = r2set[0].operator | ||
|
|
||
| # We do not handle (<) specifiers. | ||
| if o1.startswith("<") or o2.startswith("<"): | ||
| continue | ||
|
|
||
| # Handle single value specifiers. | ||
| lx = lte if x1 == x2 else lt | ||
| ly = lte if y1 == y2 else lt | ||
| gx = gte if x1 == x2 else gt | ||
| gy = gte if x1 == x2 else gt | ||
|
|
||
| # Handle unbounded (>) specifiers. | ||
| def noop(x, y, z): | ||
| return True | ||
|
|
||
| if x1 == x2 and o1.startswith(">"): | ||
| lx = noop | ||
| if y1 == y2 and o2.startswith(">"): | ||
| ly = noop | ||
|
|
||
| # Check for overlap. | ||
| if ( | ||
| gte(x1, y1, True) | ||
| and ly(x1, y2, True) | ||
| or gy(x2, y1, True) | ||
| and ly(x2, y2, True) | ||
| or gte(y1, x1, True) | ||
| and lx(y1, x2, True) | ||
| or gx(y2, x1, True) | ||
| and lx(y2, x2, True) | ||
| ): | ||
| # if we ever find an overlap, we can return immediately | ||
| return 0 | ||
|
|
||
| if gte(y1, x2, True): | ||
| if return_value is False: | ||
| # We can possibly return 1 | ||
| return_value = 1 | ||
| elif return_value == -1: | ||
| # conflicting information, so we must return None | ||
| return_value = None | ||
| continue | ||
|
|
||
| if gte(x1, y2, True): | ||
| if return_value is False: | ||
| return_value = -1 | ||
| elif return_value == 1: | ||
| # conflicting information, so we must return None | ||
| return_value = None | ||
| continue | ||
|
|
||
| msg = "Unexpected case comparing version ranges" | ||
| raise AssertionError(msg) | ||
|
|
||
| if return_value is False: | ||
| return_value = None | ||
| return return_value | ||
|
|
||
|
|
||
| #------------------------------------------------------------------------ | ||
| # base_extension_app . commands | ||
|
|
||
|
|
||
| class AppOptions(HasTraits): | ||
| """Options object for build system""" | ||
|
|
||
| def __init__(self, logger=None, core_config=None, **kwargs): | ||
| if core_config is not None: | ||
| kwargs["core_config"] = core_config | ||
| if logger is not None: | ||
| kwargs["logger"] = logger | ||
|
|
||
| # use the default if app_dir is empty | ||
| if "app_dir" in kwargs and not kwargs["app_dir"]: | ||
| kwargs.pop("app_dir") | ||
|
|
||
| super().__init__(**kwargs) | ||
|
|
||
| app_dir = Unicode(help="The application directory") | ||
|
|
||
| use_sys_dir = Bool( | ||
| True, | ||
| help=("Whether to shadow the default app_dir if that is set to a non-default value"), | ||
| ) | ||
|
|
||
| logger = Instance(logging.Logger, help="The logger to use") | ||
|
|
||
| core_config = Instance(CoreConfig, help="Configuration for core data") | ||
|
|
||
| kill_event = Instance(Event, args=(), help="Event for aborting call") | ||
|
|
||
| labextensions_path = List( | ||
| Unicode(), help="The paths to look in for prebuilt JupyterLab extensions" | ||
| ) | ||
|
|
||
| registry = Unicode(help="NPM packages registry URL") | ||
|
|
||
| splice_source = Bool(False, help="Splice source packages into app directory.") | ||
|
|
||
| skip_full_build_check = Bool( | ||
| False, | ||
| help=( | ||
| "If true, perform only a quick check that the lab build is up to date." | ||
| " If false, perform a thorough check, which verifies extension contents." | ||
| ), | ||
| ) | ||
|
|
||
| @default("logger") | ||
| def _default_logger(self): | ||
| return logging.getLogger("jupyterlab") | ||
|
|
||
| # These defaults need to be federated to pick up | ||
| # any changes to env vars: | ||
| @default("app_dir") | ||
| def _default_app_dir(self): | ||
| return get_app_dir() | ||
|
|
||
| @default("core_config") | ||
| def _default_core_config(self): | ||
| return CoreConfig() | ||
|
|
||
| @default("registry") | ||
| def _default_registry(self): | ||
| config = _yarn_config(self.logger)["yarn config"] | ||
| return config.get("registry", YARN_DEFAULT_REGISTRY) | ||
|
|
||
cronan03 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.