File: paths.py

package info (click to toggle)
duckdb 1.5.1-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 299,196 kB
  • sloc: cpp: 865,414; ansic: 57,292; python: 18,871; sql: 12,663; lisp: 11,751; yacc: 7,412; lex: 1,682; sh: 747; makefile: 558
file content (44 lines) | stat: -rw-r--r-- 1,452 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import subprocess
from pathlib import Path

# Repository root inferred relative to this file
REPO_ROOT = Path(__file__).resolve().parents[2]

# Top-level source directories
SRC_DIR = REPO_ROOT / "src"
INCLUDE_ROOT = SRC_DIR / "include" / "duckdb"

# Subdirectories we target
COMMON_ENUMS_DIR = SRC_DIR / "common" / "enums"
INCLUDE_ENUMS_DIR = INCLUDE_ROOT / "common" / "enums"
INCLUDE_MAIN_DIR = INCLUDE_ROOT / "main"
SRC_MAIN_DIR = SRC_DIR / "main"

# Tests output directory
TEST_PROFILING_DIR = REPO_ROOT / "test" / "sql" / "pragma" / "profiling"

# Inputs
METRICS_JSON = COMMON_ENUMS_DIR / "metric_type.json"
OPTIMIZER_HPP = INCLUDE_ENUMS_DIR / "optimizer_type.hpp"
PROFILING_HPP_TEMPLATE = INCLUDE_MAIN_DIR / "profiling_utils.hpp.template"
PROFILING_CPP_TEMPLATE = SRC_MAIN_DIR / "profiling_utils.cpp.template"

# Outputs
OUT_METRIC_HPP = INCLUDE_ENUMS_DIR / "metric_type.hpp"
OUT_METRIC_CPP = COMMON_ENUMS_DIR / "metric_type.cpp"
OUT_PROFILING_HPP = INCLUDE_MAIN_DIR / "profiling_utils.hpp"
OUT_PROFILING_CPP = SRC_MAIN_DIR / "profiling_utils.cpp"

# Format script
FORMAT_SCRIPT = REPO_ROOT / "scripts" / "format.py"


def path_from_duckdb(path: Path):
    return path.relative_to(REPO_ROOT)


def format_file(path: Path):
    print("    └─ Formatting...", end='', flush=True)
    subprocess.run(["python3", FORMAT_SCRIPT, OUT_METRIC_HPP, "--fix", "--noconfirm"], stdout=subprocess.DEVNULL)
    print("\r    └─ Formatted ✓  ")