8000 Publish datadog_lambda to PyPI · DataDog/datadog-lambda-python@cb29a0a · GitHub
[go: up one dir, main page]

Skip to content

Commit cb29a0a

Browse files
committed
Publish datadog_lambda to PyPI
1 parent 8fc9e9b commit cb29a0a

File tree

9 files changed

+63
-23
lines changed

9 files changed

+63
-23
lines changed

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
@@ -16,6 +16,15 @@ Replace `<AWS_REGION>` with the AWS region where your Lambda function is publish
1616
arn:aws:lambda:us-east-1:464622532012:layer:Datadog-Python37:1
1717
```
1818

19+
### PyPI
20+
21+
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`.
22+
23+
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.
24+
25+
26+
### Environment Variables
27+
1928
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):
2029

2130
* 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)
0