From 5faa6368263273db00f17bcd9a8a94213e7e245c Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 10:11:00 +0200 Subject: [PATCH 1/9] Bump Pyodide on CI Also change to explicitely use strings. I'm guessing this should be bumped, maybe there is an automatic way to do latest ? Also not sure if you want to test on alphas, but I guess it's always useful to catch bugs. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7193e4d..4826ac8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04] - pyodide-version: [0.24.1, 0.25.0] + pyodide-version: ['0.24.1', '0.25.0', '0.26.2', '0.27.0a2'] test-config: [ {runner: selenium, runtime: chrome, runtime-version: latest }, ] From 596d0ac2df5fa56bd460bdf6d1a6fcfcd0145c92 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 11:17:53 +0200 Subject: [PATCH 2/9] fix tests --- tests/test_uninstall.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index 6f8e9ad..c092d92 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -171,6 +171,9 @@ async def run(selenium, pkg_name, wheel_url): import contextlib import io + import pyodide + from packaging.version import parse + with io.StringIO() as buf, contextlib.redirect_stdout(buf): await micropip.install(wheel_url) @@ -188,10 +191,12 @@ async def run(selenium, pkg_name, wheel_url): captured = buf.getvalue() logs = captured.strip().split("\n") - - assert len(logs) == 2 - assert "does not exist" in logs[-1] - assert "does not exist" in logs[-2] + if parse(pyodide.__version__) < parse("0.27"): + assert len(logs) == 2, logs + assert "does not exist" in logs[-1] + assert "does not exist" in logs[-2] + else: + assert logs == [""] test_wheel = wheel_catalog.get(TEST_PACKAGE_NAME) From 53ad8fe7cdc098b819096785f386e160fc5ac45b Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 11:23:56 +0200 Subject: [PATCH 3/9] debug --- tests/test_uninstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index c092d92..2dc86e4 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -192,7 +192,7 @@ async def run(selenium, pkg_name, wheel_url): captured = buf.getvalue() logs = captured.strip().split("\n") if parse(pyodide.__version__) < parse("0.27"): - assert len(logs) == 2, logs + assert len(logs) == 2, (logs, pyodide.__version__) assert "does not exist" in logs[-1] assert "does not exist" in logs[-2] else: From 794e8479183e5df06b58bfaea867a23d8d7e0972 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 11:38:47 +0200 Subject: [PATCH 4/9] Shot in the dark, ar warnings sets to stderr ? --- tests/test_uninstall.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index 2dc86e4..4a4eb3a 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -174,7 +174,12 @@ async def run(selenium, pkg_name, wheel_url): import pyodide from packaging.version import parse - with io.StringIO() as buf, contextlib.redirect_stdout(buf): + with ( + io.StringIO() as buf, + contextlib.redirect_stdout(buf), + io.StringIO() as ebuf, + contextlib.redirect_stderr(ebuf), + ): await micropip.install(wheel_url) assert pkg_name in micropip.list() @@ -189,10 +194,10 @@ async def run(selenium, pkg_name, wheel_url): micropip.uninstall(pkg_name) - captured = buf.getvalue() - logs = captured.strip().split("\n") - if parse(pyodide.__version__) < parse("0.27"): - assert len(logs) == 2, (logs, pyodide.__version__) + logs = buf.getvalue().strip().split("\n") + elogs = ebuf.getvalue().strip().split("\n") + if parse(pyodide.__version__) < parse("0.27.0"): + assert len(logs) == 2, (logs, pyodide.__version__, elogs) assert "does not exist" in logs[-1] assert "does not exist" in logs[-2] else: From 173b8b5cd6db6384ef8db9501b26c0b80fcdf74c Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 12:04:34 +0200 Subject: [PATCH 5/9] extra log --- micropip/_commands/uninstall.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/micropip/_commands/uninstall.py b/micropip/_commands/uninstall.py index a22f3e7..be2b6d2 100644 --- a/micropip/_commands/uninstall.py +++ b/micropip/_commands/uninstall.py @@ -61,6 +61,9 @@ def uninstall(packages: str | list[str], *, verbose: bool | int = False) -> None # - scripts # - entry_points # Since we don't support these, we can ignore them (except for data_files (TODO)) + logger.warning( + "skipping file '%s' that is relative to root", + ) continue logger.warning( From 708d22c471defcde1f21e689a148be0a242ac9e1 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 13:56:03 +0200 Subject: [PATCH 6/9] partial --- tests/test_uninstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index 4a4eb3a..2715ab6 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -196,7 +196,7 @@ async def run(selenium, pkg_name, wheel_url): logs = buf.getvalue().strip().split("\n") elogs = ebuf.getvalue().strip().split("\n") - if parse(pyodide.__version__) < parse("0.27.0"): + if parse(pyodide.__version__) <= parse("0.27.0a2"): assert len(logs) == 2, (logs, pyodide.__version__, elogs) assert "does not exist" in logs[-1] assert "does not exist" in logs[-2] From 4ac4bee56c9c2efa11fb705f7fada9c2c2b21654 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 14:01:27 +0200 Subject: [PATCH 7/9] I'm not smart and cant make a proper versioncheck --- tests/test_uninstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index 2715ab6..e591483 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -196,7 +196,7 @@ async def run(selenium, pkg_name, wheel_url): logs = buf.getvalue().strip().split("\n") elogs = ebuf.getvalue().strip().split("\n") - if parse(pyodide.__version__) <= parse("0.27.0a2"): + if parse(pyodide.__version__) < parse("0.26.0"): assert len(logs) == 2, (logs, pyodide.__version__, elogs) assert "does not exist" in logs[-1] assert "does not exist" in logs[-2] From f74c7f02d20ff5d1b5b1addb29d8bea24382667d Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 14:09:49 +0200 Subject: [PATCH 8/9] moar stuff --- tests/test_uninstall.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index e591483..fe1563e 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -186,11 +186,10 @@ async def run(selenium, pkg_name, wheel_url): dist = distribution(pkg_name) files = dist.files - file1 = files[0] - file2 = files[1] - - file1.locate().unlink() - file2.locate().unlink() + for file in (files[0], files[1]): + path = file.locate() + assert path.name.endswith(".py") + path.unlink() micropip.uninstall(pkg_name) From d2043ee16a3c3c3c16c71668243529d635b7b04f Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Mon, 26 Aug 2024 14:34:09 +0200 Subject: [PATCH 9/9] Remove not relevant test. As pointed out by Gyeongjae Choi in 130, those file are listed since Python 3.12 and thus this error shouls not trigger. --- micropip/_commands/uninstall.py | 3 +- tests/test_uninstall.py | 52 --------------------------------- 2 files changed, 2 insertions(+), 53 deletions(-) diff --git a/micropip/_commands/uninstall.py b/micropip/_commands/uninstall.py index be2b6d2..595cc09 100644 --- a/micropip/_commands/uninstall.py +++ b/micropip/_commands/uninstall.py @@ -65,7 +65,8 @@ def uninstall(packages: str | list[str], *, verbose: bool | int = False) -> None "skipping file '%s' that is relative to root", ) continue - + # see PR 130, it is likely that this is never triggered since Python 3.12 + # as non existing files are not listed by get_files_in_distribution anymore. logger.warning( f"A file '{file}' listed in the metadata of '{name}' does not exist.", ) diff --git a/tests/test_uninstall.py b/tests/test_uninstall.py index fe1563e..f862345 100644 --- a/tests/test_uninstall.py +++ b/tests/test_uninstall.py @@ -159,58 +159,6 @@ async def run(selenium): run(selenium_standalone_micropip) -def test_warning_file_removed(selenium_standalone_micropip, wheel_catalog): - """ - Test warning when files in a package are removed by user. - """ - - @run_in_pyodide() - async def run(selenium, pkg_name, wheel_url): - from importlib.metadata import distribution - import micropip - import contextlib - import io - - import pyodide - from packaging.version import parse - - with ( - io.StringIO() as buf, - contextlib.redirect_stdout(buf), - io.StringIO() as ebuf, - contextlib.redirect_stderr(ebuf), - ): - await micropip.install(wheel_url) - - assert pkg_name in micropip.list() - - dist = distribution(pkg_name) - files = dist.files - for file in (files[0], files[1]): - path = file.locate() - assert path.name.endswith(".py") - path.unlink() - - micropip.uninstall(pkg_name) - - logs = buf.getvalue().strip().split("\n") - elogs = ebuf.getvalue().strip().split("\n") - if parse(pyodide.__version__) < parse("0.26.0"): - assert len(logs) == 2, (logs, pyodide.__version__, elogs) - assert "does not exist" in logs[-1] - assert "does not exist" in logs[-2] - else: - assert logs == [""] - - test_wheel = wheel_catalog.get(TEST_PACKAGE_NAME) - - run( - selenium_standalone_micropip, - test_wheel.name, - test_wheel.url, - ) - - def test_warning_remaining_file(selenium_standalone_micropip, wheel_catalog): """ Test warning when there are remaining files after uninstallation.