Skip to content

Commit 0e01790

Browse files
Merge branch 'develop'
2 parents cd79e90 + 434eb45 commit 0e01790

File tree

99 files changed

+953
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+953
-415
lines changed

.github/workflows/build.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
branches:
66
- develop
7+
merge_group:
8+
types: [checks_requested]
9+
branches:
10+
- develop
711

812
jobs:
913
run-workflow:
@@ -54,6 +58,7 @@ jobs:
5458
- "3.7"
5559
- "3.8"
5660
- "3.9"
61+
- "3.10"
5762
steps:
5863
- uses: actions/checkout@v3
5964
- uses: actions/setup-python@v4
@@ -78,6 +83,7 @@ jobs:
7883
- "3.7"
7984
- "3.8"
8085
- "3.9"
86+
- "3.10"
8187
npm:
8288
- 8
8389
- 9
@@ -109,6 +115,7 @@ jobs:
109115
- "3.7"
110116
- "3.8"
111117
- "3.9"
118+
- "3.10"
112119
npm:
113120
- 8
114121
- 9
@@ -140,12 +147,13 @@ jobs:
140147
- "3.7"
141148
- "3.8"
142149
- "3.9"
150+
- "3.10"
143151
steps:
144152
- uses: actions/checkout@v3
145153
- uses: actions/setup-python@v4
146154
with:
147155
python-version: ${{ matrix.python }}
148-
- uses: actions/setup-go@v3
156+
- uses: actions/setup-go@v4
149157
with:
150158
go-version: '^1.16'
151159
- run: make init
@@ -162,9 +170,10 @@ jobs:
162170
- ubuntu-latest
163171
- windows-latest
164172
python:
165-
- "3.9"
166-
- "3.8"
167173
- "3.7"
174+
- "3.8"
175+
- "3.9"
176+
- "3.10"
168177
steps:
169178
- uses: actions/checkout@v3
170179
- uses: actions/setup-python@v4
@@ -190,9 +199,10 @@ jobs:
190199
- ubuntu-latest
191200
- windows-latest
192201
python:
193-
- "3.9"
194-
- "3.8"
195202
- "3.7"
203+
- "3.8"
204+
- "3.9"
205+
- "3.10"
196206
steps:
197207
- uses: actions/checkout@v3
198208
- uses: actions/setup-python@v4
@@ -216,9 +226,10 @@ jobs:
216226
- ubuntu-latest
217227
- windows-latest
218228
python:
219-
- "3.9"
220-
- "3.8"
221229
- "3.7"
230+
- "3.8"
231+
- "3.9"
232+
- "3.10"
222233
steps:
223234
- uses: actions/checkout@v3
224235
- uses: actions/setup-python@v4
@@ -238,9 +249,10 @@ jobs:
238249
- ubuntu-latest
239250
- windows-latest
240251
python:
241-
- "3.9"
242-
- "3.8"
243252
- "3.7"
253+
- "3.8"
254+
- "3.9"
255+
- "3.10"
244256
steps:
245257
- uses: actions/checkout@v3
246258
- uses: actions/setup-python@v4
@@ -260,9 +272,10 @@ jobs:
260272
- ubuntu-latest
261273
- windows-latest
262274
python:
263-
- "3.9"
264-
- "3.8"
265275
- "3.7"
276+
- "3.8"
277+
- "3.9"
278+
- "3.10"
266279
ruby:
267280
- "3.1"
268281
- "2.7"
@@ -288,9 +301,10 @@ jobs:
288301
- ubuntu-latest
289302
- windows-latest
290303
python:
291-
- "3.9"
292-
- "3.8"
293304
- "3.7"
305+
- "3.8"
306+
- "3.9"
307+
- "3.10"
294308
steps:
295309
- uses: actions/checkout@v3
296310
- uses: actions/setup-python@v4

.github/workflows/pr-labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
pull-requests: write
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/labeler@v3
12+
- uses: actions/labeler@v4
1313
with:
1414
repo-token: "${{ secrets.GITHUB_TOKEN }}"
1515
apply-internal-external-label:

aws_lambda_builders/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
# Changing version will trigger a new release!
66
# Please make the version change as the last step of your development.
7-
__version__ = "1.27.0"
7+
__version__ = "1.28.0"
88
RPC_PROTOCOL_VERSION = "0.3"

aws_lambda_builders/__main__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def _error_response(request_id, http_status_code, message):
3636

3737

3838
def _parse_version(version_string):
39-
4039
if VERSION_REGEX.match(version_string):
4140
return float(version_string)
4241
else:

aws_lambda_builders/actions.py

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import os
77
import shutil
88
from pathlib import Path
9-
from typing import Iterator, Set, Tuple
9+
from typing import Iterator, Set, Tuple, Union
1010

