Skip to content

Commit 6969777

Browse files
committed
Update package with latest from template
The `scripts/` folder in particular was left behind when creating the cookiecutter template from cookiecutter-robust-python
1 parent 7cc56f2 commit 6969777

File tree

10 files changed

+525
-16
lines changed

10 files changed

+525
-16
lines changed

.cruft.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"template": "https://github.com/56kyle/cookiecutter-robust-python.git",
3+
"commit": "bf289288fe0cacd836ebd606dbb657193c34340f",
4+
"checkout": null,
5+
"context": {
6+
"cookiecutter": {
7+
"project_name": "maison",
8+
"package_name": "maison",
9+
"friendly_name": "Maison",
10+
"min_python_version": "3.9",
11+
"max_python_version": "3.13",
12+
"add_rust_extension": false,
13+
"author": "Dom Batten",
14+
"email": "[email protected]",
15+
"repository_provider": "github",
16+
"repository_host": "github.com",
17+
"repository_path": "dbatten/maison",
18+
"version": "2.0.1",
19+
"copyright_year": "2025",
20+
"license": "MIT",
21+
"development_status": "Development Status :: 5 - Production/Stable",
22+
"_template": "https://github.com/56kyle/cookiecutter-robust-python.git",
23+
"_commit": "bf289288fe0cacd836ebd606dbb657193c34340f"
24+
}
25+
},
26+
"directory": null
27+
}

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def docs_build(session: Session) -> None:
176176

177177
@nox.session(python=DEFAULT_PYTHON_VERSION, name="docs", tags=[DOCS, BUILD])
178178
def docs(session: Session) -> None:
179-
"""Build the project documentation (Sphinx)."""
179+
"""Build and serve the project documentation (Sphinx)."""
180180
session.log("Installing documentation dependencies...")
181181
session.install("-e", ".", "--group", "docs")
182182

scripts/bump-version.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Script responsible for bumping the version of the maison package."""
2+
3+
import argparse
4+
5+
from util import bump_version
6+
7+
8+
def main() -> None:
9+
"""Parses args and passes through to bump_version."""
10+
parser: argparse.ArgumentParser = get_parser()
11+
args: argparse.Namespace = parser.parse_args()
12+
bump_version(increment=args.increment)
13+
14+
15+
def get_parser() -> argparse.ArgumentParser:
16+
"""Creates the argument parser for prepare-release."""
17+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
18+
prog="bump-version", usage="python ./scripts/bump-version.py patch"
19+
)
20+
parser.add_argument(
21+
"increment",
22+
type=str,
23+
help="Increment type to use when preparing the release.",
24+
choices=["MAJOR", "MINOR", "PATCH", "PRERELEASE"],
25+
)
26+
return parser
27+
28+
29+
if __name__ == "__main__":
30+
main()

scripts/get-release-notes.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
"""Script responsible for getting the release notes of the maison package."""
2+
3+
import argparse
4+
from pathlib import Path
5+
6+
from util import get_latest_release_notes
7+
8+
9+
RELEASE_NOTES_PATH: Path = Path("body.md")
10+
11+
12+
def main() -> None:
13+
"""Parses args and passes through to bump_version."""
14+
parser: argparse.ArgumentParser = get_parser()
15+
args: argparse.Namespace = parser.parse_args()
16+
release_notes: str = get_latest_release_notes()
17+
path: Path = RELEASE_NOTES_PATH if args.path is None else args.path
18+
path.write_text(release_notes)
19+
20+
21+
def get_parser() -> argparse.ArgumentParser:
22+
"""Creates the argument parser for prepare-release."""
23+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
24+
prog="get-release-notes", usage="python ./scripts/get-release-notes.py"
25+
)
26+
parser.add_argument(
27+
"path",
28+
type=Path,
29+
metavar="PATH",
30+
help="Path the changelog will be written to.",
31+
)
32+
return parser
33+
34+
35+
if __name__ == "__main__":
36+
main()

scripts/setup-git.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Script responsible for first time setup of the project's git repo.
2+
3+
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
4+
"""
5+
6+
import argparse
7+
import subprocess
8+
from pathlib import Path
9+
10+
from util import check_dependencies
11+
from util import existing_dir
12+
13+
14+
def main() -> None:
15+
"""Parses command line input and passes it through to setup_git."""
16+
parser: argparse.ArgumentParser = get_parser()
17+
args: argparse.Namespace = parser.parse_args()
18+
setup_git(path=args.path)
19+
20+
21+
def setup_git(path: Path) -> None:
22+
"""Set up the provided cookiecutter-robust-python project's git repo."""
23+
commands: list[list[str]] = [
24+
["git", "init"],
25+
["git", "branch", "-m", "master", "main"],
26+
["git", "add", "."],
27+
["git", "commit", "-m", "feat: initial commit"],
28+
["git", "checkout", "-b", "develop", "main"],
29+
]
30+
check_dependencies(path=path, dependencies=["git"])
31+
32+
for command in commands:
33+
subprocess.run(command, cwd=path, stderr=subprocess.STDOUT)
34+
35+
36+
def get_parser() -> argparse.ArgumentParser:
37+
"""Creates the argument parser for setup-git."""
38+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
39+
prog="setup-git",
40+
usage="python ./scripts/setup-git.py . -u 56kyle -n robust-python-demo",
41+
description="Set up the provided cookiecutter-robust-python project's git repo.",
42+
)
43+
parser.add_argument(
44+
"path",
45+
type=existing_dir,
46+
metavar="PATH",
47+
help="Path to the repo's root directory (must already exist).",
48+
)
49+
return parser
50+
51+
52+
if __name__ == "__main__":
53+
main()

