Skip to content

Commit 7fd33d4

Browse files
authored
feat: Remove requests and all its dependencies. (#547)
1 parent fa21836 commit 7fd33d4

File tree

8 files changed

+1017
-13
lines changed

8 files changed

+1017
-13
lines changed

Dockerfile

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ RUN rm -rf ./python/lib/$runtime/site-packages/botocore*
2222
RUN rm -rf ./python/lib/$runtime/site-packages/setuptools
2323
RUN rm -rf ./python/lib/$runtime/site-packages/jsonschema/tests
2424
RUN find . -name 'libddwaf.so' -delete
25-
RUN rm -rf ./python/lib/$runtime/site-packages/urllib3*
26-
RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so
25+
# Comment this line out for now since ddtrace now tries to import it
26+
#RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_taint_tracking/*.so
2727
RUN rm ./python/lib/$runtime/site-packages/ddtrace/appsec/_iast/_stacktrace*.so
2828
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/libdd_wrapper*.so
2929
RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/ddup/_ddup.*.so
@@ -32,6 +32,14 @@ RUN rm ./python/lib/$runtime/site-packages/ddtrace/internal/datadog/profiling/st
3232
RUN find ./python/lib/$runtime/site-packages/*.dist-info -not -name "entry_points.txt" -type f -delete
3333
RUN find ./python/lib/$runtime/site-packages -type d -empty -delete
3434

35+
# Remove requests and dependencies
36+
RUN rm -rf \
37+
./python/lib/$runtime/site-packages/requests* \
38+
./python/lib/$runtime/site-packages/urllib3* \
39+
./python/lib/$runtime/site-packages/certifi* \
40+
./python/lib/$runtime/site-packages/idna* \
41+
./python/lib/$runtime/site-packages/charset_normalizer*
42+
3543
# Precompile all .pyc files and remove .py files. This speeds up load time.
3644
# Compile with optimization level 2 (-OO) and PYTHONNODEBUGRANGES=1 to redtce
3745
# size of .pyc files.

ci/input_files/build.yaml.tpl

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ integration-test ({{ $runtime.name }}-{{ $runtime.arch }}):
9898
- *install-node
9999
- EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source ./ci/get_secrets.sh
100100
- yarn global add serverless@^3.38.0 --prefix /usr/local
101+
- yarn global add serverless-python-requirements@^6.1.1 --prefix /usr/local
101102
- cd integration_tests && yarn install && cd ..
102103
script:
103104
- RUNTIME_PARAM={{ $runtime.python_version }} ARCH={{ $runtime.arch }} ./scripts/run_integration_tests.sh

poetry.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ classifiers = [
2525

2626
[tool.poetry.dependencies]
2727
python = ">=3.8.0,<4"
28-
datadog = ">=0.41.0,<1.0.0"
28+
datadog = ">=0.51.0,<1.0.0"
2929
wrapt = "^1.11.2"
3030
ddtrace = ">=2.17.0"
3131
ujson = ">=5.9.0"

tests/integration/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"devDependencies": {
3-
"serverless-plugin-datadog": "^2.18.0"
3+
"serverless-plugin-datadog": "^2.18.0",
4+
"serverless-python-requirements": "^6.1.1"
45
}
56
}

tests/integration/requirements.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
certifi==2024.12.14
2+
charset-normalizer==3.4.1
3+
idna==3.10
4+
requests==2.32.3

tests/integration/serverless.yml

+15-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ provider:
2020
iam:
2121
# IAM permissions require that all functions are deployed with this role
2222
role: "arn:aws:iam::425362996713:role/serverless-integration-test-lambda-role"
23+
layers:
24+
- { Ref: PythonLambdaLayer }
25+
- { Ref: PythonRequirementsLambdaLayer }
26+
27+
plugins:
28+
- serverless-python-requirements
29+
30+
custom:
31+
pythonRequirements:
32+
pythonBin: python3
33+
pipCmdExtraArgs:
34+
- --no-deps # install just requests
35+
layer:
36+
compatibleRuntimes:
37+
- ${env:SERVERLESS_RUNTIME}
2338

2439
layers:
2540
python:
@@ -32,8 +47,6 @@ functions:
3247
name: integration-tests-python-${sls:stage}-async-metrics_${env:RUNTIME}
3348
handler: handle.handle
3449
runtime: ${env:SERVERLESS_RUNTIME}
35-
layers:
36-
- { Ref: PythonLambdaLayer }
3750
environment:
3851
DD_FLUSH_TO_LOG: true
3952

@@ -42,5 +55,3 @@ functions:
4255
name: integration-tests-python-${sls:stage}-sync-metrics_${env:RUNTIME}
4356
handler: handle.handle
4457
runtime: ${env:SERVERLESS_RUNTIME}
45-
layers:
46-
- { Ref: PythonLambdaLayer }

0 commit comments

Comments
 (0)