Skip to content

Commit

Permalink
try this
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Mar 12, 2024
1 parent 0f2d247 commit 0cf71ca
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions .tools/boilercv_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ def sync():

PLATFORM = platform(terse=True).casefold().split("-")[0]

print(f"welp {PLATFORM}") # noqa: T201

match PLATFORM:
case "macos":
RUNNER = "macos-12"
Expand Down Expand Up @@ -68,8 +66,9 @@ def sync():

DEV = Path(".tools/requirements/dev.in")
NODEPS = Path(".tools/requirements/nodeps.in")
LOCK = Path(".lock")
LOCK.mkdir(exist_ok=True, parents=True)
LOCKFILE = Path(".lock") / (
"_".join(["requirements", RUNNER, PYTHON_VERSION.replace(".", "")]) + ".txt"
)


@app.command()
Expand Down Expand Up @@ -97,15 +96,7 @@ def lock(highest: bool = False):
)
if lock_result.returncode:
raise RuntimeError(lock_result.stderr)
path = LOCK / Path(
"_".join([
"requirements",
RUNNER,
PYTHON_VERSION.replace(".", ""),
*([] if highest else ["dev"]),
])
).with_suffix(".txt")
path.write_text(
get_lockfile(highest).write_text(
encoding="utf-8",
data="\n".join([
r.strip() for r in [lock_result.stdout, NODEPS.read_text(encoding="utf-8")]
Expand All @@ -114,28 +105,38 @@ def lock(highest: bool = False):
)


LOCKFILE = Path(".tools/lock.json")
LOCKS = Path(".tools/locks.json")


@app.command()
def combine_locks():
LOCKFILE.write_text(
LOCKS.write_text(
encoding="utf-8",
data=json.dumps({
lock.stem: lock.read_text(encoding="utf-8") for lock in LOCK.iterdir()
})
data=json.dumps(
indent=2,
obj={
lockfile.stem: lockfile.read_text(encoding="utf-8")
for lockfile in LOCKS.iterdir()
},
)
+ "\n",
)


@app.command()
def get_lock():
name = "_".join(["requirements", RUNNER, PYTHON_VERSION.replace(".", ""), "dev"])
(LOCK / Path(name).with_suffix(".txt")).write_text(
encoding="utf-8", data=json.loads(LOCKFILE.read_text("utf-8"))[name]
LOCKS.parent.mkdir(exist_ok=True, parents=True)
lockfile = get_lockfile()
lockfile.write_text(
encoding="utf-8", data=json.loads(LOCKS.read_text("utf-8"))[lockfile.stem]
)


def get_lockfile(highest: bool = False):
LOCKFILE.parent.mkdir(exist_ok=True, parents=True)
return LOCKFILE.with_stem(f"{LOCKFILE.stem}_dev" if highest else LOCKFILE.stem)


@dataclass
class Submodule:
"""Represents a git submodule."""
Expand Down
File renamed without changes.

0 comments on commit 0cf71ca

Please sign in to comment.