scripts/setup-release.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
"""Script responsible for preparing a release of the maison package."""
2+
3+
import argparse
4+
import subprocess
5+
from typing import Optional
6+
7+
from util import REPO_FOLDER
8+
from util import bump_version
9+
from util import check_dependencies
10+
from util import create_release_branch
11+
from util import get_bumped_package_version
12+
from util import get_package_version
13+
14+
15+
def main() -> None:
16+
"""Parses args and passes through to setup_release."""
17+
parser: argparse.ArgumentParser = get_parser()
18+
args: argparse.Namespace = parser.parse_args()
19+
setup_release(increment=args.increment)
20+
21+
22+
def get_parser() -> argparse.ArgumentParser:
23+
"""Creates the argument parser for prepare-release."""
24+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
25+
prog="prepare-release", usage="python ./scripts/prepare-release.py patch"
26+
)
27+
parser.add_argument(
28+
"increment",
29+
nargs="?",
30+
default=None,
31+
type=str,
32+
help="Increment type to use when preparing the release.",
33+
choices=["MAJOR", "MINOR", "PATCH", "PRERELEASE"],
34+
)
35+
return parser
36+
37+
38+
def setup_release(increment: Optional[str] = None) -> None:
39+
"""Prepares a release of the maison package.
40+
41+
Sets up a release branch from the branch develop, bumps the version, and creates a release commit. Does not tag the
42+
release or push any changes.
43+
"""
44+
check_dependencies(path=REPO_FOLDER, dependencies=["git"])
45+
46+
current_version: str = get_package_version()
47+
new_version: str = get_bumped_package_version(increment=increment)
48+
create_release_branch(new_version=new_version)
49+
bump_version(increment=increment)
50+
51+
commands: list[list[str]] = [
52+
["uv", "sync", "--all-groups"],
53+
["git", "add", "."],
54+
[
55+
"git",
56+
"commit",
57+
"-m",
58+
f"bump: version {current_version}{new_version}",
59+
"--no-verify",
60+
],
61+
]
62+
63+
for command in commands:
64+
subprocess.run(command, cwd=REPO_FOLDER, capture_output=True, check=True)
65+
66+
67+
if __name__ == "__main__":
68+
main()

