Skip to content

Commit

Permalink
Merge pull request #401 from solarwinds/NH-87217-support-python-3_12
Browse files Browse the repository at this point in the history
NH-87217 Add Python 3.12 support
  • Loading branch information
tammy-baylis-swi authored Aug 1, 2024
2 parents 183ae46 + 32da6b9 commit 84b8c06
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_publish_lambda_layer_aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ jobs:
artifact-name: solarwinds_apm_lambda_aarch64.zip
component-version: ${{ needs.build_layer_aarch64.outputs.SW_APM_VERSION }}
architecture: arm64
runtimes: "python3.8 python3.9 python3.10 python3.11"
runtimes: "python3.8 python3.9 python3.10 python3.11 python3.12"
publish-dest: ${{ inputs.publish-dest }}
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/build_publish_lambda_layer_x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ jobs:
artifact-name: solarwinds_apm_lambda_x86_64.zip
component-version: ${{ needs.build_layer_x86_64.outputs.SW_APM_VERSION }}
architecture: x86_64
runtimes: "python3.8 python3.9 python3.10 python3.11"
runtimes: "python3.8 python3.9 python3.10 python3.11 python3.12"
publish-dest: ${{ inputs.publish-dest }}
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/run_tox_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-minor: ["8", "9", "10", "11"]
python-minor: ["8", "9", "10", "11", "12"]
apm-env: ["nh-staging", "ao-prod"]
steps:
- uses: actions/checkout@v4
Expand Down
28 changes: 16 additions & 12 deletions .github/workflows/verify_install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,21 @@ jobs:
- py3.9-debian10
- py3.9-debian11
- py3.9-rhel8
- py3.9-ubuntu20.04
- py3.10-alpine3.13
- py3.10-alpine3.16
- py3.10-alpine3.17
- py3.10-amazon2023
- py3.10-debian10
- py3.10-debian11
- py3.10-ubuntu20.04
- py3.10-ubuntu22.04
- py3.11-alpine3.16
- py3.11-alpine3.17
- py3.11-debian10
- py3.11-debian11
- py3.11-ubuntu20.04
- py3.11-ubuntu22.04
- py3.12-alpine3.19
- py3.12-alpine3.20
- py3.12-debian11
- py3.12-debian12
arch:
- x64
- arm64
Expand Down Expand Up @@ -103,8 +103,6 @@ jobs:
image: python:3.9-bullseye
- hostname: py3.9-rhel8
image: registry.fedoraproject.org/f33/python3
- hostname: py3.9-ubuntu20.04
image: ubuntu:20.04
- hostname: py3.10-alpine3.13
image: python:3.10-alpine3.13
- hostname: py3.10-alpine3.16
Expand All @@ -117,8 +115,6 @@ jobs:
image: python:3.10-buster
- hostname: py3.10-debian11
image: python:3.10-bullseye
- hostname: py3.10-ubuntu20.04
image: ubuntu:20.04
- hostname: py3.10-ubuntu22.04
image: ubuntu:22.04
- hostname: py3.11-alpine3.16
Expand All @@ -129,10 +125,14 @@ jobs:
image: python:3.11-buster
- hostname: py3.11-debian11
image: python:3.11-bullseye
- hostname: py3.11-ubuntu20.04
image: ubuntu:20.04
- hostname: py3.11-ubuntu22.04
image: ubuntu:22.04
- hostname: py3.12-alpine3.19
image: python:3.12-alpine3.19
- hostname: py3.12-alpine3.20
image: python:3.12-alpine3.20
- hostname: py3.12-debian11
image: python:3.12-bullseye
- hostname: py3.12-debian12
image: python:3.12-bookworm
# Note: JavaScript Actions (checkout) in Alpine only supported in x64
exclude:
- hostname: py3.8-alpine3.12
Expand All @@ -157,6 +157,10 @@ jobs:
arch: arm64
- hostname: py3.11-alpine3.17
arch: arm64
- hostname: py3.12-alpine3.19
arch: arm64
- hostname: py3.12-alpine3.20
arch: arm64
container:
image: "${{ matrix.image }}"
options: --hostname "${{ matrix.hostname }}"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ docker-compose run aarch64

