|
1 | 1 | # This script should be invoked from the project root directory. |
2 | 2 | # |
3 | | -# Copies the nrepl_panel_addon.py file to dist adding the version |
| 3 | +# Copies the nrepl_panel_addon.py file to out/ adding the version |
4 | 4 | # number as retrieved from `poetry version`. |
| 5 | +import os |
5 | 6 | import re |
6 | 7 | import subprocess |
7 | 8 |
|
|
11 | 12 | result = subprocess.run(["poetry", "version"], capture_output=True, text=True) |
12 | 13 | _, version = result.stdout.split(" ") |
13 | 14 | major, minor, patch = version.split(".") |
14 | | -patch_int = int(re.match(r'^\d+', patch).group()) |
| 15 | +patch_int = int(re.match(r"^\d+", patch).group()) |
15 | 16 |
|
16 | | -dist_path = f'dist/nrepl_panel_addon_{version.strip().replace(".", "_")}.py' |
| 17 | +os.makedirs("out", exist_ok=True) |
| 18 | +out_path = f'out/nrepl_panel_addon_{version.strip().replace(".", "_")}.py' |
17 | 19 |
|
18 | | -with open(src_path, 'r') as src: |
19 | | - with open(dist_path, 'w', newline="\n") as dst: |
| 20 | +with open(src_path, "r") as src: |
| 21 | + with open(out_path, "w", newline="\n") as dst: |
20 | 22 | dst.write(f"# Autogenerated from {src_path}\n") |
21 | 23 | for line in src.readlines(): |
22 | 24 | if version_mark in line: |
23 | 25 | line = line.replace(version_mark, f"({major}, {minor}, {patch_int})") |
24 | 26 | dst.write(line) |
25 | | -print(f":bb_addon_create.py :created {dist_path}") |
| 27 | +print(f":bb_addon_create.py :created {out_path}") |
0 commit comments