Skip to content

Commit

Permalink
update url for fetching plugin listing from napari hub (#313)
Browse files Browse the repository at this point in the history
This PR updates for a couple api changes in dependencies that are
blocking #311 and #312.

For the napar-hub api, the `/plugins` endpoint was removed (see
[here](chanzuckerberg/napari-hub#1065)).
This impacts the `get_hub_plugins()` function, and a test
`test_get_hub_plugins` which fails without this change. It doesn't
appear that anything actually uses these, so this PR removes them.

Also [build](https://github.com/pypa/build) updated to 1.0.
`IsolatedEnvBuilder` was renamed to `DefaultIsolatedEnv`.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
nclack and pre-commit-ci[bot] authored Sep 25, 2023
1 parent db7d7c5 commit bd0d46c
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ classifiers = [
dependencies = [
"PyYAML",
"appdirs",
"build",
"build>=1",
"psygnal>=0.3.0",
"pydantic<2",
"tomli-w",
Expand Down
8 changes: 0 additions & 8 deletions src/npe2/_inspection/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"fetch_manifest",
"get_pypi_url",
"get_hub_plugin",
"get_hub_plugins",
"get_pypi_plugins",
]

Expand Down Expand Up @@ -405,13 +404,6 @@ def get_pypi_plugins() -> Dict[str, str]:
return _get_packages_by_classifier(NAPARI_CLASSIFIER)


@lru_cache
def get_hub_plugins() -> Dict[str, str]:
"""Return {name: latest_version} for all plugins on the hub."""
with request.urlopen("https://api.napari-hub.org/plugins") as r:
return json.load(r)


@lru_cache
def get_hub_plugin(plugin_name: str) -> Dict[str, Any]:
"""Return hub information for a specific plugin."""
Expand Down
4 changes: 2 additions & 2 deletions src/npe2/_inspection/_full_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def isolated_plugin_env(
"""
# it's important that this import be lazy, otherwise we'll get a circular
# import when serving as a setuptools plugin with `python -m build`
from build.env import IsolatedEnvBuilder
from build.env import DefaultIsolatedEnv

with IsolatedEnvBuilder() as env:
with DefaultIsolatedEnv() as env:
# install the package
pkg = f"{package}=={version}" if version else package
logger.debug(f"installing {pkg} into virtual env")
Expand Down
6 changes: 0 additions & 6 deletions tests/test_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from npe2._inspection._fetch import (
_manifest_from_pypi_sdist,
get_hub_plugin,
get_hub_plugins,
get_manifest_from_wheel,
get_pypi_plugins,
get_pypi_url,
Expand Down Expand Up @@ -93,11 +92,6 @@ def test_get_manifest_from_wheel(tmp_path):
assert mf.name == "affinder"


def test_get_hub_plugins():
plugins = get_hub_plugins()
assert len(plugins) > 0


def test_get_hub_plugin():
info = get_hub_plugin("napari-svg")
assert info["name"] == "napari-svg"
Expand Down

0 comments on commit bd0d46c

Please sign in to comment.