Repository: pyodide/pyodide

Issue:
Github release file description lacking in docs for v0.22
## 📚 Documentation

<!--
For typos and doc fixes, please go ahead and:

1. Create an issue (You can skip this if it is a very simple fix).
1. Fix the documentation.
1. Submit a PR.

Note: If there are no changes in code, we recommend you to append `[skip ci]` in your commit message to avoid starting the build CI.

Thanks!
-->

I noted that in the recently released 0.22 version of Pyodide the text for GitHub releases is wrong: https://pyodide.org/en/stable/usage/downloading-and-deploying.html#github-releases 

It seems that now there are two files, `pyodide-0.22.0.tar.bz2` and `pyodide-core-0.22.0.tar.bz2`, but Im not sure when I need which file. It would be great if it was written down. In addition, maybe the next section in the documentation would also need to be updated? (https://pyodide.org/en/stable/usage/downloading-and-deploying.html#serving-locally)


Discussion:
Thanks for the report, this should indeed be updated. `pyodide` has all packages, `pyodide-core` has the minimal set of packages needed to run the Pyodide core test suite. The `pyodide-core` distribution is intended primarily for use in node.

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -19,12 +19,6 @@
 
 project = "Pyodide"
 copyright = "2019-2022, Pyodide contributors and Mozilla"
-pyodide_version = "0.22.0"
-
-if ".dev" in pyodide_version or os.environ.get("READTHEDOCS_VERSION") == "latest":
-    CDN_URL = "https://cdn.jsdelivr.net/pyodide/dev/full/"
-else:
-    CDN_URL = f"https://cdn.jsdelivr.net/pyodide/v{pyodide_version}/full/"
 
 # -- General configuration ---------------------------------------------------
 
@@ -133,20 +127,14 @@
 # A list of files that should not be packed into the epub file.
 epub_exclude_files = ["search.html"]
 
-
-def delete_attrs(cls):
-    """Prevent attributes of a class or module from being documented.
-
-    The top level documentation comment of the class or module will still be
-    rendered.
-    """
-    for name in dir(cls):
-        if not name.startswith("_"):
-            try:
-                delattr(cls, name)
-            except Exception:
-                pass
-
+base_dir = Path(__file__).resolve().parent.parent
+extra_sys_path_dirs = [
+    str(base_dir),
+    str(base_dir / "pyodide-build"),
+    str(base_dir / "docs/sphinx_pyodide"),
+    str(base_dir / "src/py"),
+    str(base_dir / "packages/micropip/src"),
+]
 
 # Try not to cause side effects if we are imported incidentally.
 
@@ -159,7 +147,39 @@ def delete_attrs(cls):
 
 IN_READTHEDOCS = "READTHEDOCS" in os.environ
 
+if IN_SPHINX:
+    sys.path = extra_sys_path_dirs + sys.path
+    import builtins
+
+    from sphinx_pyodide.util import docs_argspec
+
+    # override docs_argspec, _pyodide.docs_argspec will read this value back.
+    # Must do this before importing pyodide!
+    setattr(builtins, "--docs_argspec--", docs_argspec)
+
+    # Monkey patch for python3.11 incompatible code
+    import inspect
+
+    if not hasattr(inspect, "getargspec"):
+        inspect.getargspec = inspect.getfullargspec  # type: ignore[assignment]
+
+import pyodide
+
+# The full version, including alpha/beta/rc tags.
+release = version = pyodide.__version__
+
+if ".dev" in version or os.environ.get("READTHEDOCS_VERSION") == "latest":
+    CDN_URL = "https://cdn.jsdelivr.net/pyodide/dev/full/"
+else:
+    CDN_URL = f"https://cdn.jsdelivr.net/pyodide/v{version}/full/"
+
+html_title = f"Version {version}"
+
+global_replacements = {"{{PYODIDE_CDN_URL}}": CDN_URL, "{{VERSION}}": version}
+
+
 if IN_READTHEDOCS:
+    # Make console.html file
     env = {"PYODIDE_BASE_URL": CDN_URL}
     os.makedirs("_build/html", exist_ok=True)
     res = subprocess.check_output(
@@ -185,81 +205,15 @@ def delete_attrs(cls):
     console_path.write_text("".join(console_html))
 
 
-def docs_argspec(argspec: str) -> Any:
-    """Decorator to override the argument spec of the function that is
-    rendered in the docs.
-
-    If the documentation finds a __wrapped__ attribute, it will use that to
-    render the argspec instead of the function itself. Assign an appropriate
-    fake function to __wrapped__ with the desired argspec.
-    """
-
-    def dec(func):
-        d = func.__globals__
-        TEMP_NAME = "_xxxffff___"
-        assert TEMP_NAME not in d
-        code = dedent(
-            f"""\
-            def {TEMP_NAME}{argspec}:
-                pass
-            """
-        )
-        # exec in func.__globals__ context so that type hints don't case NameErrors.
-        exec(code, d)
-        f = d.pop(TEMP_NAME)
-
-        # # Run update_wrapper but keep f's annotations and don't set
-        # # f.__wrapped__ (would cause an infinite loop!)
-        annotations = f.__annotations__
-        update_wrapper(f, func)
-        f.__annotations__ = annotations
-        del f.__wrapped__
-
-        # Set wrapper to be our fake function
-        func.__wrapped__ = f
-
-        return func
-
-    return dec
-
-
 if IN_SPHINX:
-    import inspect
-
-    if not hasattr(inspect, "getargspec"):
-        inspect.getargspec = inspect.getfullargspec  # type: ignore[assignment]
-
-    base_dir = Path(__file__).resolve().parent.parent
-    path_dirs = [
-        str(base_dir),
-        str(base_dir / "pyodide-build"),
-        str(base_dir / "docs/sphinx_pyodide"),
-        str(base_dir / "src/py"),
-        str(base_dir / "packages/micropip/src"),
-    ]
-    sys.path = path_dirs + sys.path
-
     from sphinx.domains.javascript import JavaScriptDomain, JSXRefRole
 
     JavaScriptDomain.roles["class"] = JSXRefRole()
 
-    import builtins
-    from functools import update_wrapper
-    from textwrap import dedent
-
-    # override docs_argspec, _pyodide.docs_argspec will read this value back.
-    # Must do this before importing pyodide!
-    setattr(builtins, "--docs_argspec--", docs_argspec)
-
-    import pyodide
     from pyodide.ffi import JsProxy
 
     del JsProxy.__new__
 
-    # The full version, including alpha/beta/rc tags.
-    release = version = pyodide.__version__
-    html_title = f"Version {version}"
-
     shutil.copy("../src/core/pyproxy.ts", "../src/js/pyproxy.gen.ts")
     shutil.copy("../src/core/error_handling.ts", "../src/js/error_handling.gen.ts")
     js_source_path = [str(x) for x in Path("../src/js").glob("*.ts")]
@@ -280,6 +234,8 @@ def remove_pyproxy_gen_ts():
 
     # Prevent API docs for webloop methods: they are the same as for base event loop
     # and it clutters api docs too much
+    from sphinx_pyodide.util import delete_attrs
+
     import pyodide.console
     import pyodide.webloop
 
@@ -299,8 +255,6 @@ def globalReplace(app, docname, source):
     source[0] = result
 
 
-global_replacements = {"{{PYODIDE_CDN_URL}}": CDN_URL}
-
 always_document_param_types = True
 
 
diff --git a/docs/sphinx_pyodide/sphinx_pyodide/util.py b/docs/sphinx_pyodide/sphinx_pyodide/util.py
new file mode 100644
--- /dev/null
+++ b/docs/sphinx_pyodide/sphinx_pyodide/util.py
@@ -0,0 +1,55 @@
+from functools import update_wrapper
+from textwrap import dedent
+from typing import Any
+
+
+def delete_attrs(cls):
+    """Prevent attributes of a class or module from being documented.
+
+    The top level documentation comment of the class or module will still be
+    rendered.
+    """
+    for name in dir(cls):
+        if not name.startswith("_"):
+            try:
+                delattr(cls, name)
+            except Exception:
+                pass
+
+
+def docs_argspec(argspec: str) -> Any:
+    """Decorator to override the argument spec of the function that is
+    rendered in the docs.
+
+    If the documentation finds a __wrapped__ attribute, it will use that to
+    render the argspec instead of the function itself. Assign an appropriate
+    fake function to __wrapped__ with the desired argspec.
+    """
+
+    def dec(func):
+        d = func.__globals__
+        TEMP_NAME = "_xxxffff___"
+        assert TEMP_NAME not in d
+        code = dedent(
+            f"""\
+            def {TEMP_NAME}{argspec}:
+                pass
+            """
+        )
+        # exec in func.__globals__ context so that type hints don't case NameErrors.
+        exec(code, d)
+        f = d.pop(TEMP_NAME)
+
+        # # Run update_wrapper but keep f's annotations and don't set
+        # # f.__wrapped__ (would cause an infinite loop!)
+        annotations = f.__annotations__
+        update_wrapper(f, func)
+        f.__annotations__ = annotations
+        del f.__wrapped__
+
+        # Set wrapper to be our fake function
+        func.__wrapped__ = f
+
+        return func
+
+    return dec
diff --git a/tools/bump_version.py b/tools/bump_version.py
--- a/tools/bump_version.py
+++ b/tools/bump_version.py
@@ -49,11 +49,6 @@ def build_version_pattern(pattern):
         pattern=build_version_pattern('__version__ = "{python_version}"'),
         prerelease=True,
     ),
-    Target(
-        ROOT / "docs/conf.py",
-        build_version_pattern('pyodide_version = "{python_version}"'),
-        prerelease=True,
-    ),
     Target(
         ROOT / "docs/project/about.md",
         build_version_pattern(r"version\s*=\s*{{{python_version}}}"),


Test patch: