Skip to content

Commit 8cccd86

Browse files
Taniya Mathurgudivt
authored andcommitted
Update PyYAML dependency handling across publish scripts and docs
1 parent 202318c commit 8cccd86

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

docs/deployment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ You need to have the following packages installed on your computer:
2626
3. [sam (AWS SAM)](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html)
2727
4. python 3.11 or later
2828
5. A local Docker daemon
29-
6. Python packages for publish.py: `pip install boto3 typer rich botocore setuptools`
29+
6. Python packages for publish.py: `pip install boto3 rich PyYAML botocore setuptools`
3030

3131
For guidance on setting up a development environment, see: [Development Environment Setup Guide on Linux](./setup-development-env-linux.md) or [Development Environment Setup Guide on MacOS](./setup-development-env-macos.md)
3232

publish.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -934,15 +934,6 @@ def _check_requirements_has_idp_common_pkg(self, func_dir):
934934
def _extract_function_name(self, dir_name, template_path):
935935
"""Extract CloudFormation function name from template by matching CodeUri."""
936936
try:
937-
try:
938-
import yaml
939-
except ImportError:
940-
self.console.print("[yellow]PyYAML not found, installing...[/yellow]")
941-
subprocess.run(
942-
[sys.executable, "-m", "pip", "install", "PyYAML"], check=True
943-
)
944-
import yaml
945-
946937
# Create a custom loader that ignores CloudFormation intrinsic functions
947938
class CFLoader(yaml.SafeLoader):
948939
pass

publish.sh

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,19 @@ check_python_version() {
9090
check_and_install_packages() {
9191
print_info "Checking required Python packages..."
9292

93-
# List of required packages (import_name:package_name pairs)
94-
required_packages=(
95-
"typer:typer"
96-
"rich:rich"
97-
"boto3:boto3"
98-
"yaml:PyYAML"
93+
# List of required packages (import_name:package_name)
94+
declare -A required_packages=(
95+
["typer"]="typer"
96+
["rich"]="rich"
97+
["boto3"]="boto3"
98+
["yaml"]="PyYAML"
9999
)
100100
missing_packages=()
101101

102102
# Check each package
103-
for package_pair in "${required_packages[@]}"; do
104-
import_name="${package_pair%%:*}"
105-
package_name="${package_pair##*:}"
103+
for import_name in "${!required_packages[@]}"; do
106104
if ! $PYTHON_CMD -c "import $import_name" >/dev/null 2>&1; then
107-
missing_packages+=("$package_name")
105+
missing_packages+=("${required_packages[$import_name]}")
108106
fi
109107
done
110108

0 commit comments

Comments
 (0)