Skip to content

Commit 4bf927f

Browse files
ci(build-deploy): build python deb/rpm for autoinjection (#5973)
This PR adds support to build .deb and .rpm packages for dd-trace-py. This is needed to support auto injection initiatives. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines) are followed. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). ## Reviewer Checklist - [x] Title is accurate. - [x] No unnecessary changes are introduced. - [x] Description motivates each change. - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [x] Testing strategy adequately addresses listed risk(s). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] Release note makes sense to a user of the library. - [x] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment.
1 parent 3982879 commit 4bf927f

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

.gitlab-ci.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
stages:
2+
- package
23
- deploy
34
- benchmarks
45
- benchmarks-pr-comment
56

6-
include: ".gitlab/benchmarks.yml"
7+
include:
8+
- remote: https://gitlab-templates.ddbuild.io/apm/packaging.yml
9+
- local: ".gitlab/benchmarks.yml"
710

811
variables:
912
DOWNSTREAM_BRANCH:
@@ -12,11 +15,27 @@ variables:
1215
DOWNSTREAM_MBP_BRANCH:
1316
value: "dd-trace-py"
1417
description: "Run a specific relenv-microbenchmarking-platform branch downstream"
15-
18+
PYTHON_PACKAGE_VERSION:
19+
description: "Version to build for .deb and .rpm. Must be already published in PyPi"
1620

1721
.common: &common
1822
tags: [ "runner:main", "size:large" ]
1923

24+
package:
25+
extends: .package
26+
rules:
27+
- if: $PYTHON_PACKAGE_VERSION
28+
when: on_success
29+
- if: '$CI_COMMIT_TAG =~ /^v.*/'
30+
when: on_success
31+
script:
32+
- ../.gitlab/build-deb-rpm.sh
33+
34+
.release-package:
35+
stage: deploy
36+
variables:
37+
PRODUCT_NAME: auto_inject-python
38+
2039
deploy_to_reliability_env:
2140
stage: deploy
2241
rules:

.gitlab/build-deb-rpm.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
if [ -n "$CI_COMMIT_TAG" ] && [ -z "$PYTHON_PACKAGE_VERSION" ]; then
4+
PYTHON_PACKAGE_VERSION=${CI_COMMIT_TAG##v}
5+
fi
6+
7+
echo -n $PYTHON_PACKAGE_VERSION > auto_inject-python.version
8+
9+
source common_build_functions.sh
10+
11+
# Download the megawheel
12+
mkdir -p dd-trace.dir/lib
13+
14+
# Install known compatible pip as default version shipped in Ubuntu (20.0.2)
15+
# does not work.
16+
python3 -m pip install -U "pip>=22.0"
17+
python3 -m pip install packaging
18+
19+
echo `pwd`
20+
21+
../lib-injection/dl_wheels.py \
22+
--python-version=3.11 \
23+
--python-version=3.10 \
24+
--python-version=3.9 \
25+
--python-version=3.8 \
26+
--python-version=3.7 \
27+
--ddtrace-version=$PYTHON_PACKAGE_VERSION \
28+
--arch x86_64 \
29+
--arch aarch64 \
30+
--platform musllinux_1_1 \
31+
--platform manylinux2014 \
32+
--output-dir dd-trace.dir/lib \
33+
--verbose
34+
35+
cp ../lib-injection/sitecustomize.py dd-trace.dir/lib/
36+
37+
cp auto_inject-python.version dd-trace.dir/lib/version
38+
39+
fpm_wrapper "datadog-apm-library-python" "$PYTHON_PACKAGE_VERSION" \
40+
--input-type dir \
41+
--url "https://github.com/DataDog/dd-trace-py" \
42+
--description "Datadog APM client library for python" \
43+
--license "BSD-3-Clause" \
44+
--chdir=dd-trace.dir/lib \
45+
--prefix "$LIBRARIES_INSTALL_BASE/python" \
46+
.=.

0 commit comments

Comments
 (0)