From 96fa34d8ce4c2e166ecfc1425eb2ba8469d803ea Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Mon, 11 Dec 2023 18:19:28 +0200 Subject: [PATCH] Update to 1.39.1 (fedora#2238739) - Use bcond for conditionally excluded integrations, sqlalchemy during tests, and for network-related tests - Verify all extras against setup.py - Improve testing by removing ignores for tests that pass and adding comments with reasons for ignores - Remove patch for Python 3.12 which is unnecessary now - Add new integrations (extras) --- .gitignore | 1 + 0001-tests-add-support-for-Python-3.12.patch | 80 ----- python-sentry-sdk.spec | 316 +++++++++++++------ sources | 2 +- 4 files changed, 222 insertions(+), 177 deletions(-) delete mode 100644 0001-tests-add-support-for-Python-3.12.patch diff --git a/.gitignore b/.gitignore index 1bc420b..e2c2715 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ /sentry-python-1.27.0.tar.gz /sentry-python-1.28.0.tar.gz /sentry-python-1.29.2.tar.gz +/sentry-python-1.39.1.tar.gz diff --git a/0001-tests-add-support-for-Python-3.12.patch b/0001-tests-add-support-for-Python-3.12.patch deleted file mode 100644 index 38e17d1..0000000 --- a/0001-tests-add-support-for-Python-3.12.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 5b6ab04064d1512497592e461354e9d94e5f7d04 Mon Sep 17 00:00:00 2001 -From: Roman Inflianskas -Date: Thu, 13 Jul 2023 11:08:43 +0300 -Subject: [PATCH] tests: add support for Python 3.12 - ---- - tests/integrations/logging/test_logging.py | 13 ++++++++++++- - tests/test_scrubber.py | 3 +++ - 2 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/tests/integrations/logging/test_logging.py b/tests/integrations/logging/test_logging.py -index de1c55e2..f0edef58 100644 ---- a/tests/integrations/logging/test_logging.py -+++ b/tests/integrations/logging/test_logging.py -@@ -3,6 +3,7 @@ import sys - - import pytest - import logging -+import platform - import warnings - - from sentry_sdk.integrations.logging import LoggingIntegration, ignore_logger -@@ -61,9 +62,15 @@ def test_logging_extra_data(sentry_init, capture_events): - (event,) = events - - assert event["level"] == "fatal" -+ if platform.python_version_tuple() >= ("3", "12"): -+ assert event["extra"].pop("taskName") == None - assert event["extra"] == {"bar": 69} -+ data = { -+ "foo": 42, -+ **({"taskName": None} if platform.python_version_tuple() >= ("3", "12") else {}) -+ } - assert any( -- crumb["message"] == "bread" and crumb["data"] == {"foo": 42} -+ crumb["message"] == "bread" and crumb["data"] == data - for crumb in event["breadcrumbs"]["values"] - ) - -@@ -76,6 +83,8 @@ def test_logging_extra_data_integer_keys(sentry_init, capture_events): - - (event,) = events - -+ if platform.python_version_tuple() >= ("3", "12"): -+ assert event["extra"].pop("taskName") == None - assert event["extra"] == {"1": 1} - - -@@ -184,6 +193,8 @@ def test_logging_captured_warnings(sentry_init, capture_events, recwarn): - ) - events = capture_events() - -+ warnings.filterwarnings("ignore", category=DeprecationWarning) -+ - logging.captureWarnings(True) - warnings.warn("first") - warnings.warn("second") -diff --git a/tests/test_scrubber.py b/tests/test_scrubber.py -index 4b2dfff4..9b05e4c9 100644 ---- a/tests/test_scrubber.py -+++ b/tests/test_scrubber.py -@@ -1,5 +1,6 @@ - import sys - import logging -+import platform - - from sentry_sdk import capture_exception, capture_event, start_transaction, start_span - from sentry_sdk.utils import event_from_exception -@@ -100,6 +101,8 @@ def test_breadcrumb_extra_scrubbing(sentry_init, capture_events): - assert event["extra"]["bar"] == 69 - assert event["extra"]["auth"] == "[Filtered]" - -+ if platform.python_version_tuple() >= ("3", "12"): -+ assert event["breadcrumbs"]["values"][0]["data"].pop("taskName") == None - assert event["breadcrumbs"]["values"][0]["data"] == { - "foo": 42, - "password": "[Filtered]", --- -2.41.0 - diff --git a/python-sentry-sdk.spec b/python-sentry-sdk.spec index aacb272..5223949 100644 --- a/python-sentry-sdk.spec +++ b/python-sentry-sdk.spec @@ -1,57 +1,69 @@ +# Excluded extras/integrations +# Lines below are in `code: comment` format, where `code` is used for +# easier navigation in text editors and linking + +# no_ariadne: ariadne not packaged yet +# no_arq: arq not packaged yet +# no_beam: beam not packaged yet +# no_chalice: chalice not packaged yet +# no_clickhouse_driver: clickhouse_driver not packaged yet +# no_gql: gql not packaged yet +# no_huey: huey not packaged yet +# no_loguru: loguru not packaged yet +# no_pyspark: pyspark not packaged yet +# no_quart: quart not packaged yet +# no_sanic: sanic not packaged yet +# no_starlite: starlite not packaged yet +# no_strawberry: strawberry not packaged yet +# no_trytond: trytond not packaged yet + +# Conditionally excluded extras +# opentelemetry-experimental requires opentelemetry-contrib libraries of 0.40b0 version +%bcond opentelemetry_experimental %[%{?fedora} >= 40] + +%bcond network_tests 0 + +# TODO: +# sqlalchemy installed during tests causes many failures. +# It is used by sentry_sdk/db/explain_plan/sqlalchemy.py and is optional, drop it. +%bcond sqlalchemy_during_tests 0 + Name: python-sentry-sdk -Version: 1.29.2 -Release: 2%{?dist} +Version: 1.39.1 +Release: 1%{?dist} Summary: The new Python SDK for Sentry.io License: MIT URL: https://sentry.io/for/python/ Source0: https://github.com/getsentry/sentry-python/archive/%{version}/sentry-python-%{version}.tar.gz -Patch0: 0001-tests-add-support-for-Python-3.12.patch BuildArch: noarch BuildRequires: python3-devel -BuildRequires: python3dist(certifi) -BuildRequires: python3dist(wheel) -# Use Fedora versions of testing dependencies + pytest instead of pinned versions in upstream + tox -BuildRequires: python3dist(aiohttp) -BuildRequires: python3dist(asttokens) -BuildRequires: python3dist(blinker) BuildRequires: python3dist(botocore) -BuildRequires: python3dist(bottle) -BuildRequires: python3dist(celery) -BuildRequires: python3dist(django) +BuildRequires: python3dist(certifi) BuildRequires: python3dist(djangorestframework) -BuildRequires: python3dist(executing) -BuildRequires: python3dist(fastapi) -BuildRequires: python3dist(flask) -BuildRequires: python3dist(flask-login) BuildRequires: python3dist(gevent) -BuildRequires: python3dist(grpcio) -BuildRequires: python3dist(httpx) +BuildRequires: python3dist(graphene) BuildRequires: python3dist(jsonschema) -BuildRequires: python3dist(mock) -BuildRequires: python3dist(opentelemetry-distro) BuildRequires: python3dist(protobuf) -BuildRequires: python3dist(psycopg2) -BuildRequires: python3dist(pure-eval) -BuildRequires: python3dist(pymongo) +BuildRequires: python3dist(psycopg) BuildRequires: python3dist(pyramid) -BuildRequires: python3dist(pyrsistent) BuildRequires: python3dist(pysocks) BuildRequires: python3dist(pytest) BuildRequires: python3dist(pytest-aiohttp) BuildRequires: python3dist(pytest-asyncio) -BuildRequires: python3dist(pytest-cov) +BuildRequires: python3dist(pytest-django) BuildRequires: python3dist(pytest-forked) BuildRequires: python3dist(pytest-localserver) BuildRequires: python3dist(python-multipart) BuildRequires: python3dist(requests) BuildRequires: python3dist(responses) -BuildRequires: python3dist(rq) -BuildRequires: python3dist(sqlalchemy) -BuildRequires: python3dist(starlette) -BuildRequires: python3dist(tornado) -BuildRequires: python3dist(werkzeug) +BuildRequires: python3dist(wheel) +%if %{with network_tests} +BuildRequires: python3dist(boto3) +BuildRequires: python3dist(httpx) +BuildRequires: python3dist(pytest-httpx) +%endif # For re-generating protobuf bindings BuildRequires: protobuf-compiler @@ -69,41 +81,62 @@ Summary: %{summary} %description -n python3-sentry-sdk %_description +%global extras_excluded %{shrink: + arq + beam + chalice + clickhouse-driver + huey + loguru + %{!?with_opentelemetry_experimental:opentelemetry-experimental} + pyspark + quart + sanic + starlite + %{nil}} -# Dependencies for quart, sanic, beam, pyspark, chalice, starlite, huey, arq, loguru extras are not yet in Fedora -# falcon version >= 3.0 is not yet supported => skipping this extra as well -%global _extras %{expand: - flask - bottle - django - celery - rq +%global extras %{shrink: aiohttp - tornado - sqlalchemy - pure_eval - httpx - starlette + asyncpg + bottle + celery + django + falcon fastapi - pymongo - opentelemetry + flask grpcio -} -%pyproject_extras_subpkg -n python3-sentry-sdk %_extras + httpx + opentelemetry + %{?with_opentelemetry_experimental:opentelemetry-experimental} + pure_eval + pymongo + rq + sqlalchemy + starlette + tornado + %{nil}} + +%define extras_csv %{expand:%(echo %{extras} | sed "s/ /,/g")} + +%pyproject_extras_subpkg -n python3-sentry-sdk %{extras} %prep %autosetup -p1 -n sentry-python-%{version} +# Verify all extras defined against setup.py +defined_extra=$(echo "%extras_excluded" "%extras" | xargs -n1 | sort -u) +setup_py_extra=$(cat setup.py | sed -n '/extras_require/,/}/p' | sed 's/ //g' | sed '$ s/.$/\nprint("\\n".join(extras_require))/' | python3 -) +diff <(echo "$defined_extra") <(echo "$setup_py_extra") %generate_buildrequires -%pyproject_buildrequires -r +%pyproject_buildrequires -x %{extras_csv} %build # Re-generate the protobuf bindings for compatibility with the packaged # protobuf version. -pushd tests/integrations/grpc/ +pushd tests/integrations/grpc/protos/ protoc --python_out="${PWD}" grpc_test_service.proto popd @@ -116,65 +149,156 @@ popd %check -%global _check_import_options %{expand: - -e sentry_sdk.integrations.arq - -e sentry_sdk.integrations.chalice - -e sentry_sdk.integrations.falcon - -e sentry_sdk.integrations.grpc - -e sentry_sdk.integrations.grpc.client - -e sentry_sdk.integrations.grpc.server - -e sentry_sdk.integrations.huey - -e sentry_sdk.integrations.loguru - -e sentry_sdk.integrations.quart - -e sentry_sdk.integrations.sanic - -e sentry_sdk.integrations.starlite - -e sentry_sdk.integrations.trytond -} -%pyproject_check_import %_check_import_options +# Import check +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.ariadne" # no_ariadne +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.arq" # no_arq +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.chalice" # no_chalice +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.clickhouse_driver" # no_clickhouse_driver +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.gql" # no_gql +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.huey" # no_huey +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.loguru" # no_loguru +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.quart" # no_quart +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.sanic" # no_sanic +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.starlite" # no_starlite +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.strawberry" # no_strawberry +skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.trytond" # no_trytond -# Remove old content_type argument from starlette test (not supported in current version of starlette). -sed -i '/content_type=/D' tests/integrations/starlette/test_starlette.py +%{!?with_opentelemetry_experimental:skip_import_check="${skip_import_check-} -e sentry_sdk.integrations.opentelemetry.integration"} + +%pyproject_check_import ${skip_import_check} + + +# Tests # Deselect/ignore: -# 1. Network-dependent tests -# 2. Tests which cannot be run during Fedora build because of the version of pytest: + +# not in tox.ini, probably broken +ignore="${ignore-} --ignore=tests/integrations/wsgi" + +# python 2 only +deselect="${deselect-} --deselect=tests/integrations/threading/test_threading.py::test_wrapper_attributes_no_qualname" + +# python 3.7 only +ignore="${ignore-} --ignore=tests/integrations/gcp" + +# require network +%if %{without network_tests} +deselect="${deselect-} --deselect=tests/integrations/requests/test_requests.py::test_omit_url_data_if_parsing_fails" +deselect="${deselect-} --deselect=tests/integrations/requests/test_requests.py::test_crumb_capture" +ignore="${ignore-} --ignore=tests/integrations/boto3" +ignore="${ignore-} --ignore=tests/integrations/httpx" +ignore="${ignore-} --ignore=tests/integrations/socket" +%endif +# TODO: investigate +ignore="${ignore-} --ignore=tests/integrations/fastapi" +ignore="${ignore-} --ignore=tests/integrations/httpx" +# require credentials +ignore="${ignore-} --ignore=tests/integrations/aws_lambda/" + +# require a local PostgreSQL instance running +ignore="${ignore-} --ignore=tests/integrations/asyncpg" + +# testing suite relies on the test to be executed in clean env +deselect="${deselect-} --deselect=tests/test_basics.py::test_auto_enabling_integrations_catches_import_error" + +# currently will always fail: there is no env vars or git repository +deselect="${deselect-} --deselect=tests/test_utils.py::test_default_release" + +# tests cannot be run during Fedora build because of the version of pytest: # https://github.com/pytest-dev/pytest/issues/9621 # https://github.com/pytest-dev/pytest-forked/issues/67 -# 3. django integration tests (django-rest-framework is not available for Fedora 38) -# 4. pymongo integration tests (mockupdb is unpackaged because it appears unmaintained) -# 5. redis and rq integration tests (fakeredis is unpackaged yet) -# 6. bottle, django, and flask integration tests (werkzeug in Fedora 38 is too new, see: https://github.com/getsentry/sentry-python/issues/1398) -# 7. celery & newrelic test (newrelic is unpackaged yet) -# 8. test_auto_enabling_integrations_catches_import_error: testing suite relies on the test to be executed on clean env -%pytest --durations=5 \ - --deselect tests/integrations/asyncio/test_asyncio_py3.py \ - --deselect tests/integrations/celery/test_celery.py::test_newrelic_interference \ - --deselect tests/integrations/requests/test_requests.py::test_crumb_capture \ - --deselect tests/integrations/requests/test_requests.py::test_omit_url_data_if_parsing_fails \ - --deselect tests/integrations/threading/test_threading.py::test_circular_references \ - --deselect tests/test_basics.py::test_auto_enabling_integrations_catches_import_error \ - --deselect tests/test_transport.py::test_transport_works \ - --deselect tests/utils/test_contextvars.py \ - --ignore tests/integrations/arq \ - --ignore tests/integrations/bottle \ - --ignore tests/integrations/django \ - --ignore tests/integrations/flask \ - --ignore tests/integrations/gcp \ - --ignore tests/integrations/httpx \ - --ignore tests/integrations/loguru \ - --ignore tests/integrations/pymongo \ - --ignore tests/integrations/pyramid \ - --ignore tests/integrations/redis \ - --ignore tests/integrations/rq \ - --ignore tests/integrations/socket \ - --ignore tests/integrations/wsgi +deselect="${deselect-} --deselect=tests/utils/test_contextvars.py" +# TODO: relies on django testing, incompatible with pytest macro (see above) +deselect="${deselect-} --deselect=tests/test_transport.py::test_transport_works" +ignore="${ignore-} --ignore=tests/integrations/django" + +# async_asgi_testclient is unpackaged yet +ignore="${ignore-} --ignore=tests/integrations/asgi" + +# fakeredis is unpackaged yet +deselect="${deselect-} --deselect=tests/test_basics.py::test_redis_disabled_when_not_installed" +ignore="${ignore-} --ignore=tests/integrations/redis" +ignore="${ignore-} --ignore=tests/integrations/rq" + +# graphene is too old (min version: 3.3) +ignore="${ignore-} --ignore=tests/integrations/graphene" + +# mockupdb is unpackaged because it appears unmaintained +ignore="${ignore-} --ignore=tests/integrations/pymongo" + +# protobuf is too old +ignore="${ignore-} --ignore=tests/integrations/grpc" + +# werkzeug is too new (version < 2.1.0) +ignore="${ignore-} --ignore=tests/integrations/pyramid" + +# newrelic is unpackaged yet +deselect="${deselect-} --deselect=tests/integrations/celery/test_celery.py::test_newrelic_interference" + +# rediscluster is unpackaged yet +ignore="${ignore-} --ignore=tests/integrations/rediscluster" + +# werkzeug in Fedora 38 is too new, see: https://github.com/getsentry/sentry-python/issues/1398 +ignore="${ignore-} --ignore=tests/integrations/bottle" +ignore="${ignore-} --ignore=tests/integrations/flask" + +# disabled extras/integrations +ignore="${ignore-} --ignore=tests/integrations/ariadne" # no_ariadne +ignore="${ignore-} --ignore=tests/integrations/arq" # no_arq +ignore="${ignore-} --ignore=tests/integrations/beam" # no_beam +ignore="${ignore-} --ignore=tests/integrations/chalice" # no_chalice +ignore="${ignore-} --ignore=tests/integrations/clickhouse_driver" # no_clickhouse_driver +ignore="${ignore-} --ignore=tests/integrations/gql" # no_gql +ignore="${ignore-} --ignore=tests/integrations/huey" # no_huey +ignore="${ignore-} --ignore=tests/integrations/loguru" # no_loguru +ignore="${ignore-} --ignore=tests/integrations/spark" # no_pyspark +ignore="${ignore-} --ignore=tests/integrations/quart" # no_quart +ignore="${ignore-} --ignore=tests/integrations/sanic" # no_sanic +ignore="${ignore-} --ignore=tests/integrations/starlite" # no_starlite +ignore="${ignore-} --ignore=tests/integrations/strawberry" # no_strawberry +ignore="${ignore-} --ignore=tests/integrations/trytond" # no_trytond + +ignore="${ignore-} %{!?with_opentelemetry_experimental:--ignore=tests/integrations/opentelemetry/test_experimental.py}" + +# Make django testing separate: +# pytest-django cannot find manage.py, since the layout is custom: +# https://github.com/getsentry/sentry-python/blob/1.39.1/tests/integrations/django/myapp/manage.py +# is too deep inside, so it expects manual setting of PYTHONPATH: +# https://pytest-django.readthedocs.io/en/latest/managing_python_path.html +# If we add . to PYTHONPATH for all tests, how can we be sure that packaged library works fine (we are testing sources)? +sed -i 's/\[pytest\]/[pytest]\ndjango_find_project = false/' pytest.ini +PYTHONPATH=. pytest -rsx -s --durations=5 tests/integrations/django +sed -i '/django_find_project =/D' pytest.ini +sed -i '/DJANGO_SETTINGS_MODULE =/D' pytest.ini + +%if %{without sqlalchemy_during_tests} +# Test sqlalchemy separately +%pytest -rsx -s --durations=5 tests/integrations/sqlalchemy + +# Make `import sqlalchemy` fail +echo "raise ImportError()" > sqlalchemy.py + +ignore="${ignore-} --ignore=tests/integrations/sqlalchemy" +%endif + +%pytest -rsx -s --durations=5 tests/ ${deselect-} ${ignore-} %files -n python3-sentry-sdk -f %{pyproject_files} %doc README.md %changelog +* Wed Dec 20 2023 Roman Inflianskas - 1.39.1-1 +- Update to 1.39.1 (fedora#2238739) +- Use bcond for conditionally excluded integrations, sqlalchemy during + tests, and for network-related tests +- Verify all extras against setup.py +- Improve testing by removing ignores for tests that pass and adding + comments with reasons for ignores +- Remove patch for Python 3.12 which is unnecessary now +- Add new integrations (extras) + * Thu Oct 12 2023 Miro HronĨok - 1.29.2-2 - Explicitly BuildRequire python3dist(pysocks), as the tests fail without it diff --git a/sources b/sources index 433877c..de94eb4 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (sentry-python-1.29.2.tar.gz) = 56fd53f3a43acc1c2fe5bd6f44c7a5a63b4ab944919fa5a4539239230c3c64eb75e75414e26809d12bcb601a779b661d6dec73dededa07e10f120438ea3ad5c7 +SHA512 (sentry-python-1.39.1.tar.gz) = 0b162cc677b1e59434b6c58ccced4d84f6679b5ff733271938b07302e0e9a9d706304334282bd7b7e1c1f4026ed98fae3e5635cfac306e08a3aee801d75e1d7c