lange-python 0.3.21__tar.gz → 0.3.22__tar.gz
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.
- {lange_python-0.3.21 → lange_python-0.3.22}/PKG-INFO +1 -1
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/_command.py +29 -9
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/_discovery.py +3 -2
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/_docker.py +28 -3
- {lange_python-0.3.21 → lange_python-0.3.22}/pyproject.toml +1 -1
- {lange_python-0.3.21 → lange_python-0.3.22}/README.md +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/__main__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/_util/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/_util/_base_client.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/_util/_key_handling.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/_poetry.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/build/_types.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/_stats.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/audit/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/audit/_command.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/audit/_discovery.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/audit/_runner.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/code/audit/_types.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/distribution/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/cli/distribution/_command.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/distribution/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/distribution/_client.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/distribution/_update_macos.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/distribution/_util.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/tunnel/__init__.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/tunnel/_client.py +0 -0
- {lange_python-0.3.21 → lange_python-0.3.22}/lange/tunnel/_util.py +0 -0
|
@@ -13,7 +13,12 @@ from ._discovery import (
|
|
|
13
13
|
prompt_for_build_system_selection,
|
|
14
14
|
resolve_build_folder,
|
|
15
15
|
)
|
|
16
|
-
from ._docker import
|
|
16
|
+
from ._docker import (
|
|
17
|
+
discover_dockerfiles,
|
|
18
|
+
ensure_docker_is_available,
|
|
19
|
+
parse_image_reference,
|
|
20
|
+
run_docker_build,
|
|
21
|
+
)
|
|
17
22
|
from ._poetry import run_poetry_build, run_poetry_publish, run_poetry_version_patch
|
|
18
23
|
from ._types import DOCKER_BUILD_SYSTEM, POETRY_BUILD_SYSTEM, BuildSystem
|
|
19
24
|
|
|
@@ -130,10 +135,9 @@ def resolve_build_system(
|
|
|
130
135
|
:returns: Resolved build system value.
|
|
131
136
|
"""
|
|
132
137
|
if force_docker:
|
|
133
|
-
|
|
134
|
-
if not dockerfile.is_file():
|
|
138
|
+
if not discover_dockerfiles(folder):
|
|
135
139
|
raise click.ClickException(
|
|
136
|
-
f"Dockerfile was not found at '{
|
|
140
|
+
f"Dockerfile was not found at '{folder / 'Dockerfile'}'."
|
|
137
141
|
)
|
|
138
142
|
return DOCKER_BUILD_SYSTEM
|
|
139
143
|
|
|
@@ -166,14 +170,30 @@ def _run_docker_flow(folder: Path, publish: bool) -> None:
|
|
|
166
170
|
:param publish: Whether publish was requested via flag.
|
|
167
171
|
:returns: ``None``.
|
|
168
172
|
"""
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
dockerfiles = discover_dockerfiles(folder)
|
|
174
|
+
if not dockerfiles:
|
|
175
|
+
raise click.ClickException(
|
|
176
|
+
f"Dockerfile was not found at '{folder / 'Dockerfile'}'."
|
|
177
|
+
)
|
|
178
|
+
|
|
171
179
|
ensure_docker_is_available()
|
|
172
180
|
|
|
173
181
|
try:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
run_docker_build(
|
|
182
|
+
for dockerfile in dockerfiles:
|
|
183
|
+
image_reference = parse_image_reference(dockerfile)
|
|
184
|
+
run_docker_build(
|
|
185
|
+
folder=folder,
|
|
186
|
+
dockerfile=dockerfile,
|
|
187
|
+
image_reference=image_reference,
|
|
188
|
+
publish=publish,
|
|
189
|
+
)
|
|
190
|
+
if not publish and _confirm_publish():
|
|
191
|
+
run_docker_build(
|
|
192
|
+
folder=folder,
|
|
193
|
+
dockerfile=dockerfile,
|
|
194
|
+
image_reference=image_reference,
|
|
195
|
+
publish=True,
|
|
196
|
+
)
|
|
177
197
|
except subprocess.CalledProcessError as error:
|
|
178
198
|
raise click.ClickException(
|
|
179
199
|
f"Docker command failed with exit code {error.returncode}."
|
|
@@ -6,6 +6,7 @@ from pathlib import Path
|
|
|
6
6
|
|
|
7
7
|
import click
|
|
8
8
|
|
|
9
|
+
from ._docker import discover_dockerfiles
|
|
9
10
|
from ._types import DOCKER_BUILD_SYSTEM, POETRY_BUILD_SYSTEM, BuildSystem
|
|
10
11
|
|
|
11
12
|
|
|
@@ -82,7 +83,7 @@ def list_buildable_folders(
|
|
|
82
83
|
"""
|
|
83
84
|
candidates = list_candidate_folders(root)
|
|
84
85
|
if force_docker:
|
|
85
|
-
return [folder for folder in candidates if (folder
|
|
86
|
+
return [folder for folder in candidates if discover_dockerfiles(folder)]
|
|
86
87
|
if force_poetry:
|
|
87
88
|
return [folder for folder in candidates if (folder / "pyproject.toml").is_file()]
|
|
88
89
|
return [
|
|
@@ -98,7 +99,7 @@ def detect_available_build_systems(folder: Path) -> list[BuildSystem]:
|
|
|
98
99
|
:returns: Ordered list of detected build systems.
|
|
99
100
|
"""
|
|
100
101
|
available: list[BuildSystem] = []
|
|
101
|
-
if (folder
|
|
102
|
+
if discover_dockerfiles(folder):
|
|
102
103
|
available.append(DOCKER_BUILD_SYSTEM)
|
|
103
104
|
if (folder / "pyproject.toml").is_file():
|
|
104
105
|
available.append(POETRY_BUILD_SYSTEM)
|
|
@@ -14,6 +14,25 @@ PLATFORMS = "linux/amd64,linux/arm64"
|
|
|
14
14
|
IMAGE_LINE_PATTERN = re.compile(r"^#\s*image:\s*(?P<image>\S+)\s*$", re.IGNORECASE)
|
|
15
15
|
|
|
16
16
|
|
|
17
|
+
def discover_dockerfiles(folder: Path) -> list[Path]:
|
|
18
|
+
"""
|
|
19
|
+
Discover Dockerfiles that should be built for a folder.
|
|
20
|
+
|
|
21
|
+
:param folder: Folder that should be inspected.
|
|
22
|
+
:returns: Default Dockerfile when present, otherwise sorted named Dockerfiles.
|
|
23
|
+
"""
|
|
24
|
+
default_dockerfile = folder / "Dockerfile"
|
|
25
|
+
if default_dockerfile.is_file():
|
|
26
|
+
return [default_dockerfile]
|
|
27
|
+
|
|
28
|
+
named_dockerfiles = [
|
|
29
|
+
path
|
|
30
|
+
for path in folder.glob("*.Dockerfile")
|
|
31
|
+
if path.is_file()
|
|
32
|
+
]
|
|
33
|
+
return sorted(named_dockerfiles, key=lambda item: item.name.lower())
|
|
34
|
+
|
|
35
|
+
|
|
17
36
|
def ensure_docker_is_available() -> None:
|
|
18
37
|
"""
|
|
19
38
|
Validate that docker is installed and available in ``PATH``.
|
|
@@ -98,16 +117,22 @@ def ensure_buildx_builder() -> None:
|
|
|
98
117
|
)
|
|
99
118
|
|
|
100
119
|
|
|
101
|
-
def run_docker_build(
|
|
120
|
+
def run_docker_build(
|
|
121
|
+
folder: Path,
|
|
122
|
+
dockerfile: Path,
|
|
123
|
+
image_reference: str,
|
|
124
|
+
publish: bool,
|
|
125
|
+
) -> None:
|
|
102
126
|
"""
|
|
103
127
|
Execute docker buildx build for the given folder.
|
|
104
128
|
|
|
105
129
|
:param folder: Build context folder.
|
|
130
|
+
:param dockerfile: Dockerfile to build.
|
|
106
131
|
:param image_reference: Docker image name including tag.
|
|
107
132
|
:param publish: Whether ``--push`` should be included.
|
|
108
133
|
:returns: ``None``.
|
|
109
134
|
"""
|
|
110
|
-
|
|
135
|
+
resolved_dockerfile = dockerfile.resolve()
|
|
111
136
|
ensure_buildx_builder()
|
|
112
137
|
|
|
113
138
|
command: list[str] = [
|
|
@@ -117,7 +142,7 @@ def run_docker_build(folder: Path, image_reference: str, publish: bool) -> None:
|
|
|
117
142
|
"--platform",
|
|
118
143
|
PLATFORMS,
|
|
119
144
|
"--file",
|
|
120
|
-
str(
|
|
145
|
+
str(resolved_dockerfile),
|
|
121
146
|
"--tag",
|
|
122
147
|
image_reference,
|
|
123
148
|
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|