-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b931e71
commit 78ca05f
Showing
8 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
- id: sync-uv-pre-commit | ||
name: Sync uv and pre commit | ||
description: Sync uv and pre commit | ||
language: python | ||
entry: "sync_uv_pre_commit" | ||
language: script | ||
entry: "uv run script.py" | ||
minimum_pre_commit_version: "3.5.0" | ||
require_serial: true | ||
always_run: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# /// script | ||
# requires-python = ">=3.13" | ||
# dependencies = [ | ||
# "packaging", | ||
# "pre-commit>=3.5.0", | ||
# "tomlkit>=0.13.2", | ||
# "typing-extensions>=4.12.2", | ||
# ] | ||
# /// | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
WORKSPACE = Path(__file__).parent | ||
sys.path.append(str(WORKSPACE / "src")) | ||
|
||
|
||
if __name__ == "__main__": | ||
from sync_uv_pre_commit.cli import main | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import annotations | ||
|
||
import sys | ||
from pathlib import Path | ||
|
||
WORKSPACE = Path(__file__).parent | ||
sys.path.append(str(WORKSPACE / "src")) | ||
|
||
|
||
if __name__ == "__main__": | ||
from sync_uv_pre_commit.cli import main | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# /// script | ||
# requires-python = "{{ requires_python }}" | ||
# dependencies = [ | ||
{% for dependency in dependencies -%} | ||
# "{{ dependency }}", | ||
{% endfor -%} | ||
# ] | ||
# /// | ||
|
||
{{ export_script }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
|
||
import jinja2 | ||
|
||
from sync_uv_pre_commit.toml import read_pyproject | ||
|
||
|
||
def generate_script() -> None: | ||
"""Generate the script.py file.""" | ||
pyproject_file = Path(__file__).parent.parent.parent / "pyproject.toml" | ||
export_template_file = Path(__file__).parent / "export.py.j2" | ||
export_script_file = Path(__file__).parent / "export.py" | ||
output = Path(__file__).parent.parent.parent / "script.py" | ||
|
||
pyproject = read_pyproject(pyproject_file) | ||
with export_template_file.open("r") as f: | ||
template = jinja2.Template(f.read()) | ||
with export_script_file.open("r") as f: | ||
export_script = f.read() | ||
|
||
script = template.render( | ||
requires_python=">=3.13", | ||
dependencies=pyproject["project"]["dependencies"], | ||
export_script=export_script, | ||
) | ||
with output.open("w+") as f: | ||
f.write(script) |