Date: Friday, April 21, 2023 @ 18:10:35
  Author: arojas
Revision: 1448179

upgpkg: python-nox 2022.11.21-1: Python 3.11 rebuild

Added:
  python-nox/trunk/41387eda.patch
Modified:
  python-nox/trunk/PKGBUILD

----------------+
 41387eda.patch |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 PKGBUILD       |    3 -
 2 files changed, 166 insertions(+), 1 deletion(-)

Added: 41387eda.patch
===================================================================
--- 41387eda.patch                              (rev 0)
+++ 41387eda.patch      2023-04-21 18:10:35 UTC (rev 1448179)
@@ -0,0 +1,164 @@
+From 41387eda390183ed390f5a9e612cb0d47f68628e Mon Sep 17 00:00:00 2001
+From: Lumir Balhar <[email protected]>
+Date: Mon, 20 Feb 2023 15:26:06 +0100
+Subject: [PATCH] to_to_nox implementation for tox 4
+
+---
+ nox/tox4_to_nox.jinja2 | 33 +++++++++++++++++
+ nox/tox_to_nox.py      | 84 ++++++++++++++++++++++++++++++++++++++----
+ pyproject.toml         |  2 +-
+ 3 files changed, 110 insertions(+), 9 deletions(-)
+ create mode 100644 nox/tox4_to_nox.jinja2
+
+diff --git a/nox/tox4_to_nox.jinja2 b/nox/tox4_to_nox.jinja2
+new file mode 100644
+index 00000000..e5a67d9b
+--- /dev/null
++++ b/nox/tox4_to_nox.jinja2
+@@ -0,0 +1,33 @@
++import nox
++
++{% for envname, envconfig in config.items()|sort: %}
[email protected]({%- if envconfig.base_python 
%}python='{{envconfig.base_python}}'{%- endif %})
++def {{fixname(envname)}}(session):
++    {%- if envconfig.description != '' %}
++    """{{envconfig.description}}"""
++    {%- endif %}
++    {%- set envs = envconfig.get('set_env', {}) -%}
++    {%- for key, value in envs.items()|sort: %}
++    session.env['{{key}}'] = '{{value}}'
++    {%- endfor %}
++
++    {%- if envconfig.deps %}
++    session.install({{envconfig.deps}})
++    {%- endif %}
++
++    {%- if not envconfig.skip_install %}
++    {%- if envconfig.use_develop %}
++    session.install('-e', '.')
++    {%- else %}
++    session.install('.')
++    {%- endif -%}
++    {%- endif %}
++
++    {%- if envconfig.change_dir %}
++    session.chdir('{{envconfig.change_dir}}')
++    {%- endif %}
++
++    {%- for command in envconfig.commands %}
++    session.run({{command}})
++    {%- endfor %}
++{% endfor %}
+diff --git a/nox/tox_to_nox.py b/nox/tox_to_nox.py
+index a6591b4b..26b0146c 100644
+--- a/nox/tox_to_nox.py
++++ b/nox/tox_to_nox.py
+@@ -17,24 +17,38 @@
+ from __future__ import annotations
+ 
+ import argparse
++import os
+ import pkgutil
+-from typing import Any, Iterator
++import re
++from configparser import ConfigParser
++from pathlib import Path
++from subprocess import check_output
++from typing import Any, Iterable
+ 
+ import jinja2
+ import tox.config
++from tox import __version__ as TOX_VERSION
+ 
+-_TEMPLATE = jinja2.Template(
+-    pkgutil.get_data(__name__, "tox_to_nox.jinja2").decode("utf-8"),  # type: 
ignore[union-attr]
+-    extensions=["jinja2.ext.do"],
+-)
++TOX4 = TOX_VERSION[0] == "4"
+ 
++if TOX4:
++    _TEMPLATE = jinja2.Template(
++        pkgutil.get_data(__name__, "tox4_to_nox.jinja2").decode("utf-8"),  # 
type: ignore[union-attr]
++        extensions=["jinja2.ext.do"],
++    )
++else:
++    _TEMPLATE = jinja2.Template(
++        pkgutil.get_data(__name__, "tox_to_nox.jinja2").decode("utf-8"),  # 
type: ignore[union-attr]
++        extensions=["jinja2.ext.do"],
++    )
+ 
+-def wrapjoin(seq: Iterator[Any]) -> str:
++
++def wrapjoin(seq: Iterable[Any]) -> str:
+     return ", ".join([f"'{item}'" for item in seq])
+ 
+ 
+ def fixname(envname: str) -> str:
+-    envname = envname.replace("-", "_")
++    envname = envname.replace("-", "_").replace("testenv:", "")
+     if not envname.isidentifier():
+         print(
+             f"Environment {envname!r} is not a valid nox session name.\n"
+@@ -49,7 +63,61 @@ def main() -> None:
+ 
+     args = parser.parse_args()
+ 
+-    config = tox.config.parseconfig([])
++    if TOX4:
++        output = check_output(["tox", "config"], text=True)
++        original_config = ConfigParser()
++        original_config.read_string(output)
++        config: dict[str, dict[str, Any]] = {}
++
++        for name, section in original_config.items():
++            if name == "DEFAULT":
++                continue
++
++            config[name] = dict(section)
++            # Convert set_env from string to dict
++            set_env = {}
++            for var in section.get("set_env", "").strip().splitlines():
++                k, v = var.split("=")
++                if k not in (
++                    "PYTHONHASHSEED",
++                    "PIP_DISABLE_PIP_VERSION_CHECK",
++                    "PYTHONIOENCODING",
++                ):
++                    set_env[k] = v
++
++            config[name]["set_env"] = set_env
++
++            config[name]["commands"] = [
++                wrapjoin(c.split()) for c in 
section["commands"].strip().splitlines()
++            ]
++
++            config[name]["deps"] = 
wrapjoin(section["deps"].strip().splitlines())
++
++            for option in "skip_install", "use_develop":
++                if section.get(option):
++                    if section[option] == "False":
++                        config[name][option] = False
++                    else:
++                        config[name][option] = True
++
++            if os.path.isabs(section["base_python"]) or re.match(
++                r"py\d+", section["base_python"]
++            ):
++                impl = (
++                    "python" if section["py_impl"] == "cpython" else 
section["py_impl"]
++                )
++                config[name]["base_python"] = impl + section["py_dot_ver"]
++
++            change_dir = Path(section.get("change_dir"))
++            rel_to_cwd = change_dir.relative_to(Path.cwd())
++            if str(rel_to_cwd) == ".":
++                config[name]["change_dir"] = None
++            else:
++                config[name]["change_dir"] = rel_to_cwd
++
++    else:
++        config = tox.config.parseconfig([])
++
+     output = _TEMPLATE.render(config=config, wrapjoin=wrapjoin, 
fixname=fixname)
+ 
+     with open(args.output, "w") as outfile:

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2023-04-21 17:47:58 UTC (rev 1448178)
+++ PKGBUILD    2023-04-21 18:10:35 UTC (rev 1448179)
@@ -25,7 +25,8 @@
 check() {
   cd $_pkgname-$pkgver
 
-  python -m pytest
+# tox 4 isn't supported https://github.com/wntrblm/nox/issues/673
+  python -m pytest -k 'not test_tox_to_nox'
 }
 
 package() {

Reply via email to