1111
from aws_lambda_builders import utils
12-
from aws_lambda_builders.utils import copytree
12+
from aws_lambda_builders.utils import copytree, create_symlink_or_copy
1313

1414
LOG = logging.getLogger(__name__)
1515

@@ -55,7 +55,6 @@ def has_value(item):
5555

5656
class _ActionMetaClass(type):
5757
def __new__(mcs, name, bases, class_dict):
58-
5958
cls = type.__new__(mcs, name, bases, class_dict)
6059

6160
if cls.__name__ == "BaseAction":
@@ -100,24 +99,28 @@ def __repr__(self):
10099

101100

102101
class CopySourceAction(BaseAction):
103-
104102
NAME = "CopySource"
105103

106104
DESCRIPTION = "Copying source code while skipping certain commonly excluded files"
107105

108106
PURPOSE = Purpose.COPY_SOURCE
109107

110-
def __init__(self, source_dir, dest_dir, excludes=None):
108+
def __init__(self, source_dir, dest_dir, excludes=None, maintain_symlinks=False):
111109
self.source_dir = source_dir
112110
self.dest_dir = dest_dir
113111
self.excludes = excludes or []
112+
self.maintain_symlinks = maintain_symlinks
114113

115114
def execute(self):
116-
copytree(self.source_dir, self.dest_dir, ignore=shutil.ignore_patterns(*self.excludes))
115+
copytree(
116+
self.source_dir,
117+
self.dest_dir,
118+
ignore=shutil.ignore_patterns(*self.excludes),
119+
maintain_symlinks=self.maintain_symlinks,
120+
)
117121

118122

119123
class LinkSourceAction(BaseAction):
120-
121124
NAME = "LinkSource"
122125

123126
DESCRIPTION = "Linking source code to the target folder"
@@ -141,32 +144,54 @@ def execute(self):
141144
utils.create_symlink_or_copy(str(source_path), str(destination_path))
142145

143146

144-
class CopyDependenciesAction(BaseAction):
147+
class LinkSinglePathAction(BaseAction):
148+
NAME = "LinkSource"
149+
150+
DESCRIPTION = "Creates symbolic link at destination, pointing to source"
151+
152+
PURPOSE = Purpose.LINK_SOURCE
145153

154+
def __init__(self, source: Union[str, os.PathLike], dest: Union[str, os.PathLike]):
155+
self._source = source
156+
self._dest = dest
157+
158+
def execute(self):
159+
destination_path = Path(self._dest)
160+
if not destination_path.exists():
161+
os.makedirs(destination_path.parent, exist_ok=True)
162+
utils.create_symlink_or_copy(str(self._source), str(destination_path))
163+
164+
165+
class CopyDependenciesAction(BaseAction):
146166
NAME = "CopyDependencies"
147167

148168
DESCRIPTION = "Copying dependencies while skipping source file"
149169

150170
PURPOSE = Purpose.COPY_DEPENDENCIES
151171

152-
def __init__(self, source_dir, artifact_dir, destination_dir):
172+
def __init__(self, source_dir, artifact_dir, destination_dir, maintain_symlinks=False):
153173
self.source_dir = source_dir
154174
self.artifact_dir = artifact_dir
155175
self.dest_dir = destination_dir
176+
self.maintain_symlinks = maintain_symlinks
156177

157178
def execute(self):
158179
deps_manager = DependencyManager(self.source_dir, self.artifact_dir, self.dest_dir)
159180

160181
for dependencies_source, new_destination in deps_manager.yield_source_dest():
161-
if os.path.isdir(dependencies_source):
162-
copytree(dependencies_source, new_destination)
182+
if os.path.islink(dependencies_source) and self.maintain_symlinks:
183+
os.makedirs(os.path.dirname(new_destination), exist_ok=True)
184+
linkto = os.readlink(dependencies_source)
185+
create_symlink_or_copy(linkto, new_destination)
186+
shutil.copystat(dependencies_source, new_destination, follow_symlinks=False)
187+
elif os.path.isdir(dependencies_source):
188+
copytree(dependencies_source, new_destination, maintain_symlinks=self.maintain_symlinks)
163189
else:
164190
os.makedirs(os.path.dirname(new_destination), exist_ok=True)
165191
shutil.copy2(dependencies_source, new_destination)
166192

167193

168194
class MoveDependenciesAction(BaseAction):
169-
170195
NAME = "MoveDependencies"
171196

172197
DESCRIPTION = "Moving dependencies while skipping source file"
@@ -214,7 +239,9 @@ def execute(self):
214239
target_path = os.path.join(self.target_dir, name)
215240
LOG.debug("Clean up action: %s is deleted", str(target_path))
216241

