-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Showing
19 changed files
with
1,356 additions
and
1,499 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
AWS SAM CLI | ||
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,152 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
binary_zip_filename=${1:-} | ||
python_library_zip_filename=${2:-} | ||
python_version=${3:-} | ||
build_binary_name=${4:-} | ||
build_folder=${5:-} | ||
openssl_version=${6:-} | ||
mac_arch="$(uname -m)" | ||
openssl_config_arch="" | ||
|
||
# Set architecture to install openssl | ||
if [ "$mac_arch" = "arm64" ]; then | ||
openssl_config_arch="darwin64-arm64-cc" | ||
export PATH=/usr/local/bin:"$PATH" | ||
elif [ "$mac_arch" = "x86_64" ]; then | ||
openssl_config_arch="darwin64-x86_64-cc" | ||
else | ||
echo "Invalid architecture found" | ||
exit 1 | ||
fi | ||
|
||
if [ "$python_library_zip_filename" = "" ]; then | ||
python_library_zip_filename="python-libraries.zip"; | ||
fi | ||
|
||
if [ "$openssl_version" = "" ]; then | ||
openssl_version="1.1.1o"; | ||
fi | ||
|
||
if [ "$python_version" = "" ]; then | ||
python_version="3.8.13"; | ||
fi | ||
|
||
if ! [ "$build_binary_name" = "" ]; then | ||
echo "Building native installer with nightly/beta build" | ||
is_nightly="true" | ||
else | ||
echo "Building native installer with normal build" | ||
is_nightly="false" | ||
fi | ||
|
||
echo "Making Folders" | ||
mkdir -p .build/src | ||
mkdir -p .build/output/aws-sam-cli-src | ||
mkdir -p .build/output/python-libraries | ||
mkdir -p .build/output/pyinstaller-output | ||
cd .build | ||
|
||
# Installing Openssl to allow pip configured in the TLS/SSL location to install python libraries | ||
echo "Installing Openssl" | ||
curl -LO https://www.openssl.org/source/openssl-"${openssl_version}".tar.gz | ||
tar -xzf openssl-"${openssl_version}".tar.gz | ||
cd openssl-"$openssl_version" | ||
# Openssl configure https://wiki.openssl.org/index.php/Compilation_and_Installation | ||
./Configure --prefix=/usr/local --openssldir=/usr/local/openssl no-ssl3 no-ssl3-method no-zlib ${openssl_config_arch} enable-ec_nistp_64_gcc_128 | ||
|
||
make | ||
sudo make install | ||
cd .. | ||
|
||
# Copying aws-sam-cli source code | ||
echo "Copying Source" | ||
cp -r ../[!.]* ./src | ||
cp -r ./src/* ./output/aws-sam-cli-src | ||
|
||
echo "Removing CI Scripts" | ||
rm -vf ./output/aws-sam-cli-src/appveyor*.yml | ||
|
||
echo "Installing Python" | ||
curl "https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz" --output python.tgz | ||
tar -xzf python.tgz | ||
cd Python-"$python_version" | ||
./configure --enable-shared | ||
make -j8 | ||
sudo make install | ||
cd .. | ||
|
||
echo "Installing Python Libraries" | ||
/usr/local/bin/python3.8 -m venv venv | ||
./venv/bin/pip install --upgrade pip | ||
./venv/bin/pip install -r src/requirements/reproducible-linux.txt | ||
|
||
echo "Copying All Python Libraries" | ||
cp -r ./venv/lib/python*/site-packages/* ./output/python-libraries | ||
|
||
echo "Installing PyInstaller" | ||
./venv/bin/pip install -r src/requirements/pyinstaller-build.txt | ||
|
||
# Building the binary using pyinstaller | ||
echo "Building Binary" | ||
cd src | ||
if [ "$is_nightly" = "true" ]; then | ||
# If nightly build, replace the exe_name in spec file with build_binary_name | ||
echo "Updating samcli-mac.spec with nightly/beta build" | ||
sed -i.bak "s/'sam'/'$build_binary_name'/g" installer/pyinstaller/samcli-mac.spec | ||
rm installer/pyinstaller/samcli-mac.spec.bak | ||
fi | ||
echo "samcli-mac.spec content is:" | ||
cat installer/pyinstaller/samcli-mac.spec | ||
# Note: onefile/onedir options are not valid when spec file is used on mac | ||
../venv/bin/python -m PyInstaller --clean installer/pyinstaller/samcli-mac.spec | ||
|
||
# Organizing the pyinstaller-output folder | ||
mkdir pyinstaller-output | ||
dist_folder="sam" | ||
if [ "$is_nightly" = "true" ]; then | ||
echo "using dist_folder with nightly/beta build" | ||
dist_folder=$build_binary_name | ||
fi | ||
echo "dist_folder=$dist_folder" | ||
mv "dist/$dist_folder" pyinstaller-output/dist | ||
cp installer/assets/* pyinstaller-output | ||
chmod 755 pyinstaller-output/install | ||
if [ "$is_nightly" = "true" ]; then | ||
echo "Updating install script with nightly/beta build" | ||
# If nightly build, replace the build folder and build_binary_name in the install script | ||
sed -i.bak "s/\/usr\/local\/aws-sam-cli/\/usr\/local\/$build_folder/g" pyinstaller-output/install | ||
sed -i.bak 's/EXE_NAME=\"sam\"/EXE_NAME=\"'"$build_binary_name"'\"/g' pyinstaller-output/install | ||
rm pyinstaller-output/install.bak | ||
fi | ||
echo "install script content is:" | ||
cat pyinstaller-output/install | ||
echo "Copying Binary" | ||
cd .. | ||
cp -r src/pyinstaller-output/* output/pyinstaller-output | ||
|
||
echo "Packaging Binary" | ||
cd output | ||
cd pyinstaller-output | ||
cd dist | ||
cd .. | ||
zip -r ../"$binary_zip_filename" ./* | ||
cd .. | ||
zip -r "$binary_zip_filename" aws-sam-cli-src | ||
|
||
# Remove unwanted files and zip the python libraries | ||
echo "Packaging Python Libraries" | ||
cd python-libraries | ||
rm -rf ./*.dist-info | ||
rm -rf ./*.egg-info | ||
rm -rf ./__pycache__ | ||
rm -rf ./pip | ||
rm -rf ./easy_install.py | ||
rm -rf ./pkg_resources | ||
rm -rf ./setuptools | ||
|
||
rm -rf ./*.so | ||
zip -r ../"$python_library_zip_filename" ./* | ||
cd .. | ||
zip -r "$python_library_zip_filename" aws-sam-cli-src |
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,29 @@ | ||
# -*- mode: python -*- | ||
block_cipher = None | ||
exe_name = 'sam' | ||
analysis = Analysis(['../../samcli/__main__.py'], | ||
binaries=[], | ||
datas=[], | ||
hiddenimports=[], | ||
hookspath=['./installer/pyinstaller'], | ||
runtime_hooks=[], | ||
excludes=[], | ||
cipher=block_cipher) | ||
pyz = PYZ(analysis.pure, analysis.zipped_data, cipher=block_cipher) | ||
exe = EXE(pyz, | ||
analysis.scripts, | ||
[], | ||
exclude_binaries=True, | ||
name=exe_name, | ||
debug=False, | ||
bootloader_ignore_signals=False, | ||
strip=False, | ||
upx=True, | ||
console=True ) | ||
coll = COLLECT(exe, | ||
analysis.binaries, | ||
analysis.zipfiles, | ||
analysis.datas, | ||
strip=False, | ||
upx=True, | ||
name='sam') |
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,3 +1,3 @@ | ||
# Executable binary builder requirements | ||
setuptools==47.3.2 | ||
pyinstaller==4.2 | ||
pyinstaller==5.3 |
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
SAM CLI version | ||
""" | ||
|
||
__version__ = "1.65.0" | ||
__version__ = "1.66.0" |
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,4 @@ | ||
""" | ||
Expose top level prepare hook | ||
""" | ||
from .main import prepare |
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,3 +1,3 @@ | ||
{ | ||
"app_template_repo_commit": "6c6b6650d194fe70a289c9829a3ce0f825541954" | ||
"app_template_repo_commit": "af09b91b9914b9c8faf248888bde9b7cfdc45937" | ||
} |
35 changes: 35 additions & 0 deletions
35
tests/functional/commands/validate/lib/models/function_with_snapstart.yaml
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,35 @@ | ||
%YAML 1.1 | ||
--- | ||
Parameters: | ||
SnapStartParam: | ||
Type: String | ||
Default: None | ||
|
||
Resources: | ||
SnapStartFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip | ||
Handler: hello.handler | ||
Runtime: python3.9 | ||
SnapStart: | ||
ApplyOn: PublishedVersions | ||
|
||
SnapStartParameterFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip | ||
Handler: hello.handler | ||
Runtime: python3.9 | ||
SnapStart: | ||
ApplyOn: !Ref SnapStartParam | ||
|
||
SnapStartFunctionWithAlias: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/hello.zip | ||
Handler: hello.handler | ||
Runtime: python3.9 | ||
AutoPublishAlias: live | ||
SnapStart: | ||
ApplyOn: PublishedVersions |
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
Oops, something went wrong.