File tree Expand file tree Collapse file tree 8 files changed +81
-4
lines changed
Expand file tree Collapse file tree 8 files changed +81
-4
lines changed Original file line number Diff line number Diff line change 77 - " -l DEBUG"
88 - " -g dev"
99 repo : https://github.com/phi-friday/sync-uv-pre-commit
10- rev : v0.6.3
10+ rev : v0.6.4
1111
1212 - hooks :
1313 - id : ruff
Original file line number Diff line number Diff line change 11- id : sync-uv-pre-commit
22 name : Sync uv and pre commit
33 description : Sync uv and pre commit
4- language : python
5- entry : " sync_uv_pre_commit "
4+ language : script
5+ entry : " uv run script.py "
66 minimum_pre_commit_version : " 3.5.0"
77 require_serial : true
88 always_run : true
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ classifiers = [
1212 " Programming Language :: Python :: 3.12" ,
1313 " Programming Language :: Python :: Implementation :: CPython" ,
1414]
15- scripts = { sync_uv_pre_commit = " sync_uv_pre_commit.cli:main " }
15+ scripts = { generate_cli_script = " sync_uv_pre_commit.render:generate_script " }
1616dependencies = [
1717 " packaging" ,
1818 " pre-commit>=3.5.0" ,
@@ -23,6 +23,7 @@ dependencies = [
2323dev = [
2424 " ruff==0.8.4" ,
2525 " poethepoet>=0.27.0" ,
26+ " jinja2>=3.1.5" ,
2627]
2728
2829[tool .uv ]
Original file line number Diff line number Diff line change 1+ # /// script
2+ # requires-python = ">=3.13"
3+ # dependencies = [
4+ # "packaging",
5+ # "pre-commit>=3.5.0",
6+ # "tomlkit>=0.13.2",
7+ # "typing-extensions>=4.12.2",
8+ # ]
9+ # ///
10+
11+ from __future__ import annotations
12+
13+ import sys
14+ from pathlib import Path
15+
16+ WORKSPACE = Path (__file__ ).parent
17+ sys .path .append (str (WORKSPACE / "src" ))
18+
19+
20+ if __name__ == "__main__" :
21+ from sync_uv_pre_commit .cli import main
22+
23+ main ()
Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ def check_uv_version() -> None:
227227 sys .exit (ExitCode .PARSING )
228228 sys .exit (ExitCode .UNKNOWN )
229229
230+ logger .info ("python version: %s" , sys .version_info )
230231 version = process .stdout .strip ().split ()[1 ]
231232 logger .info ("uv version: %s" , version )
232233
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ import sys
4+ from pathlib import Path
5+
6+ WORKSPACE = Path (__file__ ).parent
7+ sys .path .append (str (WORKSPACE / "src" ))
8+
9+
10+ if __name__ == "__main__" :
11+ from sync_uv_pre_commit .cli import main
12+
13+ main ()
Original file line number Diff line number Diff line change 1+ # /// script
2+ # requires-python = "{{ requires_python }}"
3+ # dependencies = [
4+ {% for dependency in dependencies -%}
5+ # "{{ dependency }}",
6+ {% endfor -%}
7+ # ]
8+ # ///
9+
10+ {{ export_script }}
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from pathlib import Path
4+
5+ import jinja2
6+
7+ from sync_uv_pre_commit .toml import read_pyproject
8+
9+
10+ def generate_script () -> None :
11+ """Generate the script.py file."""
12+ pyproject_file = Path (__file__ ).parent .parent .parent / "pyproject.toml"
13+ export_template_file = Path (__file__ ).parent / "export.py.j2"
14+ export_script_file = Path (__file__ ).parent / "export.py"
15+ output = Path (__file__ ).parent .parent .parent / "script.py"
16+
17+ pyproject = read_pyproject (pyproject_file )
18+ with export_template_file .open ("r" ) as f :
19+ template = jinja2 .Template (f .read ())
20+ with export_script_file .open ("r" ) as f :
21+ export_script = f .read ()
22+
23+ script = template .render (
24+ requires_python = ">=3.13" ,
25+ dependencies = pyproject ["project" ]["dependencies" ],
26+ export_script = export_script ,
27+ )
28+ with output .open ("w+" ) as f :
29+ f .write (script )
You can’t perform that action at this time.
0 commit comments