217-
if os.path.isdir(target_path):
242+
if os.path.islink(target_path):
243+
os.unlink(target_path)
244+
elif os.path.isdir(target_path):
218245
shutil.rmtree(target_path)
219246
else:
220247
os.remove(target_path)

aws_lambda_builders/builder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class LambdaBuilder(object):
2121
"""
2222

2323
def __init__(self, language, dependency_manager, application_framework, supported_workflows=None):
24-
2524
"""
2625
Initialize the builder.
2726
:type supported_workflows: list

aws_lambda_builders/exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class LambdaBuilderError(Exception):
7-
87
MESSAGE = ""
98

109
def __init__(self, **kwargs):

aws_lambda_builders/registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def __getitem__(self, capability):
2424
return self._data[key]
2525

2626
def __setitem__(self, capability, value):
27-
2827
key = self._make_key(capability)
2928

3029
try:

aws_lambda_builders/utils.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,40 @@
77
import shutil
88
import sys
99
from pathlib import Path
10-
from typing import Union
10+
from typing import Callable, List, Optional, Set, Union
1111

1212
from aws_lambda_builders.architecture import ARM64
1313

1414
LOG = logging.getLogger(__name__)
1515

1616

17-
def copytree(source, destination, ignore=None, include=None):
17+
def copytree(
18+
source: str,
19+
destination: str,
20+
ignore: Optional[Callable[[str, List[str]], Set[str]]] = None,
21+
include: Optional[Callable[[str], bool]] = None,
22+
maintain_symlinks: bool = False,
23+
) -> None:
1824
"""
1925
Similar to shutil.copytree except that it removes the limitation that the destination directory should
2026
be present.
2127
22-
:type source: str
23-
:param source:
24-
Path to the source folder to copy
25-
26-
:type destination: str
27-
:param destination:
28-
Path to destination folder
29-
30-
:type ignore: function
31-
:param ignore:
28+
Parameters
29+
----------
30+
source : str
31+
Path to the source folder to copy.
32+
destination : str
33+
Path to destination folder.
34+
ignore : Optional[Callable[[str, List[str]], Set[str]]]
3235
A function that returns a set of file names to ignore, given a list of available file names. Similar to the
33-
``ignore`` property of ``shutils.copytree`` method
34-
35-
:type include: Callable[[str], bool]
36-
:param include:
36+
``ignore`` property of ``shutils.copytree`` method. By default None.
37+
include : Optional[Callable[[str], bool]]
3738
A function that will decide whether a file should be copied or skipped it. It accepts file name as parameter
3839
and return True or False. Returning True will continue copy operation, returning False will skip copy operation
39-
for that file
40+
for that file. By default None.
41+
maintain_symlinks : bool, optional
42+
If True, symbolic links in the source are represented as symbolic links in the destination.
43+
If False, the contents are copied over. By default False.
4044
"""
4145

4246
if not os.path.exists(source):
@@ -74,8 +78,12 @@ def copytree(source, destination, ignore=None, include=None):
7478
LOG.debug("File (%s) doesn't satisfy the include rule, skipping it", name)
7579
continue
7680

77-
if os.path.isdir(new_source):
78-
copytree(new_source, new_destination, ignore=ignore, include=include)
81+
if os.path.islink(new_source) and maintain_symlinks:
82+
linkto = os.readlink(new_source)
83+
create_symlink_or_copy(linkto, new_destination)
84+
shutil.copystat(new_source, new_destination, follow_symlinks=False)
85+
elif os.path.isdir(new_source):
86+
copytree(new_source, new_destination, ignore=ignore, include=include, maintain_symlinks=maintain_symlinks)
7987
else:
8088
LOG.debug("Copying source file (%s) to destination (%s)", new_source, new_destination)
8189
shutil.copy2(new_source, new_destination)
@@ -193,7 +201,8 @@ def create_symlink_or_copy(source: str, destination: str) -> None:
193201
os.symlink(Path(source).absolute(), Path(destination).absolute())
194202
except OSError as ex:
195203
LOG.warning(
196-
"Symlink operation is failed, falling back to copying files",
204+
"Symbolic link creation failed, falling back to copying files instead. To optimize speed, "
205+
"consider enabling the necessary settings or privileges on your system to support symbolic links.",
197206
exc_info=ex if LOG.isEnabledFor(logging.DEBUG) else None,
198207
)
199208
copytree(source, destination)

aws_lambda_builders/validator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"python3.7": [X86_64],
1818
"python3.8": [ARM64, X86_64],
1919
"python3.9": [ARM64, X86_64],
20+
"python3.10": [ARM64, X86_64],
2021
"ruby2.7": [ARM64, X86_64],
2122
"java8": [ARM64, X86_64],
2223
"java11": [ARM64, X86_64],

0 commit comments

Comments
 (0)