From 695c7f7aaa76afc111d7d9b0fa49fe49788a7806 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 29 Oct 2023 14:16:07 +0100 Subject: [PATCH 01/20] move coverage upload to separate steep --- .github/workflows/ci.yml | 48 +++++++++++++++++++++++++++++++++++----- pyproject.toml | 1 + 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2c112ff..49d87a0b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,13 +51,13 @@ jobs: - name: Test run: | coverage run --source=npe2 -m pytest --color yes - coverage xml - coverage report --show-missing - - name: Coverage - uses: codecov/codecov-action@v3 + - name: Upload coverage as artifact + uses: actions/upload-artifact@v3 with: - fail_ci_if_error: true + name: coverage reports + path: | + ./.coverage.* test_napari: name: napari tests @@ -104,6 +104,44 @@ jobs: env: NPE2_SCHEMA: "_schema.json" + upload_coverage: + needs: test + name: Upload coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + cache-dependency-path: setup.cfg + cache: 'pip' + + - name: Install Dependencies + run: | + pip install --upgrade pip + pip install codecov + + - name: Download coverage data + uses: actions/download-artifact@v3 + with: + name: coverage reports + path: coverage + + - name: combine coverage data + run: | + python -Im coverage combine coverage + python -Im coverage xml -o coverage.xml + + # Report and write to summary. + python -Im coverage report --format=markdown --skip-empty --skip-covered >> $GITHUB_STEP_SUMMARY + + - name: Upload coverage data + uses: codecov/codecov-action@v3 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + deploy: name: Deploy needs: test diff --git a/pyproject.toml b/pyproject.toml index 7b7f65e4..2b588cad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,6 +134,7 @@ pretty = true [tool.coverage.run] +parallel = true source = ["src"] omit = [ "src/npe2/manifest/contributions/_keybindings.py", From 0c80477df270621096d5c6eab90ac445d1e5a040 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 29 Oct 2023 14:29:29 +0100 Subject: [PATCH 02/20] alway upload coverage --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49d87a0b..4552d71a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,6 +107,7 @@ jobs: upload_coverage: needs: test name: Upload coverage + if: always() runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 8620f71a17a5722c100bca8a2a8c404984b658a8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Sun, 29 Oct 2023 14:56:11 +0100 Subject: [PATCH 03/20] add paths --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 2b588cad..170727e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -146,6 +146,9 @@ omit = [ "src/npe2/_setuptools_plugin.py", ] +[tool.coverage.paths] +source = ["src"] + # https://coverage.readthedocs.io/en/6.4/config.html [tool.coverage.report] exclude_lines = [ From 29d23e2e4e0e20b54f21de21e614470a41cbd1c8 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 00:48:55 +0100 Subject: [PATCH 04/20] add more paths --- pyproject.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 170727e5..aca5466e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -147,7 +147,12 @@ omit = [ ] [tool.coverage.paths] -source = ["src"] +source = [ + "src", + "/Users/runner/work/npe2/npe2/src", + "/home/runner/work/npe2/npe2/src", + "D:\a\npe2\npe2\src", +] # https://coverage.readthedocs.io/en/6.4/config.html [tool.coverage.report] From 5c949b3b18835db83cf324ac6e291ca1b4e0cc25 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 00:51:25 +0100 Subject: [PATCH 05/20] escape chars --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aca5466e..3177397e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,7 +151,7 @@ source = [ "src", "/Users/runner/work/npe2/npe2/src", "/home/runner/work/npe2/npe2/src", - "D:\a\npe2\npe2\src", + "D:\\a\\npe2\\npe2\\src", ] # https://coverage.readthedocs.io/en/6.4/config.html From b567452aed6daacd0d10b4e5cc72f7c7382f74e3 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:32:27 +0100 Subject: [PATCH 06/20] add print --- tests/test_setuptools_plugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_setuptools_plugin.py b/tests/test_setuptools_plugin.py index 4780fbcf..f9be672f 100644 --- a/tests/test_setuptools_plugin.py +++ b/tests/test_setuptools_plugin.py @@ -30,6 +30,8 @@ def test_compile(compiled_plugin_dir: Path, tmp_path: Path, dist_type: str) -> N pyproject = compiled_plugin_dir / "pyproject.toml" pyproject.write_text(PYPROJECT) + print(f"pyproject.toml {PYPROJECT!r}") + template = compiled_plugin_dir / TEMPLATE template.write_text("name: my_compiled_plugin\ndisplay_name: My Compiled Plugin\n") os.chdir(compiled_plugin_dir) From 40330860ce9cb8b11c948f426dc94bfd92e7ccfd Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:38:50 +0100 Subject: [PATCH 07/20] limit ci --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4552d71a..d0118870 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] - platform: [ubuntu-latest, macos-latest, windows-latest] + python-version: [3.8] #, 3.9, "3.10", "3.11"] + platform: [windows-latest] #[ubuntu-latest, macos-latest, windows-latest] pydantic: ["pydantic<2", "pydantic>2"] steps: From a78a3e1e235031566906c7b27c2e886f15c45e28 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:42:00 +0100 Subject: [PATCH 08/20] more debug info --- tests/test_setuptools_plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_setuptools_plugin.py b/tests/test_setuptools_plugin.py index f9be672f..7624b182 100644 --- a/tests/test_setuptools_plugin.py +++ b/tests/test_setuptools_plugin.py @@ -30,12 +30,13 @@ def test_compile(compiled_plugin_dir: Path, tmp_path: Path, dist_type: str) -> N pyproject = compiled_plugin_dir / "pyproject.toml" pyproject.write_text(PYPROJECT) - print(f"pyproject.toml {PYPROJECT!r}") - template = compiled_plugin_dir / TEMPLATE template.write_text("name: my_compiled_plugin\ndisplay_name: My Compiled Plugin\n") os.chdir(compiled_plugin_dir) - subprocess.check_call([sys.executable, "-m", "build", f"--{dist_type}"]) + try: + subprocess.check_call([sys.executable, "-m", "build", f"--{dist_type}"]) + except subprocess.CalledProcessError as e: + raise AssertionError(PYPROJECT) from e dist_dir = compiled_plugin_dir / "dist" assert dist_dir.is_dir() if dist_type == "sdist": From b5d3f393fec815160f75af4641c60ab9e6fa5aa3 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:48:03 +0100 Subject: [PATCH 09/20] try fix --- tests/test_setuptools_plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_setuptools_plugin.py b/tests/test_setuptools_plugin.py index 7624b182..d56572fc 100644 --- a/tests/test_setuptools_plugin.py +++ b/tests/test_setuptools_plugin.py @@ -18,7 +18,9 @@ [tool.npe2] template="{TEMPLATE}" -""" +""".replace( + "\\", "\\\\" +) @pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI") From 302abb5d87ed58ab51521c227ebd2df723096702 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:59:22 +0100 Subject: [PATCH 10/20] Revert "more debug info" This reverts commit a78a3e1e235031566906c7b27c2e886f15c45e28. --- tests/test_setuptools_plugin.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_setuptools_plugin.py b/tests/test_setuptools_plugin.py index d56572fc..422ff8e7 100644 --- a/tests/test_setuptools_plugin.py +++ b/tests/test_setuptools_plugin.py @@ -32,13 +32,12 @@ def test_compile(compiled_plugin_dir: Path, tmp_path: Path, dist_type: str) -> N pyproject = compiled_plugin_dir / "pyproject.toml" pyproject.write_text(PYPROJECT) + print(f"pyproject.toml {PYPROJECT!r}") + template = compiled_plugin_dir / TEMPLATE template.write_text("name: my_compiled_plugin\ndisplay_name: My Compiled Plugin\n") os.chdir(compiled_plugin_dir) - try: - subprocess.check_call([sys.executable, "-m", "build", f"--{dist_type}"]) - except subprocess.CalledProcessError as e: - raise AssertionError(PYPROJECT) from e + subprocess.check_call([sys.executable, "-m", "build", f"--{dist_type}"]) dist_dir = compiled_plugin_dir / "dist" assert dist_dir.is_dir() if dist_type == "sdist": From 6cb168fa9c54d31de345971827885c67a125cf80 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 13:59:29 +0100 Subject: [PATCH 11/20] Revert "add print" This reverts commit b567452aed6daacd0d10b4e5cc72f7c7382f74e3. --- tests/test_setuptools_plugin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_setuptools_plugin.py b/tests/test_setuptools_plugin.py index 422ff8e7..b2502009 100644 --- a/tests/test_setuptools_plugin.py +++ b/tests/test_setuptools_plugin.py @@ -32,8 +32,6 @@ def test_compile(compiled_plugin_dir: Path, tmp_path: Path, dist_type: str) -> N pyproject = compiled_plugin_dir / "pyproject.toml" pyproject.write_text(PYPROJECT) - print(f"pyproject.toml {PYPROJECT!r}") - template = compiled_plugin_dir / TEMPLATE template.write_text("name: my_compiled_plugin\ndisplay_name: My Compiled Plugin\n") os.chdir(compiled_plugin_dir) From 11981366e67b88ff041cd67646d107663e9497ba Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 14:02:14 +0100 Subject: [PATCH 12/20] fix test name --- tests/test_fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 241b8569..92f2f9d3 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -70,7 +70,7 @@ def test_from_pypi_wheel_bdist_missing(): @pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI") -def testfetch_manifest_with_full_install(): +def test_fetch_manifest_with_full_install(): # TODO: slowest of the tests ... would be nice to provide a local mock mf = fetch_manifest_with_full_install("napari-ndtiffs", version="0.1.2") # use version 0.1.2 which is npe1 From a17cc2d303e1943ae5a17636237f44e2872551de Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Mon, 30 Oct 2023 14:45:50 +0100 Subject: [PATCH 13/20] try fix full install --- src/npe2/_inspection/_full_install.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/npe2/_inspection/_full_install.py b/src/npe2/_inspection/_full_install.py index 27f59cdc..209c247c 100644 --- a/src/npe2/_inspection/_full_install.py +++ b/src/npe2/_inspection/_full_install.py @@ -70,7 +70,8 @@ def isolated_plugin_env( prefixes = [getattr(env, "path")] # noqa if not (site_pkgs := site.getsitepackages(prefixes=prefixes)): raise ValueError("No site-packages found") # pragma: no cover - sys.path.insert(0, site_pkgs[0]) + for el in reversed(site_pkgs): + sys.path.insert(0, el) try: if validate_npe1_imports: # try to import the plugin's entry points @@ -91,8 +92,9 @@ def isolated_plugin_env( raise yield env finally: - # cleanup sys.path - sys.path.pop(0) + for _el in site_pkgs: + # cleanup sys.path + sys.path.pop(0) def _get_loaded_mf_or_die(package: str) -> PluginManifest: From 91cecce90959850f10300bf4e0233accd9d5c45a Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Tue, 31 Oct 2023 16:54:30 +0100 Subject: [PATCH 14/20] remove dead code --- src/npe2/_inspection/_full_install.py | 123 -------------------------- tests/test_all_plugins.py | 30 ------- tests/test_fetch.py | 13 --- 3 files changed, 166 deletions(-) delete mode 100644 src/npe2/_inspection/_full_install.py diff --git a/src/npe2/_inspection/_full_install.py b/src/npe2/_inspection/_full_install.py deleted file mode 100644 index 209c247c..00000000 --- a/src/npe2/_inspection/_full_install.py +++ /dev/null @@ -1,123 +0,0 @@ -"""This module is mostly superceded by the static NPE1ModuleVisitor pattern. - -It is left here for reference, but could be removed in the future. -""" -from __future__ import annotations - -import site -import sys -import warnings -from contextlib import contextmanager -from importlib import metadata -from logging import getLogger -from typing import TYPE_CHECKING, Iterator, Optional - -if TYPE_CHECKING: - from build.env import IsolatedEnv - - from npe2.manifest import PluginManifest - -logger = getLogger(__name__) -__all__ = [ - "fetch_manifest_with_full_install", - "isolated_plugin_env", -] - -NPE1_ENTRY_POINT = "napari.plugin" -NPE2_ENTRY_POINT = "napari.manifest" - - -@contextmanager -def isolated_plugin_env( - package: str, - version: Optional[str] = None, - validate_npe1_imports: bool = True, - install_napari_if_necessary: bool = True, -) -> Iterator[IsolatedEnv]: - """Isolated env context with a plugin installed. - - The site-packages folder of the env is added to sys.path within the context. - - Parameters - ---------- - package : str - package name - version : Optional[str] - package version, by default, latest version. - validate_npe1_imports: bool - Whether to try to import an npe1 plugin's entry points. by default True. - install_napari_if_necessary: bool - If `validate_npe1_imports` is True, whether to install napari if the import - fails. (It's not uncommon for plugins to fail to specify napari as a - dependency. Othertimes, they simply need a qt backend.). by default True. - - Yields - ------ - build.env.IsolatedEnv - env object that has an `install` method. - """ - # 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 DefaultIsolatedEnv - - with DefaultIsolatedEnv() as env: - # install the package - pkg = f"{package}=={version}" if version else package - logger.debug(f"installing {pkg} into virtual env") - env.install([pkg]) - - # temporarily add env site packages to path - prefixes = [getattr(env, "path")] # noqa - if not (site_pkgs := site.getsitepackages(prefixes=prefixes)): - raise ValueError("No site-packages found") # pragma: no cover - for el in reversed(site_pkgs): - sys.path.insert(0, el) - try: - if validate_npe1_imports: - # try to import the plugin's entry points - dist = metadata.distribution(package) - ep_groups = {ep.group for ep in dist.entry_points} - if NPE1_ENTRY_POINT in ep_groups and NPE2_ENTRY_POINT not in ep_groups: - try: - _get_loaded_mf_or_die(package) - except Exception: # pragma: no cover - # if loading contributions fails, it can very often be fixed - # by installing `napari[all]` into the environment - if install_napari_if_necessary: - env.install(["napari[all]"]) - # force reloading of qtpy - sys.modules.pop("qtpy", None) - _get_loaded_mf_or_die(package) - else: - raise - yield env - finally: - for _el in site_pkgs: - # cleanup sys.path - sys.path.pop(0) - - -def _get_loaded_mf_or_die(package: str) -> PluginManifest: - """Return a fully loaded (if npe1) manifest, or raise an exception.""" - from npe2 import PluginManifest - from npe2.manifest._npe1_adapter import NPE1Adapter - - mf = PluginManifest.from_distribution(package) - if isinstance(mf, NPE1Adapter): - with warnings.catch_warnings(): - warnings.filterwarnings("error", message="Error importing contributions") - warnings.filterwarnings("error", message="Failed to convert") - warnings.filterwarnings("ignore", message="Found a multi-layer writer") - mf._load_contributions(save=False) - return mf - - -def fetch_manifest_with_full_install( - package: str, version: Optional[str] = None -) -> PluginManifest: - """Fetch manifest for plugin by installing into an isolated environment.""" - # create an isolated env in which to install npe1 plugin - with isolated_plugin_env( - package, version, validate_npe1_imports=True, install_napari_if_necessary=True - ): - return _get_loaded_mf_or_die(package) diff --git a/tests/test_all_plugins.py b/tests/test_all_plugins.py index deff755b..2a4df7ba 100644 --- a/tests/test_all_plugins.py +++ b/tests/test_all_plugins.py @@ -1,11 +1,8 @@ import os -from importlib import metadata -from subprocess import CalledProcessError from typing import TYPE_CHECKING import pytest -from npe2._inspection._full_install import isolated_plugin_env from npe2.cli import app if TYPE_CHECKING: @@ -16,33 +13,6 @@ pytest.skip("skipping plugin specific tests", allow_module_level=True) -@pytest.fixture(scope="session") -def plugin_env(): - try: - with isolated_plugin_env(PLUGIN) as env: - yield env - except CalledProcessError as e: - if "Failed building wheel" in str(e.output): - yield None - - -def test_entry_points_importable(plugin_env): - if plugin_env is None: - pytest.mark.xfail() - return - - entry_points = [ - ep - for ep in metadata.distribution(PLUGIN).entry_points - if ep.group in ("napari.plugin", "napari.manifest") - ] - if PLUGIN not in {"napari-console", "napari-error-reporter"}: - assert entry_points - - for ep in entry_points: - if ep.group == "napari.plugin": - ep.load() - def test_fetch(tmp_path: "Path"): from typer.testing import CliRunner diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 92f2f9d3..7dfcd298 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -13,9 +13,6 @@ get_pypi_plugins, get_pypi_url, ) -from npe2._inspection._full_install import fetch_manifest_with_full_install -from npe2.manifest._npe1_adapter import NPE1Adapter - def test_fetch_npe2_manifest(): mf = fetch_manifest("napari-omero") @@ -69,16 +66,6 @@ def test_from_pypi_wheel_bdist_missing(): fetch_manifest("my-package") -@pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI") -def test_fetch_manifest_with_full_install(): - # TODO: slowest of the tests ... would be nice to provide a local mock - mf = fetch_manifest_with_full_install("napari-ndtiffs", version="0.1.2") - # use version 0.1.2 which is npe1 - assert isinstance(mf, NPE1Adapter) - assert mf.name == "napari-ndtiffs" - assert mf.contributions - - @pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI") def test_manifest_from_sdist(): mf = _manifest_from_pypi_sdist("zarpaint") From 1b127c22b00867ba223406418a8abe6d71d9dc61 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:54:49 +0000 Subject: [PATCH 15/20] style: [pre-commit.ci] auto fixes [...] --- tests/test_all_plugins.py | 1 - tests/test_fetch.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_all_plugins.py b/tests/test_all_plugins.py index 2a4df7ba..16aa251a 100644 --- a/tests/test_all_plugins.py +++ b/tests/test_all_plugins.py @@ -13,7 +13,6 @@ pytest.skip("skipping plugin specific tests", allow_module_level=True) - def test_fetch(tmp_path: "Path"): from typer.testing import CliRunner diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 7dfcd298..7cd0f7ac 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -14,6 +14,7 @@ get_pypi_url, ) + def test_fetch_npe2_manifest(): mf = fetch_manifest("napari-omero") assert mf.name == "napari-omero" From 35b819eb0ea9bfc561c5837925fa693a7734d3d4 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Wed, 1 Nov 2023 09:24:50 +0100 Subject: [PATCH 16/20] use dummy plugin --- tests/test_fetch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 7cd0f7ac..eeadd3ee 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -24,7 +24,7 @@ def test_fetch_npe2_manifest(): @pytest.mark.skip("package looks deleted from pypi") def test_fetch_npe1_manifest_with_writer(): - mf = fetch_manifest("example-plugin") + mf = fetch_manifest("dummy-test-plugin", version="0.1.1") assert mf.name == "example-plugin" assert mf.contributions.writers # Test will eventually fail when example-plugin is updated to npe2 @@ -97,7 +97,7 @@ def test_get_pypi_plugins(): [ "https://files.pythonhosted.org/packages/fb/01/e59bc1d6ac96f84ce9d7a46cc5422250e047958ead6c5693ed386cf94003/napari_dv-0.3.0.tar.gz", # noqa "https://files.pythonhosted.org/packages/5d/ae/17779e12ce60d8329306963e1a8dec608465caee582440011ff0c1310715/example_plugin-0.0.7-py3-none-any.whl", # noqa - # "git+https://github.com/DragaDoncila/example-plugin.git", Draga hide package + "git+https://github.com/napari/dummy-test-plugin.git@npe1", # this one doesn't use setuptools_scm, can check direct zip without clone "https://github.com/jo-mueller/napari-stl-exporter/archive/refs/heads/main.zip", ], From 93055737b6d1acf5e603809faa2ad143f68ab06f Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Wed, 1 Nov 2023 09:38:56 +0100 Subject: [PATCH 17/20] Revert "limit ci" This reverts commit 40330860ce9cb8b11c948f426dc94bfd92e7ccfd. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0118870..4552d71a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,8 +28,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.8] #, 3.9, "3.10", "3.11"] - platform: [windows-latest] #[ubuntu-latest, macos-latest, windows-latest] + python-version: [3.8, 3.9, "3.10", "3.11"] + platform: [ubuntu-latest, macos-latest, windows-latest] pydantic: ["pydantic<2", "pydantic>2"] steps: From 1b1276b8ae8de21a0d77228783f508196bb2ca97 Mon Sep 17 00:00:00 2001 From: Grzegorz Bokota Date: Wed, 1 Nov 2023 09:50:19 +0100 Subject: [PATCH 18/20] add checkout of branch --- src/npe2/_inspection/_fetch.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/npe2/_inspection/_fetch.py b/src/npe2/_inspection/_fetch.py index 95a18826..b6cd45b8 100644 --- a/src/npe2/_inspection/_fetch.py +++ b/src/npe2/_inspection/_fetch.py @@ -204,8 +204,16 @@ def _get_manifest_from_git_url(url: str) -> PluginManifest: if url.startswith("git+"): url = url[4:] + branch = "" + if "@" in url: + url, branch = url.split("@") + with tempfile.TemporaryDirectory() as td: subprocess.run(["git", "clone", url, td], stdout=subprocess.DEVNULL) + if branch: + subprocess.run( + ["git", "checkout", branch], cwd=td, stdout=subprocess.DEVNULL + ) return _build_src_and_extract_manifest(td) From 164038b3750e52fe6d4bc1eeff68429f33783642 Mon Sep 17 00:00:00 2001 From: Draga Doncila Pop <17995243+DragaDoncila@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:43:13 +1100 Subject: [PATCH 19/20] Update dummy-test-plugin version --- tests/test_fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index eeadd3ee..0b39a42f 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -24,7 +24,7 @@ def test_fetch_npe2_manifest(): @pytest.mark.skip("package looks deleted from pypi") def test_fetch_npe1_manifest_with_writer(): - mf = fetch_manifest("dummy-test-plugin", version="0.1.1") + mf = fetch_manifest("dummy-test-plugin", version="0.1.2") assert mf.name == "example-plugin" assert mf.contributions.writers # Test will eventually fail when example-plugin is updated to npe2 From 39eef8d03c7fc0430870edca584fd504f1edac40 Mon Sep 17 00:00:00 2001 From: Draga Doncila Pop <17995243+DragaDoncila@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:11:56 +1100 Subject: [PATCH 20/20] Bump test plugin to 0.1.3 --- tests/test_fetch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 0b39a42f..a404edd8 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -24,7 +24,7 @@ def test_fetch_npe2_manifest(): @pytest.mark.skip("package looks deleted from pypi") def test_fetch_npe1_manifest_with_writer(): - mf = fetch_manifest("dummy-test-plugin", version="0.1.2") + mf = fetch_manifest("dummy-test-plugin", version="0.1.3") assert mf.name == "example-plugin" assert mf.contributions.writers # Test will eventually fail when example-plugin is updated to npe2