2020-03-09 06:47:18 -04:00
|
|
|
#!/usr/bin/env python3
|
2019-06-25 13:39:19 -04:00
|
|
|
"""Script to add non-"latest" miniconda releases.
|
2020-03-09 06:47:18 -04:00
|
|
|
Written for python 3.7.
|
2019-06-25 13:39:19 -04:00
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
Checks the miniconda download archives for new versions,
|
|
|
|
then writes a build script for any which do not exist locally,
|
|
|
|
saving it to plugins/python-build/share/python-build.
|
2019-06-25 13:39:19 -04:00
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
Ignores releases below 4.3.30.
|
|
|
|
Also ignores sub-patch releases if that major.minor.patch already exists,
|
|
|
|
but otherwise, takes the latest sub-patch release for given OS/arch.
|
|
|
|
Assumes all miniconda3 releases < 4.7 default to python 3.6, and anything else 3.7.
|
2019-06-25 13:39:19 -04:00
|
|
|
"""
|
|
|
|
import textwrap
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
from collections import defaultdict
|
|
|
|
from enum import Enum
|
|
|
|
from functools import total_ordering
|
|
|
|
from pathlib import Path
|
|
|
|
from typing import NamedTuple, List, Optional, DefaultDict, Dict
|
2020-03-09 06:47:18 -04:00
|
|
|
import logging
|
2022-06-05 18:07:46 -04:00
|
|
|
import string
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
import requests_html
|
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
2019-06-25 13:39:19 -04:00
|
|
|
CONDA_REPO = "https://repo.anaconda.com"
|
|
|
|
MINICONDA_REPO = CONDA_REPO + "/miniconda"
|
2022-06-05 18:07:46 -04:00
|
|
|
ANACONDA_REPO = CONDA_REPO + "/archive"
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
install_script_fmt = """
|
|
|
|
case "$(anaconda_architecture 2>/dev/null || true)" in
|
|
|
|
{install_lines}
|
|
|
|
* )
|
|
|
|
{{ echo
|
|
|
|
colorize 1 "ERROR"
|
2022-06-05 18:07:46 -04:00
|
|
|
echo ": The binary distribution of {tflavor} is not available for $(anaconda_architecture 2>/dev/null || true)."
|
2019-06-25 13:39:19 -04:00
|
|
|
echo
|
|
|
|
}} >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
""".lstrip()
|
|
|
|
|
|
|
|
install_line_fmt = """
|
|
|
|
"{os}-{arch}" )
|
2022-06-05 18:07:46 -04:00
|
|
|
install_script "{tflavor}{suffix}-{version_py_version}{version_str}-{os}-{arch}" "{repo}/{tflavor}{suffix}-{version_py_version}{version_str}-{os}-{arch}.sh#{md5}" "{flavor}" verify_{py_version}
|
2019-06-25 13:39:19 -04:00
|
|
|
;;
|
|
|
|
""".strip()
|
|
|
|
|
|
|
|
here = Path(__file__).resolve()
|
|
|
|
out_dir: Path = here.parent.parent / "share" / "python-build"
|
|
|
|
|
|
|
|
|
|
|
|
class StrEnum(str, Enum):
|
2020-03-09 06:47:18 -04:00
|
|
|
"""Enum subclass whose members are also instances of str
|
2019-06-25 13:39:19 -04:00
|
|
|
and directly comparable to strings. str type is forced at declaration.
|
|
|
|
|
|
|
|
Adapted from https://github.com/kissgyorgy/enum34-custom/blob/dbc89596761c970398701d26c6a5bbcfcf70f548/enum_custom.py#L100
|
|
|
|
(MIT license)
|
|
|
|
"""
|
2019-11-01 07:46:41 -04:00
|
|
|
|
2019-06-25 13:39:19 -04:00
|
|
|
def __new__(cls, *args):
|
|
|
|
for arg in args:
|
|
|
|
if not isinstance(arg, str):
|
2019-11-01 07:46:41 -04:00
|
|
|
raise TypeError("Not text %s:" % arg)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
return super(StrEnum, cls).__new__(cls, *args)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return str(self.value)
|
|
|
|
|
|
|
|
|
|
|
|
class SupportedOS(StrEnum):
|
|
|
|
LINUX = "Linux"
|
|
|
|
MACOSX = "MacOSX"
|
|
|
|
|
|
|
|
|
|
|
|
class SupportedArch(StrEnum):
|
2022-05-17 15:59:11 -04:00
|
|
|
AARCH64 = "aarch64"
|
|
|
|
ARM64 = "arm64"
|
2019-06-25 13:39:19 -04:00
|
|
|
PPC64LE = "ppc64le"
|
2022-05-17 15:59:11 -04:00
|
|
|
S390X = "s390x"
|
2019-06-25 13:39:19 -04:00
|
|
|
X86_64 = "x86_64"
|
|
|
|
X86 = "x86"
|
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
class Flavor(StrEnum):
|
|
|
|
ANACONDA = "anaconda"
|
|
|
|
MINICONDA = "miniconda"
|
|
|
|
|
|
|
|
|
|
|
|
class TFlavor(StrEnum):
|
|
|
|
ANACONDA = "Anaconda"
|
|
|
|
MINICONDA = "Miniconda"
|
|
|
|
|
|
|
|
|
2019-06-25 13:39:19 -04:00
|
|
|
class Suffix(StrEnum):
|
|
|
|
TWO = "2"
|
|
|
|
THREE = "3"
|
2022-06-05 18:07:46 -04:00
|
|
|
NONE = ""
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
class PyVersion(StrEnum):
|
|
|
|
PY27 = "py27"
|
|
|
|
PY36 = "py36"
|
|
|
|
PY37 = "py37"
|
|
|
|
PY38 = "py38"
|
|
|
|
PY39 = "py39"
|
2023-01-03 20:18:26 -05:00
|
|
|
PY310 = "py310"
|
2023-07-11 17:35:35 -04:00
|
|
|
PY311 = "py311"
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
def version(self):
|
|
|
|
first, *others = self.value[2:]
|
|
|
|
return f"{first}.{''.join(others)}"
|
|
|
|
|
|
|
|
def version_info(self):
|
2019-11-01 07:46:41 -04:00
|
|
|
return tuple(int(n) for n in self.version().split("."))
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
@total_ordering
|
|
|
|
class VersionStr(str):
|
|
|
|
def info(self):
|
2023-01-03 20:29:19 -05:00
|
|
|
return tuple(int(n) for n in self.replace("-", ".").split("."))
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
def __eq__(self, other):
|
|
|
|
return str(self) == str(other)
|
|
|
|
|
|
|
|
def __lt__(self, other):
|
|
|
|
if isinstance(other, VersionStr):
|
|
|
|
return self.info() < other.info()
|
|
|
|
raise ValueError("VersionStr can only be compared to other VersionStr")
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_info(cls, version_info):
|
2019-11-01 07:46:41 -04:00
|
|
|
return VersionStr(".".join(str(n) for n in version_info))
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
def __hash__(self):
|
|
|
|
return hash(str(self))
|
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
class CondaVersion(NamedTuple):
|
|
|
|
flavor: Flavor
|
2019-06-25 13:39:19 -04:00
|
|
|
suffix: Suffix
|
|
|
|
version_str: VersionStr
|
2021-09-19 21:47:28 -04:00
|
|
|
py_version: Optional[PyVersion]
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_str(cls, s):
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
2022-06-05 18:07:46 -04:00
|
|
|
Convert a string of the form "miniconda_n-ver" or "miniconda_n-py_ver-ver" to a :class:`CondaVersion` object.
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
2023-06-23 20:10:18 -04:00
|
|
|
miniconda_n, _, remainder = s.partition("-")
|
2022-06-05 18:07:46 -04:00
|
|
|
suffix = miniconda_n[-1]
|
|
|
|
if suffix in string.digits:
|
|
|
|
flavor = miniconda_n[:-1]
|
|
|
|
else:
|
|
|
|
flavor = miniconda_n
|
|
|
|
suffix = ""
|
2023-06-23 20:10:18 -04:00
|
|
|
|
|
|
|
components = remainder.split("-")
|
|
|
|
if flavor == Flavor.MINICONDA and len(components) >= 2:
|
|
|
|
py_ver, *ver_parts = components
|
|
|
|
py_ver = PyVersion(f"py{py_ver.replace('.', '')}")
|
|
|
|
ver = "-".join(ver_parts)
|
|
|
|
else:
|
|
|
|
ver = "-".join(components)
|
|
|
|
py_ver = None
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
return CondaVersion(Flavor(flavor), Suffix(suffix), VersionStr(ver), py_ver)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
def to_filename(self):
|
2021-09-19 21:47:28 -04:00
|
|
|
if self.py_version:
|
2022-06-05 18:07:46 -04:00
|
|
|
return f"{self.flavor}{self.suffix}-{self.py_version.version()}-{self.version_str}"
|
2021-09-19 21:47:28 -04:00
|
|
|
else:
|
2022-06-05 18:07:46 -04:00
|
|
|
return f"{self.flavor}{self.suffix}-{self.version_str}"
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
def default_py_version(self):
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
|
|
|
:class:`PyVersion` of Python used with this Miniconda version
|
|
|
|
"""
|
2021-09-19 21:47:28 -04:00
|
|
|
if self.py_version:
|
|
|
|
return self.py_version
|
|
|
|
elif self.suffix == Suffix.TWO:
|
2019-06-25 13:39:19 -04:00
|
|
|
return PyVersion.PY27
|
2022-06-05 18:07:46 -04:00
|
|
|
|
|
|
|
v = self.version_str.info()
|
|
|
|
if self.flavor == "miniconda":
|
2019-06-25 13:39:19 -04:00
|
|
|
# https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-python.html
|
2022-06-05 18:07:46 -04:00
|
|
|
if v < (4, 7):
|
|
|
|
return PyVersion.PY36
|
|
|
|
else:
|
|
|
|
return PyVersion.PY37
|
|
|
|
if self.flavor == "anaconda":
|
|
|
|
# https://docs.anaconda.com/anaconda/reference/release-notes/
|
|
|
|
if v >= (2021,11):
|
|
|
|
return PyVersion.PY39
|
|
|
|
if v >= (2020,7):
|
|
|
|
return PyVersion.PY38
|
|
|
|
if v >= (2020,2):
|
|
|
|
return PyVersion.PY37
|
|
|
|
if v >= (5,3,0):
|
|
|
|
return PyVersion.PY37
|
2019-06-25 13:39:19 -04:00
|
|
|
return PyVersion.PY36
|
|
|
|
|
2023-01-15 05:37:11 -05:00
|
|
|
raise ValueError(self.flavor)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
class CondaSpec(NamedTuple):
|
|
|
|
tflavor: TFlavor
|
|
|
|
version: CondaVersion
|
2019-06-25 13:39:19 -04:00
|
|
|
os: SupportedOS
|
|
|
|
arch: SupportedArch
|
|
|
|
md5: str
|
2022-06-05 18:07:46 -04:00
|
|
|
repo: str
|
2019-06-25 13:39:19 -04:00
|
|
|
py_version: Optional[PyVersion] = None
|
|
|
|
|
|
|
|
@classmethod
|
2022-06-05 18:07:46 -04:00
|
|
|
def from_filestem(cls, stem, md5, repo, py_version=None):
|
2023-01-03 20:29:19 -05:00
|
|
|
# The `*vers` captures the new trailing `-1` in some file names (a build number?)
|
|
|
|
# so they can be processed properly.
|
|
|
|
miniconda_n, *vers, os, arch = stem.split("-")
|
|
|
|
ver = "-".join(vers)
|
2022-06-05 18:07:46 -04:00
|
|
|
suffix = miniconda_n[-1]
|
|
|
|
if suffix in string.digits:
|
|
|
|
tflavor = miniconda_n[:-1]
|
|
|
|
else:
|
|
|
|
tflavor = miniconda_n
|
|
|
|
suffix = ""
|
|
|
|
flavor = tflavor.lower()
|
|
|
|
|
2021-09-19 21:47:28 -04:00
|
|
|
if ver.startswith("py"):
|
|
|
|
py_ver, ver = ver.split("_", maxsplit=1)
|
|
|
|
py_ver = PyVersion(py_ver)
|
|
|
|
else:
|
|
|
|
py_ver = None
|
2022-06-05 18:07:46 -04:00
|
|
|
spec = CondaSpec(
|
|
|
|
TFlavor(tflavor),
|
|
|
|
CondaVersion(Flavor(flavor), Suffix(suffix), VersionStr(ver), py_ver),
|
2019-06-25 13:39:19 -04:00
|
|
|
SupportedOS(os),
|
|
|
|
SupportedArch(arch),
|
|
|
|
md5,
|
2022-06-05 18:07:46 -04:00
|
|
|
repo,
|
2019-06-25 13:39:19 -04:00
|
|
|
)
|
|
|
|
if py_version is None:
|
|
|
|
spec = spec.with_py_version(spec.version.default_py_version())
|
|
|
|
return spec
|
|
|
|
|
|
|
|
def to_install_lines(self):
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
|
|
|
Installation command for this version of Miniconda for use in a Pyenv installation script
|
|
|
|
"""
|
2019-06-25 13:39:19 -04:00
|
|
|
return install_line_fmt.format(
|
2022-06-05 18:07:46 -04:00
|
|
|
tflavor=self.tflavor,
|
|
|
|
flavor=self.version.flavor,
|
|
|
|
repo=self.repo,
|
2019-06-25 13:39:19 -04:00
|
|
|
suffix=self.version.suffix,
|
|
|
|
version_str=self.version.version_str,
|
2021-09-19 21:47:28 -04:00
|
|
|
version_py_version=f"{self.version.py_version}_" if self.version.py_version else "",
|
2019-06-25 13:39:19 -04:00
|
|
|
os=self.os,
|
|
|
|
arch=self.arch,
|
|
|
|
md5=self.md5,
|
|
|
|
py_version=self.py_version,
|
|
|
|
)
|
|
|
|
|
|
|
|
def with_py_version(self, py_version: PyVersion):
|
2022-06-05 18:07:46 -04:00
|
|
|
return CondaSpec(*self[:-1], py_version=py_version)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
def make_script(specs: List[CondaSpec]):
|
2019-06-25 13:39:19 -04:00
|
|
|
install_lines = [s.to_install_lines() for s in specs]
|
2022-06-05 18:07:46 -04:00
|
|
|
return install_script_fmt.format(
|
|
|
|
install_lines="\n".join(install_lines),
|
|
|
|
tflavor=specs[0].tflavor,
|
|
|
|
)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
def get_existing_condas(name):
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
|
|
|
Enumerate existing Miniconda installation scripts in share/python-build/ except rolling releases.
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
:returns: A generator of :class:`CondaVersion` objects.
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
2022-06-05 18:07:46 -04:00
|
|
|
logger.info("Getting known %(name)s versions",locals())
|
2019-06-25 13:39:19 -04:00
|
|
|
for p in out_dir.iterdir():
|
2022-06-05 18:07:46 -04:00
|
|
|
entry_name = p.name
|
|
|
|
if not p.is_file() or not entry_name.startswith(name):
|
2019-06-25 13:39:19 -04:00
|
|
|
continue
|
|
|
|
try:
|
2022-06-05 18:07:46 -04:00
|
|
|
v = CondaVersion.from_str(entry_name)
|
2019-06-25 13:39:19 -04:00
|
|
|
if v.version_str != "latest":
|
2022-06-05 18:07:46 -04:00
|
|
|
logger.debug("Found existing %(name)s version %(v)s", locals())
|
2019-06-25 13:39:19 -04:00
|
|
|
yield v
|
|
|
|
except ValueError:
|
2023-07-10 17:24:50 -04:00
|
|
|
logger.error("Unable to parse existing version %s", entry_name)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
def get_available_condas(name, repo):
|
2021-12-23 13:01:28 -05:00
|
|
|
"""
|
|
|
|
Fetch remote miniconda versions.
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
:returns: A generator of :class:`CondaSpec` objects for each release available for download
|
2021-12-23 13:01:28 -05:00
|
|
|
except rolling releases.
|
|
|
|
"""
|
2022-06-05 18:07:46 -04:00
|
|
|
logger.info("Fetching remote %(name)s versions",locals())
|
2019-06-25 13:39:19 -04:00
|
|
|
session = requests_html.HTMLSession()
|
2022-06-05 18:07:46 -04:00
|
|
|
response = session.get(repo)
|
2019-06-25 13:39:19 -04:00
|
|
|
page: requests_html.HTML = response.html
|
2019-11-01 07:46:41 -04:00
|
|
|
table = page.find("table", first=True)
|
2019-06-25 13:39:19 -04:00
|
|
|
rows = table.find("tr")[1:]
|
|
|
|
for row in rows:
|
2019-11-01 07:46:41 -04:00
|
|
|
f, size, date, md5 = row.find("td")
|
2019-06-25 13:39:19 -04:00
|
|
|
fname = f.text
|
|
|
|
md5 = md5.text
|
|
|
|
|
|
|
|
if not fname.endswith(".sh"):
|
|
|
|
continue
|
|
|
|
stem = fname[:-3]
|
|
|
|
|
|
|
|
try:
|
2022-06-05 18:07:46 -04:00
|
|
|
s = CondaSpec.from_filestem(stem, md5, repo)
|
2019-06-25 13:39:19 -04:00
|
|
|
if s.version.version_str != "latest":
|
2022-06-05 18:07:46 -04:00
|
|
|
logger.debug("Found remote %(name)s version %(s)s", locals())
|
2019-06-25 13:39:19 -04:00
|
|
|
yield s
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
def key_fn(spec: CondaSpec):
|
2019-06-25 13:39:19 -04:00
|
|
|
return (
|
2022-06-05 18:07:46 -04:00
|
|
|
spec.tflavor,
|
2019-06-25 13:39:19 -04:00
|
|
|
spec.version.version_str.info(),
|
|
|
|
spec.version.suffix.value,
|
|
|
|
spec.os.value,
|
|
|
|
spec.arch.value,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-03-09 06:47:18 -04:00
|
|
|
parser = ArgumentParser(description=__doc__)
|
|
|
|
parser.add_argument(
|
|
|
|
"-d", "--dry-run", action="store_true",
|
|
|
|
help="Do not write scripts, just report them to stdout",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
2021-09-17 23:27:41 -04:00
|
|
|
"-v", "--verbose", action="count", default=0,
|
2020-03-09 06:47:18 -04:00
|
|
|
help="Increase verbosity of logging",
|
|
|
|
)
|
2019-06-25 13:39:19 -04:00
|
|
|
parsed = parser.parse_args()
|
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
log_level = {
|
|
|
|
0: logging.WARNING,
|
|
|
|
1: logging.INFO,
|
|
|
|
2: logging.DEBUG,
|
|
|
|
}.get(parsed.verbose, logging.DEBUG)
|
|
|
|
logging.basicConfig(level=log_level)
|
|
|
|
if parsed.verbose < 3:
|
|
|
|
logging.getLogger("requests").setLevel(logging.WARNING)
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
existing_versions = set()
|
|
|
|
available_specs = set()
|
|
|
|
for name,repo in ("miniconda",MINICONDA_REPO),("anaconda",ANACONDA_REPO):
|
|
|
|
existing_versions |= set(get_existing_condas(name))
|
|
|
|
available_specs |= set(get_available_condas(name, repo))
|
2019-06-25 13:39:19 -04:00
|
|
|
|
|
|
|
# version triple to triple-ified spec to raw spec
|
2019-11-01 07:46:41 -04:00
|
|
|
to_add: DefaultDict[
|
2022-06-05 18:07:46 -04:00
|
|
|
CondaVersion, Dict[CondaSpec, CondaSpec]
|
2019-11-01 07:46:41 -04:00
|
|
|
] = defaultdict(dict)
|
2019-06-25 13:39:19 -04:00
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
logger.info("Checking for new versions")
|
2019-06-25 13:39:19 -04:00
|
|
|
for s in sorted(available_specs, key=key_fn):
|
2022-06-05 18:07:46 -04:00
|
|
|
key = s.version
|
|
|
|
vv = key.version_str.info()
|
|
|
|
|
|
|
|
reason = None
|
|
|
|
if key in existing_versions:
|
|
|
|
reason = "already exists"
|
|
|
|
elif key.version_str.info() <= (4, 3, 30):
|
|
|
|
reason = "too old"
|
2023-01-03 20:29:19 -05:00
|
|
|
elif len(key.version_str.info()) >= 4 and "-" not in key.version_str:
|
2022-06-05 18:07:46 -04:00
|
|
|
reason = "ignoring hotfix releases"
|
|
|
|
|
|
|
|
if reason:
|
|
|
|
logger.debug("Ignoring version %(s)s (%(reason)s)", locals())
|
2019-06-25 13:39:19 -04:00
|
|
|
continue
|
|
|
|
|
2022-06-05 18:07:46 -04:00
|
|
|
to_add[key][s] = s
|
2019-06-25 13:39:19 -04:00
|
|
|
|
2020-03-09 06:47:18 -04:00
|
|
|
logger.info("Writing %s scripts", len(to_add))
|
2019-06-25 13:39:19 -04:00
|
|
|
for ver, d in to_add.items():
|
|
|
|
specs = list(d.values())
|
|
|
|
fpath = out_dir / ver.to_filename()
|
|
|
|
script_str = make_script(specs)
|
2022-06-05 18:07:46 -04:00
|
|
|
logger.info("Writing script for %s", ver)
|
2019-06-25 13:39:19 -04:00
|
|
|
if parsed.dry_run:
|
2019-11-01 07:46:41 -04:00
|
|
|
print(f"Would write spec to {fpath}:\n" + textwrap.indent(script_str, " "))
|
2019-06-25 13:39:19 -04:00
|
|
|
else:
|
2019-11-01 07:46:41 -04:00
|
|
|
with open(fpath, "w") as f:
|
2019-06-25 13:39:19 -04:00
|
|
|
f.write(script_str)
|