### Regression Tests

Automated testing of this repo uses [tox](https://tox.readthedocs.io) and runs in Python 3.8, 3.9, 3.10, and/or 3.11 because these are the versions supported by [OTel Python](https://github.com/open-telemetry/opentelemetry-python/blob/main/tox.ini). Testing can be run inside a build container which provides all dependencies and a compiled C-extension. Here is how to set up then run unit and integration tests locally:
Automated testing of this repo uses [tox](https://tox.readthedocs.io) and runs in Python 3.8, 3.9, 3.10, 3.11 and/or 3.12 because these are the versions supported by [OTel Python](https://github.com/open-telemetry/opentelemetry-python/blob/main/tox.ini). Testing can be run inside a build container which provides all dependencies and a compiled C-extension. Here is how to set up then run unit and integration tests locally:

1. Create and run a Docker build container as described above.
2. Inside the build container: `make wrapper`. This downloads the version of a C/C++ dependency defined in `extension/VERSION` from SolarWinds Cloud and builds SWIG bindings.
Expand Down
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ check-sdist-local:
# in the corresponding repo of the Docker images: https://github.com/pypa/manylinux#example.
manylinux-wheels: wrapper
@echo -e "Generating python agent package any-linux wheels for 64 bit systems"
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311; do /opt/python/$${PYBIN}/bin/pip -v wheel . -w ./tmp_dist/ --no-deps; done
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip -v wheel . -w ./tmp_dist/ --no-deps; done
@echo -e "Tagging wheels with $(wheel_tag)"
@set -e; for whl in ./tmp_dist/*.whl; do auditwheel repair --plat $(wheel_tag) "$$whl" -w ./dist/; done
@rm -rf ./tmp_dist
Expand All @@ -194,17 +194,17 @@ install-lambda-modules:
@echo -e "Install upstream dependencies to include in layer"
@/opt/python/cp38-cp38/bin/pip3.8 install -t ${target_dir}/python -r lambda/requirements.txt
@echo -e "Install other version-specific .so files for deps"
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311; do /opt/python/$${PYBIN}/bin/pip install -t ${target_dir}/$${PYBIN} -r lambda/requirements-so.txt; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311; do cp ${target_dir}/$${PYBIN}/charset_normalizer/*.so ${target_dir}/python/charset_normalizer/ && cp ${target_dir}/$${PYBIN}/grpc/_cython/*.so ${target_dir}/python/grpc/_cython/ && cp ${target_dir}/$${PYBIN}/wrapt/*.so ${target_dir}/python/wrapt/; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311; do rm -rf ${target_dir}/$${PYBIN} ; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/pip install -t ${target_dir}/$${PYBIN} -r lambda/requirements-so.txt; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do cp ${target_dir}/$${PYBIN}/charset_normalizer/*.so ${target_dir}/python/charset_normalizer/ && cp ${target_dir}/$${PYBIN}/grpc/_cython/*.so ${target_dir}/python/grpc/_cython/ && cp ${target_dir}/$${PYBIN}/wrapt/*.so ${target_dir}/python/wrapt/; done
@set -e; for PYBIN in cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do rm -rf ${target_dir}/$${PYBIN} ; done
@echo -e "Install upstream dependencies without deps to include in layer"
@/opt/python/cp38-cp38/bin/pip3.8 install -t ${target_dir}/nodeps -r lambda/requirements-nodeps.txt --no-deps
@echo -e "Install solarwinds_apm to be packed up in zip archive to target directory."
@/opt/python/cp38-cp38/bin/pip3.8 install . -t ${target_dir}/nodeps --no-deps
@echo -e "Removing non-lambda C-extension library files generated by pip install under target directory."
@rm -rf ${target_dir}/nodeps/solarwinds_apm/extension/*.so*
@echo -e "Building AWS Lambda version of C-extensions for all supported Python versions in target directory."
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311; do /opt/python/$${PYBIN}/bin/python setup.py build_ext -b ${target_dir}/nodeps; done
@set -e; for PYBIN in cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312; do /opt/python/$${PYBIN}/bin/python setup.py build_ext -b ${target_dir}/nodeps; done
@echo -e "Copying AWS Lambda specific Oboe library liboboe-1.0-lambda-${platform}.so into target directory."
@cp solarwinds_apm/extension/liboboe-1.0-lambda-${platform}.so ${target_dir}/nodeps/solarwinds_apm/extension/liboboe.so
@echo -e "Moving no-deps dependencies, needed for full opentelemetry/instrumentation path"
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Typing :: Typed",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
Expand Down
2 changes: 1 addition & 1 deletion solarwinds_apm/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.2.0.0"
__version__ = "2.2.0.1"
48 changes: 8 additions & 40 deletions tests/docker/install/_helper_run_install_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,10 @@ echo "Installing test dependencies for Python $python_version on $pretty_name"

elif grep Ubuntu /etc/os-release; then
ubuntu_version=$(grep VERSION_ID /etc/os-release | sed 's/VERSION_ID="//' | sed 's/"//')
if [ "$ubuntu_version" = "18.04" ] || [ "$ubuntu_version" = "20.04" ]; then
if [ "$ubuntu_version" = "18.04" ] || [ "$ubuntu_version" = "20.04" ] || [ "$ubuntu_version" = "22.04" ] || [ "$ubuntu_version" = "24.04" ]; then
apt-get update -y
TZ=America
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
if [ "$python_version" = "3.10" ] || [ "$python_version" = "3.11" ]; then
# py3.10,3.11 not currently on main apt repo for ubuntu 18/20 so use deadsnakes
apt-get install -y software-properties-common
add-apt-repository ppa:deadsnakes/ppa -y
apt-get install -y \
python3 \
python3-distutils \
python3-dev \
python3-setuptools \
build-essential \
unzip \
wget \
curl
update-alternatives --install /usr/bin/python python "/usr/bin/python3" 1
else
apt-get install -y \
"python$python_version" \
"python$python_version-distutils" \
"python$python_version-dev" \
python3-setuptools \
build-essential \
unzip \
wget \
curl
update-alternatives --install /usr/bin/python python "/usr/bin/python$python_version" 1
fi

elif [ "$ubuntu_version" = "22.04" ]; then
apt-get update -y
TZ=America
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

apt-get install -y \
"python$python_version" \
"python$python_version-distutils" \
Expand All @@ -105,18 +73,18 @@ echo "Installing test dependencies for Python $python_version on $pretty_name"
curl
update-alternatives --install /usr/bin/python python "/usr/bin/python$python_version" 1

# Make sure we don't install py3.6's pip on ubuntu
# Official get-pip documentation:
# https://pip.pypa.io/en/stable/installation/#get-pip-py
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install --upgrade pip >/dev/null

else
echo "ERROR: Testing on Ubuntu <18.04 not supported."
exit 1
fi

# Make sure we don't install py3.6's pip on ubuntu
# Official get-pip documentation:
# https://pip.pypa.io/en/stable/installation/#get-pip-py
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install --upgrade pip >/dev/null

elif grep "Amazon Linux" /etc/os-release; then
yum update -y
if grep "Amazon Linux 2023" /etc/os-release; then
Expand Down
56 changes: 30 additions & 26 deletions tests/docker/install/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,6 @@ services:
environment:
<< : *envvars-install-test

py3.9-install-ubuntu20.04:
hostname: "py3.9-ubuntu20.04"
image: "ubuntu:20.04"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.9-install-centos8:
hostname: "py3.9-centos8"
image: "centos:8"
Expand Down Expand Up @@ -177,13 +170,6 @@ services:
environment:
<< : *envvars-install-test

py3.10-install-ubuntu20.04:
hostname: "py3.10-ubuntu20.04"
image: "ubuntu:20.04"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.10-install-ubuntu22.04:
hostname: "py3.10-ubuntu22.04"
image: "ubuntu:22.04"
Expand Down Expand Up @@ -230,30 +216,48 @@ services:
environment:
<< : *envvars-install-test

py3.11-install-ubuntu20.04:
hostname: "py3.11-ubuntu20.04"
image: "ubuntu:20.04"
py3.11-install-alpine3.16:
hostname: "py3.11-alpine3.16"
image: "python:3.11-alpine3.16"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.11-install-ubuntu22.04:
hostname: "py3.11-ubuntu22.04"
image: "ubuntu:22.04"
py3.11-install-alpine3.17:
hostname: "py3.11-alpine3.17"
image: "python:3.11-alpine3.17"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.11-install-alpine3.16:
hostname: "py3.11-alpine3.16"
image: "python:3.11-alpine3.16"
#--------------------------------------------------------------------
# Python 3.12
#--------------------------------------------------------------------

py3.12-install-debian11:
hostname: "py3.12-debian11"
image: "python:3.12-bullseye"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.11-install-alpine3.17:
hostname: "py3.11-alpine3.17"
image: "python:3.11-alpine3.17"
py3.12-install-debian12:
hostname: "py3.12-debian12"
image: "python:3.12-bookworm"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.12-install-alpine3.19:
hostname: "py3.12-alpine3.19"
image: "python:3.12-alpine3.19"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test

py3.12-install-alpine3.20:
hostname: "py3.12-alpine3.20"
image: "python:3.12-alpine3.20"
<< : [*command-install-test, *workdir, *volumes-codebase]
environment:
<< : *envvars-install-test
22 changes: 11 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
skipsdist = True
skip_missing_interpreters = True
envlist =
py3{8,9,10,11}-ao-prod
py3{8,9,10,11}-nh-staging
py3{8,9,10,11}-lambda
py3{8,9,10,11,12}-ao-prod
py3{8,9,10,11,12}-nh-staging
py3{8,9,10,11,12}-lambda
lint

[testenv]
Expand All @@ -15,31 +15,31 @@ allowlist_externals = echo
deps =
-rdev-requirements.txt
commands_pre =
py3{8,9,10,11}: pip install --upgrade pip
py3{8,9,10,11}: pip install -Ie {toxinidir}
py3{8,9,10,11,12}: pip install --upgrade pip
py3{8,9,10,11,12}: pip install -Ie {toxinidir}
commands =
pytest {posargs}

[testenv:py3{8,9,10,11}-ao-prod]
[testenv:py3{8,9,10,11,12}-ao-prod]
changedir = tests
setenv =
SW_APM_COLLECTOR = collector.appoptics.com
SW_APM_SERVICE_KEY = foo-bar:service-key
[testenv:py3{8,9,10,11}-nh-staging]
[testenv:py3{8,9,10,11,12}-nh-staging]
changedir = tests
setenv =
SW_APM_COLLECTOR = apm.collector.st-ssp.solarwinds.com
SW_APM_SERVICE_KEY = foo-bar:service-key

[testenv:py3{8,9,10,11}-lambda]
[testenv:py3{8,9,10,11,12}-lambda]
changedir = lambda/tests
commands_pre =
py3{8,9,10,11}-lambda: pip install -r requirements.txt
py3{8,9,10,11,12}-lambda: pip install -r requirements.txt

[testenv:py3{8,9,10,11}-lambda-gh]
[testenv:py3{8,9,10,11,12}-lambda-gh]
changedir = lambda/tests
commands_pre =
py3{8,9,10,11}-lambda: pip install -r requirements.txt
py3{8,9,10,11,12}-lambda: pip install -r requirements.txt

[testenv:lint]
basepython: python3.9
Expand Down

0 comments on commit 84b8c06

Please sign in to comment.