-
Notifications
You must be signed in to change notification settings - Fork 28
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
Cleanup manifest #38
Merged
Merged
Cleanup manifest #38
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a6e2281
Some cleanup
nclack fb71bc3
Some more cleanup
nclack 1da7bce
Change 'publisher' to 'authors' (#39)
nclack 3bf56c5
Update npe2/_plugin_manager.py
tlambert03 7a98b5d
Update npe2/_from_npe1.py
nclack ff94b39
Update npe2/manifest/schema.py
nclack 514c60c
Add back some comments
nclack 4cd869e
Merge branch 'nclack/issue39' into pr/nclack/38
nclack 0967151
fix test
nclack faa6900
fix test
nclack 298ee41
add back license field (#17)
nclack 9964f72
Merge branch 'main' into nclack/issue17
nclack 01e03be
add back license field try2 (#17)
nclack 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
import sys | ||
import types | ||
from contextlib import contextmanager | ||
from enum import Enum | ||
from importlib import import_module, util | ||
from logging import getLogger | ||
from pathlib import Path | ||
|
@@ -14,7 +13,6 @@ | |
Any, | ||
Callable, | ||
Iterator, | ||
List, | ||
NamedTuple, | ||
Optional, | ||
Sequence, | ||
|
@@ -37,9 +35,6 @@ | |
from importlib.metadata import EntryPoint | ||
|
||
|
||
spdx_ids = (Path(__file__).parent / "spdx.txt").read_text().splitlines() | ||
SPDX = Enum("SPDX", {i.replace("-", "_"): i for i in spdx_ids}) # type: ignore | ||
|
||
logger = getLogger(__name__) | ||
|
||
ENTRY_POINT = "napari.manifest" | ||
|
@@ -54,19 +49,20 @@ class DiscoverResults(NamedTuple): | |
class PluginManifest(BaseModel): | ||
|
||
# VS Code uses <publisher>.<name> as a unique ID for the extension | ||
# should this just be the package name ... not the module name? (probably yes) | ||
# do we normalize this? (i.e. underscores / dashes ?) | ||
# should this just be the package name ... not the module name? (yes) | ||
# do we normalize this? (i.e. underscores / dashes ?) (no) | ||
# TODO: enforce that this matches the package name | ||
|
||
name: str = Field( | ||
..., | ||
description="The name of the plugin - should be all lowercase with no spaces.", | ||
description="The name of the plugin. Should correspond to the python " | ||
"package name for this plugin.", | ||
Comment on lines
+61
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) | ||
# this is not something that has an equivalent on PyPI ... | ||
# it might be a good field with which we can identify trusted source | ||
# but... it's not entire clear how that "trust" gets validated at the moment | ||
publisher: Optional[str] = Field( | ||
|
||
author: Optional[str] = Field( | ||
None, | ||
description="The publisher name - can be an individual or an organization", | ||
description="The author name(s). When unspecified, the description is " | ||
"take from the 'Author' field of the package metadata.", | ||
) | ||
|
||
display_name: str = Field( | ||
|
@@ -77,55 +73,32 @@ class PluginManifest(BaseModel): | |
# non-word character. | ||
regex=r"^[^\W_][\w -~]{1,38}[^\W_]$", | ||
) | ||
# take this from setup.cfg | ||
|
||
description: Optional[str] = Field( | ||
description="A short description of what your extension is and does." | ||
"When unspecified, the description is taken from package metadata." | ||
) | ||
|
||
# TODO: | ||
# Perhaps we should version the plugin interface (not so the manifest, but | ||
# the actual mechanism/consumption of plugin information) independently | ||
# of napari itself | ||
|
||
# mechanistic things: | ||
# this is the module that has the activate() function | ||
# The module that has the activate() function | ||
entry_point: Optional[str] = Field( | ||
default=None, | ||
description="The extension entry point. This should be a fully qualified " | ||
"module string. e.g. `foo.bar.baz`", | ||
description="The extension entry point. This should be a fully " | ||
"qualified module string. e.g. `foo.bar.baz` for a module containing " | ||
"the plugin's activate() function.", | ||
) | ||
|
||
# this comes from setup.cfg | ||
version: Optional[str] = Field(None, description="SemVer compatible version.") | ||
# this should come from setup.cfg ... but they don't requireq SPDX | ||
license: Optional[SPDX] = None | ||
|
||
contributions: Optional[ContributionPoints] | ||
|
||
categories: List[str] = Field( | ||
default_factory=list, | ||
description="specifically defined classifiers", | ||
) | ||
|
||
# in the absense of input. should be inferred from version (require using rc ...) | ||
# or use `classifiers = Status` | ||
preview: Optional[bool] = Field( | ||
version: Optional[str] = Field( | ||
None, | ||
description="Sets the extension to be flagged as a Preview in napari-hub.", | ||
description="SemVer compatible version. When unspecified the version " | ||
"is taken from package metadata.", | ||
) | ||
private: bool = Field(False, description="Whether this extension is private") | ||
|
||
# activationEvents: Optional[List[ActivationEvent]] = Field( | ||
# default_factory=list, | ||
# description="Events upon which your extension becomes active.", | ||
# ) | ||
|
||
# @validator("activationEvents", pre=True) | ||
# def _validateActivationEvent(cls, val): | ||
# return [ | ||
# dict(zip(("kind", "id"), x.split(":"))) if ":" in x else x | ||
# for x in val | ||
# ] | ||
contributions: Optional[ContributionPoints] | ||
|
||
_manifest_file: Optional[Path] = None | ||
|
||
|
@@ -275,15 +248,6 @@ def _populate_missing_meta(self, metadata: Message): | |
self.version = metadata["Version"] | ||
if not self.description: | ||
self.description = metadata["Summary"] | ||
if not self.license: | ||
self.license = metadata["License"] | ||
if self.preview is None: | ||
for k, v in getattr(metadata, "_headers"): | ||
if k.lower() == "classifier" and v.lower().startswith( | ||
"development status" | ||
): | ||
self.preview = int(v.split(":: ")[-1][0]) < 3 | ||
break | ||
|
||
@classmethod | ||
def discover( | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this fixes some broken tests I was getting on the napari side. napari's CI misses these at the moment because npe2 isn't installed when the test suite is running.