Skip to content

Commit 8ac8962

Browse files
committed
Merge branch 'master' into darcy.rayner/add-badge-to-readme
2 parents 3c1f47e + 6bd1672 commit 8ac8962

File tree

10 files changed

+118
-23
lines changed

10 files changed

+118
-23
lines changed

.circleci/config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 2.1
2+
3+
jobs:
4+
verify_build:
5+
working_directory: ~/repo
6+
docker:
7+
- image: circleci/python:<< parameters.python >>
8+
parameters:
9+
python:
10+
type: string
11+
steps:
12+
- checkout
13+
- restore_cache:
14+
keys:
15+
- v1-dependencies-<< parameters.python >>-{{ checksum "setup.py" }}
16+
# fallback to using the latest cache if no exact match is found
17+
- v1-dependencies-<< parameters.python >>--
18+
- run:
19+
name: Install Dependencies
20+
command: |
21+
pip install virtualenv
22+
virtualenv venv
23+
source venv/bin/activate
24+
pip install .[dev]
25+
- run:
26+
name: Run Unit Tests
27+
command: |
28+
source venv/bin/activate
29+
nose2 -v
30+
- run:
31+
name: Lint
32+
command: |
33+
source venv/bin/activate
34+
flake8 datadog_lambda/
35+
36+
- save_cache:
37+
paths:
38+
- ./venv
39+
key: v1-dependencies-<< parameters.python >>-{{ checksum "setup.py" }}
40+
41+
workflows:
42+
python-v2.7:
43+
jobs:
44+
- verify_build:
45+
python: "2.7"
46+
47+
python-v3.6:
48+
jobs:
49+
- verify_build:
50+
python: "3.6"
51+
52+
python-v3.7:
53+
jobs:
54+
- verify_build:
55+
python: "3.7"

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ ARG runtime
77
RUN mkdir -p /build/python/lib/$runtime/site-packages
88
WORKDIR /build
99

10-
# Install dependencies
11-
COPY requirements.txt requirements.txt
12-
RUN pip install -r requirements.txt -t ./python/lib/$runtime/site-packages
13-
14-
# Install datadog_lambda
15-
COPY datadog_lambda ./python/lib/$runtime/site-packages/datadog_lambda
10+
# Install datadog_lambda and dependencies from local
11+
COPY . .
12+
RUN pip install . -t ./python/lib/$runtime/site-packages
1613

1714
# Remove *.pyc files
1815
RUN find ./python/lib/$runtime/site-packages -name \*.pyc -delete

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ Replace `<AWS_REGION>` with the AWS region where your Lambda function is publish
2121
arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Python37:1
2222
```
2323

24+
### PyPI
25+
26+
When developing your Lambda function locally where AWS Layer doesn't work, the Datadog Lambda layer can be installed from [PyPI](https://pypi.org/project/datadog-lambda/) by `pip install datadog-lambda` or adding `datadog-lambda` to your project's `requirements.txt`.
27+
28+
The minor version of the `datadog-lambda` package always match the layer version. E.g., datadog-lambda v0.5.0 matches the content in layer version 5.
29+
30+
31+
### Environment Variables
32+
2433
The Datadog API must be defined as an environment variable via [AWS CLI](https://docs.aws.amazon.com/lambda/latest/dg/env_variables.html) or [Serverless Framework](https://serverless-stack.com/chapters/serverless-environment-variables.html):
2534

2635
- DD_API_KEY or DD_KMS_API_KEY (if encrypted by KMS)

datadog_lambda/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
__version__ = "4"
1+
# The minor version corresponds to the Lambda layer version.
2+
# E.g.,, version 0.5.0 gets packaged into layer version 5.
3+
__version__ = '0.5.0'

requirements-dev.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

scripts/pypi.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
# Unless explicitly stated otherwise all files in this repository are licensed
4+
# under the Apache License Version 2.0.
5+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
6+
# Copyright 2019 Datadog, Inc.
7+
8+
# Builds the lambda layer and upload to Pypi
9+
set -e
10+
11+
# Clear previously built distributions
12+
if [ -d "dist" ]; then
13+
echo "Removing folder 'dist' to clear previously built distributions"
14+
rm -rf dist;
15+
fi
16+
17+
# Install build tools
18+
pip install --upgrade setuptools wheel twine
19+
20+
# Build distributions
21+
python setup.py sdist bdist_wheel
22+
23+
# Upload distributions
24+
python -m twine upload dist/*

scripts/run_tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ do
1515
echo "Running tests against python${python_version}"
1616
docker build -t datadog-lambda-layer-python-test:$python_version \
1717
-f tests/Dockerfile . \
18-
--quiet \
1918
--build-arg python_version=$python_version
2019
docker run -v `pwd`:/datadog-lambda-layer-python \
2120
-w /datadog-lambda-layer-python \

setup.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
from os import path
33
from io import open
44

5+
from datadog_lambda import __version__
6+
57
here = path.abspath(path.dirname(__file__))
68

79
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
810
long_description = f.read()
911

1012
setup(
11-
name='ddlambda',
12-
version='0.2.0',
13+
name='datadog_lambda',
14+
version=__version__,
1315
description='The Datadog AWS Lambda Layer',
1416
long_description=long_description,
1517
long_description_content_type='text/markdown',
@@ -24,4 +26,18 @@
2426
keywords='datadog aws lambda layer',
2527
packages=['datadog_lambda'],
2628
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4',
29+
install_requires=[
30+
'aws-xray-sdk==2.4.2',
31+
'datadog==0.28.0',
32+
'wrapt==1.11.1',
33+
'setuptools==40.8.0',
34+
'boto3==1.9.160'
35+
],
36+
extras_require={
37+
'dev': [
38+
'nose2==0.9.1',
39+
'flake8==3.7.7',
40+
'requests==2.21.0'
41+
]
42+
}
2743
)

tests/Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ FROM python:$python_version
33

44
ENV PYTHONDONTWRITEBYTECODE True
55

6-
COPY .flake8 .flake8
7-
COPY requirements.txt requirements.txt
8-
COPY requirements-dev.txt requirements-dev.txt
9-
RUN pip install -r requirements.txt
10-
RUN pip install -r requirements-dev.txt
6+
RUN mkdir -p /test
7+
WORKDIR /test
8+
9+
# Install datadog-lambda with dev dependencies from local
10+
COPY . .
11+
RUN pip install .[dev]

0 commit comments

Comments
 (0)