Files
cibuildwheel/cibuildwheel/extra.py
T
mayeut 4b19db8454 chore: drop python 3.7 for cibuildwheel driver
This drops python 3.7 for cibuildwheel.
Building python 3.6 / 3.7 packages is still supported.
2023-07-01 14:33:24 +02:00

36 lines
1.1 KiB
Python

"""
These are utilities for the `/bin` scripts, not for the `cibuildwheel` program.
"""
from __future__ import annotations
from collections.abc import Mapping, Sequence
from io import StringIO
from typing import Protocol
__all__ = ("Printable", "dump_python_configurations")
class Printable(Protocol):
def __str__(self) -> str:
...
def dump_python_configurations(
inp: Mapping[str, Mapping[str, Sequence[Mapping[str, Printable]]]]
) -> str:
output = StringIO()
for header, values in inp.items():
output.write(f"[{header}]\n")
for inner_header, listing in values.items():
output.write(f"{inner_header} = [\n")
for item in listing:
output.write(" { ")
dict_contents = (f'{key} = "{value}"' for key, value in item.items())
output.write(", ".join(dict_contents))
output.write(" },\n")
output.write("]\n")
output.write("\n")
# Strip the final newline, to avoid two blank lines at the end.
return output.getvalue()[:-1]