Skip to content

Commit 2462bbb

Browse files
committed
Some updated from rerun_template
1 parent c85c09c commit 2462bbb

File tree

4 files changed

+81
-33
lines changed

4 files changed

+81
-33
lines changed

.github/workflows/cpp.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Copied from https://github.com/rerun-io/rerun_template
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
types: [ opened, synchronize ]
38

49
name: C++
510

@@ -10,7 +15,7 @@ jobs:
1015
steps:
1116
- uses: actions/checkout@v4
1217

13-
- uses: prefix-dev/[email protected].0
18+
- uses: prefix-dev/[email protected].1
1419
with:
1520
pixi-version: v0.26.1
1621
cache: true

.github/workflows/links.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Copied from https://github.com/rerun-io/rerun_template
2-
on: [push, pull_request]
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
types: [ opened, synchronize ]
38

49
name: Link checker
510

pixi.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ print-env = { cmd = "echo $PATH" }
3737
prepare = "cmake -G 'Ninja' -B build -S . -DCMAKE_BUILD_TYPE=RelWithDebInfo"
3838

3939
# Build C++ example
40-
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends_on = [
40+
build = { cmd = "cmake --build build --config RelWithDebInfo --target all", depends-on = [
4141
"prepare",
4242
] }
4343

4444
# Run C++ example
45-
example = { cmd = "build/rerun_vrs_example", depends_on = ["build"] }
45+
example = { cmd = "build/rerun_vrs_example", depends-on = ["build"] }
4646

4747
# Format C++ code
4848
cpp-fmt = { cmd = "clang-format -i src/*.[hc]pp" }
@@ -55,9 +55,14 @@ cpp-fmt-check = { cmd = "clang-format --dry-run --Werror -i src/*.[hc]pp" }
5555

5656
# Run first ruff fix, then ruff format, order is important see also https://twitter.com/charliermarsh/status/1717229721954799727
5757
py-fmt = "ruff check --fix --config pyproject.toml . && ruff format --config pyproject.toml ."
58-
py-fmt-check = "ruff format --check --config pyproject.toml"
58+
py-fmt-check = "ruff check --config pyproject.toml . && ruff format --check --config pyproject.toml"
5959
py-lint = "mypy --install-types --non-interactive --no-warn-unused-ignore"
6060

61+
# ------------------------------------------------------------------------------------------
62+
# General stuff:
63+
lint-typos = "typos"
64+
65+
6166
[dependencies]
6267
# C++ build-tools:
6368
boost = "1.84.0.*"
@@ -82,5 +87,8 @@ ruff = "0.3.7"
8287

8388
types-requests = ">=2.31,<3" # mypy type hint stubs for generate_changelog.py
8489

90+
# General stuff:
91+
typos = ">=1.16.20"
92+
8593
[target.linux-64.dependencies]
86-
sysroot_linux-64 = ">=2.17,<3" # rustc 1.78+ requires glibc 2.17+, see https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html
94+
sysroot_linux-64 = ">=2.17,<3" # rustc 1.64+ requires glibc 2.17+, see https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html

scripts/template_update.py

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,82 @@
1414
You can also use `--dry-run` to see what would happen without actually changing anything.
1515
"""
1616

17+
from __future__ import annotations
18+
1719
import argparse
1820
import os
1921
import shutil
2022
import tempfile
21-
from typing import Set
2223

23-
from git import Repo
24+
from git import Repo # pip install GitPython
2425

2526
OWNER = "rerun-io"
2627

27-
# Files requires by C++, but not by both Python or Rust.
28+
# Don't overwrite these when updating existing repository from the template
29+
DO_NOT_OVERWRITE = {
30+
"Cargo.lock",
31+
"CHANGELOG.md",
32+
"main.py",
33+
"pixi.lock",
34+
"README.md",
35+
"requirements.txt",
36+
}
37+
38+
# Files required by C++, but not by _both_ Python and Rust
2839
CPP_FILES = {
2940
".clang-format",
3041
".github/workflows/cpp.yml",
3142
"CMakeLists.txt",
32-
"pixi.lock", # Not needed by Rust
33-
"pixi.toml", # Not needed by Rust
34-
"src/main.cpp",
43+
"pixi.lock", # Pixi is only C++ & Python - For Rust we only use cargo
44+
"pixi.toml", # Pixi is only C++ & Python - For Rust we only use cargo
3545
"src/",
46+
"src/main.cpp",
3647
}
3748

38-
# Files requires by Python, but not by both C++ or Rust
49+
# Files required by Python, but not by _both_ C++ and Rust
3950
PYTHON_FILES = {
4051
".github/workflows/python.yml",
4152
".mypy.ini",
42-
"pixi.lock", # Not needed by Rust
43-
"pixi.toml", # Not needed by Rust
53+
"main.py",
54+
"pixi.lock", # Pixi is only C++ & Python - For Rust we only use cargo
55+
"pixi.toml", # Pixi is only C++ & Python - For Rust we only use cargo
4456
"pyproject.toml",
57+
"requirements.txt",
4558
}
4659

47-
# Files requires by Rust, but not by both C++ or Python
60+
# Files required by Rust, but not by _both_ C++ and Python
4861
RUST_FILES = {
62+
".github/workflows/cargo_shear.yml",
4963
".github/workflows/rust.yml",
5064
"bacon.toml",
5165
"Cargo.lock",
5266
"Cargo.toml",
67+
"CHANGELOG.md", # We only keep a changelog for Rust crates at the moment
5368
"clippy.toml",
5469
"Cranky.toml",
5570
"deny.toml",
71+
"RELEASES.md",
5672
"rust-toolchain",
5773
"scripts/clippy_wasm/",
5874
"scripts/clippy_wasm/clippy.toml",
75+
"scripts/generate_changelog.py", # We only keep a changelog for Rust crates at the moment
76+
"src/",
5977
"src/lib.rs",
6078
"src/main.rs",
61-
"src/",
6279
}
6380

81+
# Files we used to have, but have been removed in never version of rerun_template
82+
DEAD_FILES = ["bacon.toml", "Cranky.toml"]
83+
6484

65-
def parse_languages(lang_str: str) -> Set[str]:
85+
def parse_languages(lang_str: str) -> set[str]:
6686
languages = lang_str.split(",") if lang_str else []
6787
for lang in languages:
6888
assert lang in ["cpp", "python", "rust"], f"Unsupported language: {lang}"
6989
return set(languages)
7090

7191

72-
def calc_deny_set(languages: Set[str]) -> Set[str]:
92+
def calc_deny_set(languages: set[str]) -> set[str]:
7393
"""The set of files to delete/ignore."""
7494
files_to_delete = CPP_FILES | PYTHON_FILES | RUST_FILES
7595
if "cpp" in languages:
@@ -81,29 +101,41 @@ def calc_deny_set(languages: Set[str]) -> Set[str]:
81101
return files_to_delete
82102

83103

84-
def init(languages: Set[str], dry_run: bool) -> None:
104+
def init(languages: set[str], dry_run: bool) -> None:
85105
print("Removing all language-specific files not needed for languages {languages}.")
86106
files_to_delete = calc_deny_set(languages)
87107
delete_files_and_folder(files_to_delete, dry_run)
88108

89109

90-
def delete_files_and_folder(paths: Set[str], dry_run: bool) -> None:
110+
def remove_file(filepath: str) -> None:
111+
try:
112+
os.remove(filepath)
113+
except FileNotFoundError:
114+
pass
115+
116+
117+
def delete_files_and_folder(paths: set[str], dry_run: bool) -> None:
91118
repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
92119
for path in paths:
93120
full_path = os.path.join(repo_path, path)
94121
if os.path.exists(full_path):
95122
if os.path.isfile(full_path):
96123
print(f"Removing file {full_path}…")
97124
if not dry_run:
98-
os.remove(full_path)
125+
remove_file(full_path)
99126
elif os.path.isdir(full_path):
100127
print(f"Removing folder {full_path}…")
101128
if not dry_run:
102129
shutil.rmtree(full_path)
103130

104131

105-
def update(languages: Set[str], dry_run: bool) -> None:
106-
files_to_ignore = calc_deny_set(languages)
132+
def update(languages: set[str], dry_run: bool) -> None:
133+
for file in DEAD_FILES:
134+
print(f"Removing dead file {file}…")
135+
if not dry_run:
136+
remove_file(file)
137+
138+
files_to_ignore = calc_deny_set(languages) | DO_NOT_OVERWRITE
107139
repo_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
108140

109141
with tempfile.TemporaryDirectory() as temp_dir:
@@ -117,17 +149,15 @@ def update(languages: Set[str], dry_run: bool) -> None:
117149
continue
118150
if rel_path.startswith("src/"):
119151
continue
120-
121-
if rel_path in {"README.md", "pixi.lock", "Cargo.lock"}:
152+
if rel_path in files_to_ignore:
122153
continue
123154

124-
if rel_path not in files_to_ignore:
125-
dest_path = os.path.join(repo_path, rel_path)
155+
dest_path = os.path.join(repo_path, rel_path)
126156

127-
print(f"Updating {rel_path}…")
128-
if not dry_run:
129-
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
130-
shutil.copy2(src_path, dest_path)
157+
print(f"Updating {rel_path}…")
158+
if not dry_run:
159+
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
160+
shutil.copy2(src_path, dest_path)
131161

132162

133163
def main() -> None:

0 commit comments

Comments
 (0)