Skip to content

Commit ff76bbc

Browse files
committed
CCM-12616: test deployment
1 parent 590d3df commit ff76bbc

File tree

6 files changed

+73
-19
lines changed

6 files changed

+73
-19
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ version.json
1515
# Don't track ephemeral local build files
1616
target/
1717

18+
# Python build artifacts
19+
*.egg-info/
20+
.eggs/
21+
build/
22+
dist/
23+
1824
# dependencies
1925
node_modules
2026
.node-version

infrastructure/terraform/components/dl/pre.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ npm ci
99
npm run generate-dependencies
1010

1111
npm run lambda-build --workspaces --if-present
12+
13+
# Build Python lambdas
14+
make -C lambdas/mesh-poll package
15+
make -C lambdas/mesh-download package
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
component_name="$1"
5+
6+
rootdir=$(realpath "$(dirname "$0")/../..")
7+
source ${rootdir}/utils/get_version.sh
8+
9+
VERSIONED_ZIP_NAME="NHSD.comms."${component_name}-"${point_version}"".zip"
10+
11+
dist_dir="${PWD}/target/dist"
12+
build_dir="${PWD}/target/python-build"
13+
mkdir -p "${dist_dir}"
14+
rm -rf "${build_dir}"
15+
mkdir -p "${build_dir}"
16+
rm -rf "${dist_dir}/${VERSIONED_ZIP_NAME}"
17+
18+
# Extract internal (file://) and external dependencies from requirements.txt
19+
grep -E '^-e ' requirements.txt | sed 's|^-e ||' > target/internal_requirements.txt || true
20+
grep -vE '^-e ' requirements.txt > target/external_requirements.txt || true
21+
22+
# Install external dependencies (from PyPI)
23+
pip install --platform manylinux2014_x86_64 --only-binary=:all: -r target/external_requirements.txt --target ${build_dir} --python-version 3.13 --implementation cp
24+
25+
# Install internal dependencies (local packages)
26+
if [ -s target/internal_requirements.txt ]; then
27+
while IFS= read -r dep; do
28+
pip install "$dep" --target ${build_dir}
29+
done < target/internal_requirements.txt
30+
fi
31+
32+
for item in src/*; do
33+
basename=$(basename "$item")
34+
if [[ "$basename" != "__tests__" && "$basename" != "venv" && "$basename" != "__pycache__" ]]; then
35+
cp -r "$item" "${build_dir}/"
36+
fi
37+
done
38+
39+
# Construct the build artefact
40+
cd ${build_dir} && zip -r "${dist_dir}/${VERSIONED_ZIP_NAME}" .

lambdas/mesh-download/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ urllib3>=1.26.19,<2.0.0
88
idna>=3.7
99
requests>=2.32.0
1010
pyopenssl>=24.2.1
11-
setuptools>=78.1.1
1211
-e ../../utils/event-publisher-py
1312
-e ../../utils/py-mock-mesh
1413
-e ../../utils/metric-publishers

lambdas/mesh-poll/package_python_lambda.sh

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,26 @@ rm -rf "${build_dir}"
1515
mkdir -p "${build_dir}"
1616
rm -rf "${dist_dir}/${VERSIONED_ZIP_NAME}"
1717

18-
# poetry config virtualenvs.in-project true
19-
20-
# this asserts we are using the right pip+python
21-
poetry install --only-root
22-
source .venv/bin/activate
23-
24-
# now bundle dependencies from lock file
25-
poetry export -f requirements.txt --output target/all_requirements.txt --without dev
26-
grep -v file:// target/all_requirements.txt > target/external_requirements.txt
27-
grep file:// target/all_requirements.txt > target/internal_requirements.txt
28-
pip install --platform manylinux2014_x86_64 --only-binary=:all: -r target/external_requirements.txt --target ${build_dir} --no-deps
29-
pip install -r target/internal_requirements.txt --target ${build_dir} --no-deps
30-
31-
# now bundle application code
32-
pip install . --no-deps --target ${build_dir}
33-
34-
# and construct the build artefact
18+
# Extract internal (file://) and external dependencies from requirements.txt
19+
grep -E '^-e ' requirements.txt | sed 's|^-e ||' > target/internal_requirements.txt || true
20+
grep -vE '^-e ' requirements.txt > target/external_requirements.txt || true
21+
22+
# Install external dependencies (from PyPI)
23+
pip install --platform manylinux2014_x86_64 --only-binary=:all: -r target/external_requirements.txt --target ${build_dir} --python-version 3.13 --implementation cp
24+
25+
# Install internal dependencies (local packages)
26+
if [ -s target/internal_requirements.txt ]; then
27+
while IFS= read -r dep; do
28+
pip install "$dep" --target ${build_dir}
29+
done < target/internal_requirements.txt
30+
fi
31+
32+
for item in src/*; do
33+
basename=$(basename "$item")
34+
if [[ "$basename" != "__tests__" && "$basename" != "venv" && "$basename" != "__pycache__" ]]; then
35+
cp -r "$item" "${build_dir}/"
36+
fi
37+
done
38+
39+
# Construct the build artefact
3540
cd ${build_dir} && zip -r "${dist_dir}/${VERSIONED_ZIP_NAME}" .

lambdas/mesh-poll/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ urllib3>=1.26.19,<2.0.0
77
idna>=3.7
88
requests>=2.32.0
99
pyopenssl>=24.2.1
10-
setuptools>=78.1.1
10+
pydantic>=2.0.0
1111
-e ../../utils/metric-publishers
1212
-e ../../utils/event-publisher-py
1313
-e ../../utils/py-mock-mesh

0 commit comments

Comments
 (0)