dycw-actions 0.8.11__py3-none-any.whl → 0.14.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- actions/.DS_Store +0 -0
- actions/__init__.py +1 -1
- actions/clean_dir/lib.py +7 -4
- actions/cli.py +23 -2
- actions/constants.py +2 -0
- actions/git_clone_with/__init__.py +1 -0
- actions/git_clone_with/cli.py +41 -0
- actions/git_clone_with/constants.py +7 -0
- actions/git_clone_with/lib.py +78 -0
- actions/git_clone_with/settings.py +20 -0
- actions/pre_commit/conformalize_repo/action_dicts.py +39 -40
- actions/pre_commit/conformalize_repo/cli.py +16 -4
- actions/pre_commit/conformalize_repo/constants.py +14 -0
- actions/pre_commit/conformalize_repo/lib.py +350 -220
- actions/pre_commit/conformalize_repo/settings.py +42 -16
- actions/pre_commit/constants.py +3 -3
- actions/pre_commit/format_requirements/lib.py +5 -2
- actions/pre_commit/replace_sequence_strs/lib.py +5 -2
- actions/pre_commit/touch_empty_py/lib.py +7 -4
- actions/pre_commit/touch_py_typed/lib.py +9 -5
- actions/pre_commit/update_requirements/cli.py +10 -2
- actions/pre_commit/update_requirements/lib.py +78 -15
- actions/pre_commit/update_requirements/settings.py +23 -0
- actions/pre_commit/utilities.py +131 -39
- actions/publish_package/lib.py +33 -20
- actions/random_sleep/lib.py +12 -7
- actions/re_encrypt/__init__.py +1 -0
- actions/re_encrypt/cli.py +36 -0
- actions/re_encrypt/constants.py +7 -0
- actions/re_encrypt/lib.py +115 -0
- actions/re_encrypt/settings.py +26 -0
- actions/register_gitea_runner/configs/entrypoint.sh +8 -8
- actions/register_gitea_runner/lib.py +23 -14
- actions/run_hooks/lib.py +27 -14
- actions/setup_cronjob/lib.py +19 -13
- actions/setup_ssh_config/__init__.py +1 -0
- actions/setup_ssh_config/cli.py +17 -0
- actions/setup_ssh_config/constants.py +7 -0
- actions/setup_ssh_config/lib.py +30 -0
- actions/tag_commit/lib.py +16 -9
- actions/types.py +5 -9
- actions/utilities.py +1 -16
- {dycw_actions-0.8.11.dist-info → dycw_actions-0.14.0.dist-info}/METADATA +5 -3
- {dycw_actions-0.8.11.dist-info → dycw_actions-0.14.0.dist-info}/RECORD +46 -30
- {dycw_actions-0.8.11.dist-info → dycw_actions-0.14.0.dist-info}/WHEEL +1 -1
- {dycw_actions-0.8.11.dist-info → dycw_actions-0.14.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from typed_settings import Secret, load_settings, option, secret, settings
|
|
4
|
-
from utilities.pytest import IS_CI
|
|
5
4
|
|
|
5
|
+
from actions.pre_commit.conformalize_repo.constants import RUN_VERSION_BUMP
|
|
6
6
|
from actions.utilities import LOADER
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@settings
|
|
10
10
|
class Settings:
|
|
11
|
-
|
|
11
|
+
ci__certificates: bool = option(
|
|
12
12
|
default=False, help="Update CA certficates before each step"
|
|
13
13
|
)
|
|
14
14
|
ci__gitea: bool = option(default=False, help="Set up CI on Gitea")
|
|
15
|
-
|
|
15
|
+
ci__token_checkout: Secret[str] | None = secret(
|
|
16
|
+
default=None, help="Set up CI with this checkout token"
|
|
17
|
+
)
|
|
18
|
+
ci__token_github: Secret[str] | None = secret(
|
|
19
|
+
default=None, help="Set up CI with this GitHub token"
|
|
20
|
+
)
|
|
16
21
|
ci__pull_request__pre_commit: bool = option(
|
|
17
22
|
default=False, help="Set up CI 'pull-request.yaml' pre-commit"
|
|
18
23
|
)
|
|
@@ -34,24 +39,45 @@ class Settings:
|
|
|
34
39
|
ci__pull_request__pytest__all_versions: bool = option(
|
|
35
40
|
default=False, help="Set up CI 'pull-request.yaml' pytest with all versions"
|
|
36
41
|
)
|
|
37
|
-
ci__pull_request__pytest__sops_age_key: str | None =
|
|
42
|
+
ci__pull_request__pytest__sops_age_key: Secret[str] | None = secret(
|
|
38
43
|
default=None,
|
|
39
44
|
help="Set up CI 'pull-request.yaml' pytest with this 'age' key for 'sops'",
|
|
40
45
|
)
|
|
41
46
|
ci__pull_request__ruff: bool = option(
|
|
42
47
|
default=False, help="Set up CI 'pull-request.yaml' ruff"
|
|
43
48
|
)
|
|
44
|
-
|
|
45
|
-
default=False, help="Set up CI 'push.yaml' publishing"
|
|
49
|
+
ci__push__publish__github: bool = option(
|
|
50
|
+
default=False, help="Set up CI 'push.yaml' publishing to GitHub"
|
|
51
|
+
)
|
|
52
|
+
ci__push__publish__primary: bool = option(
|
|
53
|
+
default=False, help="Set up CI 'push.yaml' publishing #1"
|
|
54
|
+
)
|
|
55
|
+
ci__push__publish__primary__job_name: str = option(
|
|
56
|
+
default="pypi", help="Set up CI 'push.yaml' publishing #1 with this job name"
|
|
57
|
+
)
|
|
58
|
+
ci__push__publish__primary__username: str | None = option(
|
|
59
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this username"
|
|
60
|
+
)
|
|
61
|
+
ci__push__publish__primary__password: Secret[str] | None = secret(
|
|
62
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this password"
|
|
46
63
|
)
|
|
47
|
-
|
|
48
|
-
default=None, help="Set up CI 'push.yaml' publishing with this
|
|
64
|
+
ci__push__publish__primary__publish_url: str | None = option(
|
|
65
|
+
default=None, help="Set up CI 'push.yaml' publishing #1 with this URL"
|
|
49
66
|
)
|
|
50
|
-
|
|
51
|
-
default=
|
|
67
|
+
ci__push__publish__secondary: bool = option(
|
|
68
|
+
default=False, help="Set up CI 'push.yaml' publishing #2"
|
|
52
69
|
)
|
|
53
|
-
|
|
54
|
-
default=
|
|
70
|
+
ci__push__publish__secondary__job_name: str = option(
|
|
71
|
+
default="pypi2", help="Set up CI 'push.yaml' publishing #2 with this job name"
|
|
72
|
+
)
|
|
73
|
+
ci__push__publish__secondary__username: str | None = option(
|
|
74
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this username"
|
|
75
|
+
)
|
|
76
|
+
ci__push__publish__secondary__password: Secret[str] | None = secret(
|
|
77
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this password"
|
|
78
|
+
)
|
|
79
|
+
ci__push__publish__secondary__publish_url: str | None = option(
|
|
80
|
+
default=None, help="Set up CI 'push.yaml' publishing #2 with this URL"
|
|
55
81
|
)
|
|
56
82
|
ci__push__tag: bool = option(default=False, help="Set up CI 'push.yaml' tagging")
|
|
57
83
|
ci__push__tag__all: bool = option(
|
|
@@ -89,9 +115,6 @@ class Settings:
|
|
|
89
115
|
default=False,
|
|
90
116
|
help="Set up 'pyproject.toml' [project.optional-dependencies.scripts]",
|
|
91
117
|
)
|
|
92
|
-
pyproject__tool__uv__indexes: list[tuple[str, str]] = option(
|
|
93
|
-
factory=list, help="Set up 'pyproject.toml' [[uv.tool.index]]"
|
|
94
|
-
)
|
|
95
118
|
pyright: bool = option(default=False, help="Set up 'pyrightconfig.json'")
|
|
96
119
|
pytest: bool = option(default=False, help="Set up 'pytest.toml'")
|
|
97
120
|
pytest__asyncio: bool = option(default=False, help="Set up 'pytest.toml' asyncio_*")
|
|
@@ -108,7 +131,10 @@ class Settings:
|
|
|
108
131
|
readme: bool = option(default=False, help="Set up 'README.md'")
|
|
109
132
|
repo_name: str | None = option(default=None, help="Repo name")
|
|
110
133
|
ruff: bool = option(default=False, help="Set up 'ruff.toml'")
|
|
111
|
-
run_version_bump: bool = option(default=
|
|
134
|
+
run_version_bump: bool = option(default=RUN_VERSION_BUMP, help="Run version bump")
|
|
135
|
+
uv__indexes: list[tuple[str, str]] = option(
|
|
136
|
+
factory=list, help="Set up 'uv' with index indexes"
|
|
137
|
+
)
|
|
112
138
|
uv__native_tls: bool = option(default=False, help="Setup 'uv' with native TLS")
|
|
113
139
|
script: str | None = option(
|
|
114
140
|
default=None, help="Set up a script instead of a package"
|
actions/pre_commit/constants.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from utilities.
|
|
3
|
+
from utilities.constants import HOUR
|
|
4
4
|
|
|
5
5
|
from actions.constants import PATH_ACTIONS
|
|
6
6
|
|
|
7
7
|
PATH_PRE_COMMIT = PATH_ACTIONS / "pre_commit"
|
|
8
|
-
|
|
8
|
+
THROTTLE_DURATION = 12 * HOUR
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
__all__ = ["PATH_PRE_COMMIT", "
|
|
11
|
+
__all__ = ["PATH_PRE_COMMIT", "THROTTLE_DURATION"]
|
|
@@ -3,11 +3,13 @@ from __future__ import annotations
|
|
|
3
3
|
import sys
|
|
4
4
|
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
|
+
from utilities.functions import get_func_name
|
|
7
|
+
from utilities.tabulate import func_param_desc
|
|
6
8
|
from utilities.text import repr_str
|
|
7
9
|
|
|
10
|
+
from actions import __version__
|
|
8
11
|
from actions.logging import LOGGER
|
|
9
12
|
from actions.pre_commit.utilities import get_pyproject_dependencies, yield_toml_doc
|
|
10
|
-
from actions.utilities import log_func_call
|
|
11
13
|
|
|
12
14
|
if TYPE_CHECKING:
|
|
13
15
|
from collections.abc import MutableSet
|
|
@@ -18,7 +20,7 @@ if TYPE_CHECKING:
|
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
def format_requirements(*paths: PathLike) -> None:
|
|
21
|
-
LOGGER.info(
|
|
23
|
+
LOGGER.info(func_param_desc(format_requirements, __version__, f"{paths=}"))
|
|
22
24
|
modifications: set[Path] = set()
|
|
23
25
|
for path in paths:
|
|
24
26
|
_format_path(path, modifications=modifications)
|
|
@@ -28,6 +30,7 @@ def format_requirements(*paths: PathLike) -> None:
|
|
|
28
30
|
", ".join(map(repr_str, sorted(modifications))),
|
|
29
31
|
)
|
|
30
32
|
sys.exit(1)
|
|
33
|
+
LOGGER.info("Finished running %r", get_func_name(format_requirements))
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
def _format_path(
|
|
@@ -10,11 +10,13 @@ from libcst.matchers import Subscript as MSubscript
|
|
|
10
10
|
from libcst.matchers import SubscriptElement as MSubscriptElement
|
|
11
11
|
from libcst.matchers import matches
|
|
12
12
|
from libcst.metadata import MetadataWrapper
|
|
13
|
+
from utilities.functions import get_func_name
|
|
14
|
+
from utilities.tabulate import func_param_desc
|
|
13
15
|
from utilities.text import repr_str
|
|
14
16
|
|
|
17
|
+
from actions import __version__
|
|
15
18
|
from actions.logging import LOGGER
|
|
16
19
|
from actions.pre_commit.utilities import yield_python_file
|
|
17
|
-
from actions.utilities import log_func_call
|
|
18
20
|
|
|
19
21
|
if TYPE_CHECKING:
|
|
20
22
|
from collections.abc import MutableSet
|
|
@@ -24,7 +26,7 @@ if TYPE_CHECKING:
|
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
def replace_sequence_strs(*paths: PathLike) -> None:
|
|
27
|
-
LOGGER.info(
|
|
29
|
+
LOGGER.info(func_param_desc(replace_sequence_strs, __version__, f"{paths=}"))
|
|
28
30
|
modifications: set[Path] = set()
|
|
29
31
|
for path in paths:
|
|
30
32
|
_format_path(path, modifications=modifications)
|
|
@@ -34,6 +36,7 @@ def replace_sequence_strs(*paths: PathLike) -> None:
|
|
|
34
36
|
", ".join(map(repr_str, sorted(modifications))),
|
|
35
37
|
)
|
|
36
38
|
sys.exit(1)
|
|
39
|
+
LOGGER.info("Finished running %r", get_func_name(replace_sequence_strs))
|
|
37
40
|
|
|
38
41
|
|
|
39
42
|
def _format_path(
|
|
@@ -4,13 +4,15 @@ import sys
|
|
|
4
4
|
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from libcst import parse_statement
|
|
7
|
+
from utilities.functions import get_func_name
|
|
8
|
+
from utilities.tabulate import func_param_desc
|
|
7
9
|
from utilities.text import repr_str
|
|
8
10
|
from utilities.throttle import throttle
|
|
9
11
|
|
|
12
|
+
from actions import __version__
|
|
10
13
|
from actions.logging import LOGGER
|
|
11
|
-
from actions.pre_commit.constants import
|
|
14
|
+
from actions.pre_commit.constants import THROTTLE_DURATION
|
|
12
15
|
from actions.pre_commit.utilities import path_throttle_cache, yield_python_file
|
|
13
|
-
from actions.utilities import log_func_call
|
|
14
16
|
|
|
15
17
|
if TYPE_CHECKING:
|
|
16
18
|
from collections.abc import MutableSet
|
|
@@ -20,7 +22,7 @@ if TYPE_CHECKING:
|
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
def _touch_empty_py(*paths: PathLike) -> None:
|
|
23
|
-
LOGGER.info(
|
|
25
|
+
LOGGER.info(func_param_desc(touch_empty_py, __version__, f"{paths=}"))
|
|
24
26
|
modifications: set[Path] = set()
|
|
25
27
|
for path in paths:
|
|
26
28
|
_format_path(path, modifications=modifications)
|
|
@@ -30,10 +32,11 @@ def _touch_empty_py(*paths: PathLike) -> None:
|
|
|
30
32
|
", ".join(map(repr_str, sorted(modifications))),
|
|
31
33
|
)
|
|
32
34
|
sys.exit(1)
|
|
35
|
+
LOGGER.info("Finished running %r", get_func_name(touch_empty_py))
|
|
33
36
|
|
|
34
37
|
|
|
35
38
|
touch_empty_py = throttle(
|
|
36
|
-
|
|
39
|
+
duration=THROTTLE_DURATION, path=path_throttle_cache(_touch_empty_py)
|
|
37
40
|
)(_touch_empty_py)
|
|
38
41
|
|
|
39
42
|
|
|
@@ -4,14 +4,17 @@ import sys
|
|
|
4
4
|
from pathlib import Path
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
+
from utilities.functions import get_func_name
|
|
7
8
|
from utilities.iterables import one
|
|
9
|
+
from utilities.tabulate import func_param_desc
|
|
8
10
|
from utilities.text import repr_str
|
|
9
11
|
from utilities.throttle import throttle
|
|
10
12
|
|
|
13
|
+
from actions import __version__
|
|
14
|
+
from actions.constants import PYPROJECT_TOML
|
|
11
15
|
from actions.logging import LOGGER
|
|
12
|
-
from actions.pre_commit.constants import
|
|
16
|
+
from actions.pre_commit.constants import THROTTLE_DURATION
|
|
13
17
|
from actions.pre_commit.utilities import path_throttle_cache
|
|
14
|
-
from actions.utilities import log_func_call
|
|
15
18
|
|
|
16
19
|
if TYPE_CHECKING:
|
|
17
20
|
from collections.abc import MutableSet
|
|
@@ -20,7 +23,7 @@ if TYPE_CHECKING:
|
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
def _touch_py_typed(*paths: PathLike) -> None:
|
|
23
|
-
LOGGER.info(
|
|
26
|
+
LOGGER.info(func_param_desc(touch_py_typed, __version__, f"{paths=}"))
|
|
24
27
|
modifications: set[Path] = set()
|
|
25
28
|
for path in paths:
|
|
26
29
|
_format_path(path, modifications=modifications)
|
|
@@ -30,10 +33,11 @@ def _touch_py_typed(*paths: PathLike) -> None:
|
|
|
30
33
|
", ".join(map(repr_str, sorted(modifications))),
|
|
31
34
|
)
|
|
32
35
|
sys.exit(1)
|
|
36
|
+
LOGGER.info("Finished running %r", get_func_name(touch_py_typed))
|
|
33
37
|
|
|
34
38
|
|
|
35
39
|
touch_py_typed = throttle(
|
|
36
|
-
|
|
40
|
+
duration=THROTTLE_DURATION, path=path_throttle_cache(_touch_py_typed)
|
|
37
41
|
)(_touch_py_typed)
|
|
38
42
|
|
|
39
43
|
|
|
@@ -44,7 +48,7 @@ def _format_path(
|
|
|
44
48
|
if not path.is_file():
|
|
45
49
|
msg = f"Expected a file; {str(path)!r} is not"
|
|
46
50
|
raise FileNotFoundError(msg)
|
|
47
|
-
if path.name !=
|
|
51
|
+
if path.name != PYPROJECT_TOML.name:
|
|
48
52
|
msg = f"Expected 'pyproject.toml'; got {str(path)!r}"
|
|
49
53
|
raise TypeError(msg)
|
|
50
54
|
src = path.parent / "src"
|
|
@@ -2,23 +2,31 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
|
+
from typed_settings import click_options
|
|
5
6
|
from utilities.logging import basic_config
|
|
6
7
|
from utilities.os import is_pytest
|
|
7
8
|
|
|
8
9
|
from actions.logging import LOGGER
|
|
9
10
|
from actions.pre_commit.click import path_argument
|
|
10
11
|
from actions.pre_commit.update_requirements.lib import update_requirements
|
|
12
|
+
from actions.pre_commit.update_requirements.settings import Settings
|
|
13
|
+
from actions.utilities import LOADER
|
|
11
14
|
|
|
12
15
|
if TYPE_CHECKING:
|
|
13
16
|
from pathlib import Path
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
@path_argument
|
|
17
|
-
|
|
20
|
+
@click_options(Settings, [LOADER], show_envvars_in_help=True)
|
|
21
|
+
def update_requirements_sub_cmd(
|
|
22
|
+
settings: Settings, /, *, paths: tuple[Path, ...]
|
|
23
|
+
) -> None:
|
|
18
24
|
if is_pytest():
|
|
19
25
|
return
|
|
20
26
|
basic_config(obj=LOGGER)
|
|
21
|
-
update_requirements(
|
|
27
|
+
update_requirements(
|
|
28
|
+
*paths, indexes=settings.indexes, native_tls=settings.native_tls
|
|
29
|
+
)
|
|
22
30
|
|
|
23
31
|
|
|
24
32
|
__all__ = ["update_requirements_sub_cmd"]
|
|
@@ -4,10 +4,13 @@ import sys
|
|
|
4
4
|
from functools import partial
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
+
from ordered_set import OrderedSet
|
|
7
8
|
from pydantic import TypeAdapter
|
|
8
|
-
from utilities.functions import max_nullable
|
|
9
|
+
from utilities.functions import ensure_str, get_func_name, max_nullable
|
|
10
|
+
from utilities.tabulate import func_param_desc
|
|
9
11
|
from utilities.text import repr_str
|
|
10
12
|
|
|
13
|
+
from actions import __version__
|
|
11
14
|
from actions.logging import LOGGER
|
|
12
15
|
from actions.pre_commit.update_requirements.classes import (
|
|
13
16
|
PipListOutdatedOutput,
|
|
@@ -18,11 +21,18 @@ from actions.pre_commit.update_requirements.classes import (
|
|
|
18
21
|
parse_version1_or_2,
|
|
19
22
|
parse_version2_or_3,
|
|
20
23
|
)
|
|
21
|
-
from actions.pre_commit.
|
|
22
|
-
from actions.utilities import
|
|
24
|
+
from actions.pre_commit.update_requirements.settings import SETTINGS
|
|
25
|
+
from actions.pre_commit.utilities import (
|
|
26
|
+
get_aot,
|
|
27
|
+
get_pyproject_dependencies,
|
|
28
|
+
get_table,
|
|
29
|
+
yield_pyproject_toml,
|
|
30
|
+
yield_toml_doc,
|
|
31
|
+
)
|
|
32
|
+
from actions.utilities import logged_run
|
|
23
33
|
|
|
24
34
|
if TYPE_CHECKING:
|
|
25
|
-
from collections.abc import MutableSet
|
|
35
|
+
from collections.abc import Iterator, MutableSet
|
|
26
36
|
from pathlib import Path
|
|
27
37
|
|
|
28
38
|
from utilities.packaging import Requirement
|
|
@@ -31,17 +41,32 @@ if TYPE_CHECKING:
|
|
|
31
41
|
from actions.pre_commit.update_requirements.classes import Version2or3, VersionSet
|
|
32
42
|
|
|
33
43
|
|
|
34
|
-
def update_requirements(
|
|
35
|
-
|
|
44
|
+
def update_requirements(
|
|
45
|
+
*paths: PathLike,
|
|
46
|
+
indexes: list[str] | None = SETTINGS.indexes,
|
|
47
|
+
native_tls: bool = SETTINGS.native_tls,
|
|
48
|
+
) -> None:
|
|
49
|
+
LOGGER.info(
|
|
50
|
+
func_param_desc(
|
|
51
|
+
update_requirements,
|
|
52
|
+
__version__,
|
|
53
|
+
f"{paths=}",
|
|
54
|
+
f"{indexes=}",
|
|
55
|
+
f"{native_tls=}",
|
|
56
|
+
)
|
|
57
|
+
)
|
|
36
58
|
modifications: set[Path] = set()
|
|
37
59
|
for path in paths:
|
|
38
|
-
_format_path(
|
|
60
|
+
_format_path(
|
|
61
|
+
path, indexes=indexes, native_tls=native_tls, modifications=modifications
|
|
62
|
+
)
|
|
39
63
|
if len(modifications) >= 1:
|
|
40
64
|
LOGGER.info(
|
|
41
65
|
"Exiting due to modifications: %s",
|
|
42
66
|
", ".join(map(repr_str, sorted(modifications))),
|
|
43
67
|
)
|
|
44
68
|
sys.exit(1)
|
|
69
|
+
LOGGER.info("Finished running %r", get_func_name(update_requirements))
|
|
45
70
|
|
|
46
71
|
|
|
47
72
|
def _format_path(
|
|
@@ -49,24 +74,40 @@ def _format_path(
|
|
|
49
74
|
/,
|
|
50
75
|
*,
|
|
51
76
|
versions: VersionSet | None = None,
|
|
77
|
+
indexes: list[str] | None = SETTINGS.indexes,
|
|
78
|
+
native_tls: bool = SETTINGS.native_tls,
|
|
52
79
|
modifications: MutableSet[Path] | None = None,
|
|
53
80
|
) -> None:
|
|
54
|
-
versions_use =
|
|
81
|
+
versions_use = (
|
|
82
|
+
_get_versions(indexes=indexes, native_tls=native_tls)
|
|
83
|
+
if versions is None
|
|
84
|
+
else versions
|
|
85
|
+
)
|
|
55
86
|
with yield_toml_doc(path, modifications=modifications) as doc:
|
|
56
87
|
get_pyproject_dependencies(doc).apply(
|
|
57
88
|
partial(_format_req, versions=versions_use)
|
|
58
89
|
)
|
|
59
90
|
|
|
60
91
|
|
|
61
|
-
def _get_versions(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
92
|
+
def _get_versions(
|
|
93
|
+
*,
|
|
94
|
+
indexes: list[str] | None = SETTINGS.indexes,
|
|
95
|
+
native_tls: bool = SETTINGS.native_tls,
|
|
96
|
+
) -> VersionSet:
|
|
97
|
+
index_args: OrderedSet[str] = OrderedSet([])
|
|
98
|
+
_ = index_args.update(list(_yield_indexes()))
|
|
99
|
+
if indexes is not None:
|
|
100
|
+
_ = index_args.update(indexes)
|
|
101
|
+
head: list[str] = ["uv", "pip", "list", "--format", "json"]
|
|
102
|
+
tail: list[str] = ["--strict"]
|
|
103
|
+
if len(index_args) >= 1:
|
|
104
|
+
tail.extend(["--index", ",".join(index_args)])
|
|
105
|
+
if native_tls:
|
|
106
|
+
tail.append("--native-tls")
|
|
107
|
+
json1 = logged_run(*head, *tail, return_=True)
|
|
65
108
|
models1 = TypeAdapter(list[PipListOutput]).validate_json(json1)
|
|
66
109
|
versions1 = {p.name: parse_version2_or_3(p.version) for p in models1}
|
|
67
|
-
json2 = logged_run(
|
|
68
|
-
"uv", "pip", "list", "--format", "json", "--outdated", "--strict", return_=True
|
|
69
|
-
)
|
|
110
|
+
json2 = logged_run(*head, "--outdated", *tail, return_=True)
|
|
70
111
|
models2 = TypeAdapter(list[PipListOutdatedOutput]).validate_json(json2)
|
|
71
112
|
versions2 = {p.name: parse_version2_or_3(p.latest_version) for p in models2}
|
|
72
113
|
out: StrDict = {}
|
|
@@ -75,6 +116,28 @@ def _get_versions() -> VersionSet:
|
|
|
75
116
|
return out
|
|
76
117
|
|
|
77
118
|
|
|
119
|
+
def _yield_indexes() -> Iterator[str]:
|
|
120
|
+
try:
|
|
121
|
+
with yield_pyproject_toml() as doc:
|
|
122
|
+
try:
|
|
123
|
+
tool = get_table(doc, "tool")
|
|
124
|
+
except KeyError:
|
|
125
|
+
return
|
|
126
|
+
try:
|
|
127
|
+
uv = get_table(tool, "uv")
|
|
128
|
+
except KeyError:
|
|
129
|
+
return
|
|
130
|
+
try:
|
|
131
|
+
indexes = get_aot(uv, "index")
|
|
132
|
+
except KeyError:
|
|
133
|
+
return
|
|
134
|
+
else:
|
|
135
|
+
for index in indexes:
|
|
136
|
+
yield ensure_str(index["url"])
|
|
137
|
+
except FileNotFoundError:
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
|
|
78
141
|
def _format_req(requirement: Requirement, /, *, versions: VersionSet) -> Requirement:
|
|
79
142
|
try:
|
|
80
143
|
lower = parse_version2_or_3(requirement[">="])
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typed_settings import load_settings, option, settings
|
|
4
|
+
|
|
5
|
+
from actions.utilities import LOADER
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@settings
|
|
9
|
+
class Settings:
|
|
10
|
+
indexes: list[str] | None = option(
|
|
11
|
+
factory=list,
|
|
12
|
+
help="List of URLs as additional indexes when searching for packages",
|
|
13
|
+
)
|
|
14
|
+
native_tls: bool = option(
|
|
15
|
+
default=False,
|
|
16
|
+
help="Whether to load TLS certificates from the platform's native certificate store",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
SETTINGS = load_settings(Settings, [LOADER])
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
__all__ = ["SETTINGS", "Settings"]
|