scripts/setup-remote.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
"""Script responsible for first time setup of the project's git repo's remote connection.
2+
3+
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
4+
"""
5+
6+
import argparse
7+
import subprocess
8+
from pathlib import Path
9+
10+
from util import check_dependencies
11+
from util import existing_dir
12+
13+
14+
def main() -> None:
15+
"""Parses command line input and passes it through to setup_git."""
16+
parser: argparse.ArgumentParser = get_parser()
17+
args: argparse.Namespace = parser.parse_args()
18+
setup_remote(
19+
path=args.path,
20+
repository_host=args.repository_host,
21+
repository_path=args.repository_path,
22+
)
23+
24+
25+
def setup_remote(path: Path, repository_host: str, repository_path: str) -> None:
26+
"""Set up the provided cookiecutter-robust-python project's git repo."""
27+
commands: list[list[str]] = [
28+
[
29+
"git",
30+
"remote",
31+
"add",
32+
"origin",
33+
f"https://{repository_host}/{repository_path}.git",
34+
],
35+
[
36+
"git",
37+
"remote",
38+
"set-url",
39+
"origin",
40+
f"https://{repository_host}/{repository_path}.git",
41+
],
42+
["git", "fetch", "origin"],
43+
["git", "checkout", "main"],
44+
["git", "push", "-u", "origin", "main"],
45+
["git", "checkout", "develop"],
46+
["git", "push", "-u", "origin", "develop"],
47+
]
48+
check_dependencies(path=path, dependencies=["git"])
49+
50+
for command in commands:
51+
subprocess.run(command, cwd=path, stderr=subprocess.STDOUT)
52+
53+
54+
def get_parser() -> argparse.ArgumentParser:
55+
"""Creates the argument parser for setup-remote."""
56+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
57+
prog="setup-remote",
58+
usage="python ./scripts/setup-remote.py . --host github.com --path 56kyle/robust-python-demo",
59+
description="Set up the provided cookiecutter-robust-python project's remote repo connection.",
60+
)
61+
parser.add_argument(
62+
"path",
63+
type=existing_dir,
64+
metavar="PATH",
65+
help="Path to the repo's root directory (must already exist).",
66+
)
67+
parser.add_argument(
68+
"--host",
69+
dest="repository_host",
70+
help="Repository host (e.g., github.com, gitlab.com).",
71+
)
72+
parser.add_argument(
73+
"--path",
74+
dest="repository_path",
75+
help="Repository path (e.g., user/repo, group/subgroup/repo).",
76+
)
77+
return parser
78+
79+
80+
if __name__ == "__main__":
81+
main()

scripts/setup-venv.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Script responsible for first time setup of the project's venv.
2+
3+
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
4+
"""
5+
6+
import argparse
7+
import shutil
8+
import subprocess
9+
from pathlib import Path
10+
11+
from util import check_dependencies
12+
from util import existing_dir
13+
from util import remove_readonly
14+
15+
16+
def main() -> None:
17+
"""Parses args and passes through to setup_venv."""
18+
parser: argparse.ArgumentParser = get_parser()
19+
args: argparse.Namespace = parser.parse_args()
20+
setup_venv(path=args.path, python_version=args.python_version)
21+
22+
23+
def get_parser() -> argparse.ArgumentParser:
24+
"""Creates the argument parser for setup-venv."""
25+
parser: argparse.ArgumentParser = argparse.ArgumentParser(
26+
prog="setup-venv", usage="python ./scripts/setup-venv.py . -p '3.9'"
27+
)
28+
parser.add_argument(
29+
"path",
30+
type=existing_dir,
31+
metavar="PATH",
32+
help="Path to the repo's root directory (must already exist).",
33+
)
34+
parser.add_argument(
35+
"-p",
36+
"--python",
37+
dest="python_version",
38+
help="The Python version that will serve as the main working version used by the IDE.",
39+
)
40+
return parser
41+
42+
43+
def setup_venv(path: Path, python_version: str) -> None:
44+
"""Set up the provided cookiecutter-robust-python project's venv."""
45+
commands: list[list[str]] = [
46+
["uv", "lock"],
47+
["uv", "venv", ".venv"],
48+
["uv", "python", "install", python_version],
49+
["uv", "python", "pin", python_version],
50+
["uv", "sync", "--all-groups"],
51+
]
52+
check_dependencies(path=path, dependencies=["uv"])
53+
54+
venv_path: Path = path / ".venv"
55+
if venv_path.exists():
56+
shutil.rmtree(venv_path, onerror=remove_readonly)
57+
58+
for command in commands:
59+
subprocess.run(command, cwd=path, capture_output=True)
60+
61+
62+
if __name__ == "__main__":
63+
main()

0 commit comments

Comments
 (0)