Skip to content

Commit 5ccd5b7

Browse files
authored
chore(template): accept new copier update (#52)
2 parents 36f4a23 + 025e401 commit 5ccd5b7

8 files changed

Lines changed: 60 additions & 27 deletions

File tree

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
2-
_commit: v0.10.0-1-g4d30a6c
2+
_commit: v0.11.0-2-ga4e3723
33
_src_path: https://github.com/usnistgov/cookiecutter-nist-python.git
44
command_line_interface: typer
55
conda_channel: conda-forge

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ jobs:
150150
persist-credentials: false
151151

152152
- name: Pin actions
153-
uses: suzuki-shunsuke/pinact-action@1081f5ad49ac904b7d977784f338145150a32112 # v1.4.0
153+
uses: suzuki-shunsuke/pinact-action@cf51507d80d4d6522a07348e3d58790290eaf0b6 # v2.0.0
154154
with:
155155
skip_push: "true"
156156

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ repos:
6666
files: ^pyproject\.toml$
6767
# ** validate (schema-store)
6868
- repo: https://github.com/henryiii/validate-pyproject-schema-store
69-
rev: 2026.03.27
69+
rev: 2026.03.29
7070
hooks:
7171
- id: validate-pyproject
7272
name: validate-pyproject-schema-store
@@ -99,7 +99,7 @@ repos:
9999

100100
# Just
101101
- repo: https://github.com/wpk-nist-gov/just-pre-commit
102-
rev: v1.48.0
102+
rev: v1.48.1
103103
hooks:
104104
- id: justfile-format
105105

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Ready to contribute? Here's how to make a contribution.
6161
```
6262

6363
If the repo includes submodules, you can add them either with the initial
64-
close using:
64+
clone using:
6565

6666
```bash
6767
git clone --recursive-submodules git@github.com:your_name_here/pyproject2conda.git

docs/conf.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import os
2424
import sys
25+
from importlib.util import find_spec
2526
from pathlib import Path
2627
from typing import Any
2728

@@ -465,11 +466,6 @@ def linkcode_resolve(domain: str, info: dict[str, Any]) -> str | None:
465466

466467

467468
# only set spelling stuff if installed:
468-
try:
469-
import sphinxcontrib.spelling # noqa: F401
470-
469+
if find_spec("sphinxcontrib.spelling") is not None:
471470
extensions += ["sphinxcontrib.spelling"]
472471
spelling_word_list_filename = "spelling_wordlist.txt"
473-
474-
except ImportError:
475-
pass

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ lint-manual *commands: (pre-commit "run --all-files --hook-stage=manual" command
7474

7575
alias lint-all := lint-manual
7676

77-
# run prettier/markdownlint/pypoject-fmt
77+
# run prettier/markdownlint/pyproject-fmt
7878
[group("lint")]
7979
prettier: (lint "pyproject-fmt") (lint-manual "markdownlint")
8080

@@ -220,7 +220,7 @@ typecheck-all *checkers="mypy basedpyright": (nox "-s typecheck -- +m" checkers)
220220

221221
# * docs -----------------------------------------------------------------------
222222

223-
# build docs. Optioons {html, spelling, livehtml, linkcheck, open}.
223+
# build docs. Options {html, spelling, livehtml, linkcheck, open}.
224224
[group("docs")]
225225
[group("nox")]
226226
docs *options="html": (nox "-s docs -- +d" options)

tools/noxtools.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Utilities to wonferrk with nox"""
1+
"""Utilities to work with nox"""
22

33
from __future__ import annotations
44

@@ -17,8 +17,6 @@
1717

1818
from nox import Session
1919

20-
PathLike = str | Path
21-
2220

2321
# * Top level installation functions ---------------------------------------------------
2422
def py_prefix(python_version: Any) -> str:

tools/requirements_lock.py

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import logging
66
import shlex
7+
import shutil
78
import sys
89
from argparse import ArgumentParser
910
from pathlib import Path
@@ -99,6 +100,32 @@ def _lock_files(
99100
_ = check_call(options)
100101

101102

103+
# NOTE(wpk): This will not be needed once https://github.com/astral-sh/uv/issues/18155 is closed
104+
def _maybe_copy_lockfile(lock_path: Path) -> Path | None:
105+
if not lock_path.exists():
106+
return None
107+
108+
# copy lockfile to temp location
109+
import tempfile
110+
111+
with tempfile.TemporaryDirectory(delete=False) as tmp_dir:
112+
new_path = Path(tmp_dir) / lock_path.name
113+
logger.info("backing up current uv.lock to %s", new_path)
114+
shutil.copy2(lock_path, new_path)
115+
return new_path
116+
117+
118+
def _only_changed_exclude_newer_time(old_path: Path, new_path: Path) -> bool:
119+
import tomllib
120+
121+
old_data, new_data = (
122+
tomllib.loads(path.read_text(encoding="utf-8")) for path in (old_path, new_path)
123+
)
124+
old_data["options"]["exclude-newer"] = "0"
125+
new_data["options"]["exclude-newer"] = "0"
126+
return old_data == new_data
127+
128+
102129
def _maybe_lock_or_sync(
103130
lock: bool,
104131
sync: bool,
@@ -112,17 +139,29 @@ def _maybe_lock_or_sync(
112139
else:
113140
lock = True
114141

115-
if lock or sync:
116-
command = [
117-
"uv",
118-
("sync" if sync else "lock"),
119-
*(["--no-active"] if sync else []),
120-
*(["--upgrade"] if upgrade else []),
121-
*uv_options,
122-
]
123-
124-
logger.info(shlex.join(command))
125-
_ = check_call(command)
142+
if not (lock or sync):
143+
return
144+
145+
lock_path = Path("uv.lock")
146+
old_lock_path = _maybe_copy_lockfile(lock_path) if upgrade else None
147+
148+
# update lock_path
149+
command = [
150+
"uv",
151+
("sync" if sync else "lock"),
152+
*(["--no-active"] if sync else []),
153+
*(["--upgrade"] if upgrade else []),
154+
*uv_options,
155+
]
156+
157+
logger.info(shlex.join(command))
158+
_ = check_call(command)
159+
160+
if old_lock_path is not None and _only_changed_exclude_newer_time(
161+
old_lock_path, lock_path
162+
):
163+
logger.info("only exclude-newer timestamp changed. Keeping old file")
164+
shutil.move(old_lock_path, lock_path)
126165

127166

128167
def main(args: Sequence[str] | None = None) -> int:

0 commit comments

Comments
 (0)