From e2ff918adbee9aa6fe28ff4fb28fd0f1a32c2bef Mon Sep 17 00:00:00 2001 From: anthony sottile <103459774+asottile-sentry@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:33:50 -0400 Subject: [PATCH] Reapplyx3 "ref: upgrade sentry to python 3.12" (#76625) This reverts commit 0c527a02199e9b61e56e4fef4b9f9068118258da. now that pyuwsgi is no longer deadlocking this should be good to go! --- .github/actions/setup-sentry/action.yml | 3 +- .github/workflows/backend.yml | 4 +- .github/workflows/development-environment.yml | 4 +- .github/workflows/pre-commit.yml | 2 +- .../react-to-product-owners-yml-changes.yml | 2 +- .github/workflows/self-hosted.yml | 2 +- .python-version | 2 +- devenv/config.ini | 40 +++++++++---------- pyproject.toml | 6 ++- requirements-dev-frozen.txt | 2 +- requirements-frozen.txt | 2 +- scripts/lib.sh | 4 +- self-hosted/Dockerfile | 2 +- tests/sentry/test_devimports.py | 2 +- 14 files changed, 41 insertions(+), 36 deletions(-) diff --git a/.github/actions/setup-sentry/action.yml b/.github/actions/setup-sentry/action.yml index aedc1d3140d3a..1c00b26b346ed 100644 --- a/.github/actions/setup-sentry/action.yml +++ b/.github/actions/setup-sentry/action.yml @@ -38,7 +38,7 @@ inputs: python-version: description: 'python version to install' required: false - default: '3.11.8' + default: '3.12.3' pg-version: description: 'PostgreSQL version to use' default: '14' @@ -79,6 +79,7 @@ runs: ### pytest configuration ### echo "PY_COLORS=1" >> "$GITHUB_ENV" echo "PYTEST_ADDOPTS=--reruns=5 --durations=10 --fail-slow=60s" >> $GITHUB_ENV + echo "COVERAGE_CORE=sysmon" >> "$GITHUB_ENV" ### pytest-sentry configuration ### if [ "$GITHUB_REPOSITORY" = "getsentry/sentry" ]; then diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 9c33fb36cba9b..0da8a19026cf2 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -208,7 +208,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.8 + python-version: 3.12.3 cache-dependency-path: requirements-dev-frozen.txt install-cmd: python3 -m tools.hack_pip && pip install -q --constraint requirements-dev-frozen.txt pip-tools - name: check requirements @@ -301,7 +301,7 @@ jobs: - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.8 + python-version: 3.12.3 cache-dependency-path: requirements-dev-frozen.txt install-cmd: python3 -m tools.hack_pip && pip install -r requirements-dev-frozen.txt diff --git a/.github/workflows/development-environment.yml b/.github/workflows/development-environment.yml index 83a7da8f20fbe..9b82fc4e890d1 100644 --- a/.github/workflows/development-environment.yml +++ b/.github/workflows/development-environment.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.8 + python-version: 3.12.3 cache-dependency-path: | requirements-dev.txt requirements-dev-frozen.txt @@ -52,7 +52,7 @@ jobs: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.8 + python-version: 3.12.3 cache-dependency-path: | requirements-dev.txt requirements-dev-frozen.txt diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 696fd5b9c1b12..7d8a5df2ae959 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -71,7 +71,7 @@ jobs: - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.8 + python-version: 3.12.3 cache-dependency-path: | requirements-dev.txt requirements-dev-frozen.txt diff --git a/.github/workflows/react-to-product-owners-yml-changes.yml b/.github/workflows/react-to-product-owners-yml-changes.yml index b7c72697bc1ec..5502b8ef6a7fd 100644 --- a/.github/workflows/react-to-product-owners-yml-changes.yml +++ b/.github/workflows/react-to-product-owners-yml-changes.yml @@ -13,7 +13,7 @@ jobs: - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.3 + python-version: 3.12.3 - name: React to product-owners.yml changes shell: bash diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml index 8deffe5a2f8af..a370846f565b6 100644 --- a/.github/workflows/self-hosted.yml +++ b/.github/workflows/self-hosted.yml @@ -31,7 +31,7 @@ jobs: - uses: getsentry/action-setup-venv@a133e6fd5fa6abd3f590a1c106abda344f5df69f # v2.1.0 with: - python-version: 3.11.6 + python-version: 3.12.3 cache-dependency-path: requirements-dev-frozen.txt install-cmd: python3 -m tools.hack_pip diff --git a/.python-version b/.python-version index b6d8b7612f0ef..871f80a34bee8 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11.8 +3.12.3 diff --git a/devenv/config.ini b/devenv/config.ini index 6bb9b112ee327..0550eab4adbf3 100644 --- a/devenv/config.ini +++ b/devenv/config.ini @@ -1,5 +1,5 @@ [venv.sentry] -python = 3.11.8 +python = 3.12.3 path = .venv requirements = requirements-dev.txt editable = @@ -8,7 +8,7 @@ editable = # bins = [venv.getsentry] -python = 3.11.8 +python = 3.12.3 # technically these are conflicting paths but getsentry is special # and would rather keep devenv config symlinked path = .venv @@ -17,15 +17,15 @@ editable = . # but we'll just install it during sync as it's rarely populated requirements = sentry-requirements-dev-frozen.txt -[python3.11.8] -darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-x86_64-apple-darwin-install_only.tar.gz -darwin_x86_64_sha256 = 097f467b0c36706bfec13f199a2eaf924e668f70c6e2bd1f1366806962f7e86e -darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-aarch64-apple-darwin-install_only.tar.gz -darwin_arm64_sha256 = 389a51139f5abe071a0d70091ca5df3e7a3dfcfcbe3e0ba6ad85fb4c5638421e -linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-x86_64-unknown-linux-gnu-install_only.tar.gz -linux_x86_64_sha256 = 94e13d0e5ad417035b80580f3e893a72e094b0900d5d64e7e34ab08e95439987 -linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-aarch64-unknown-linux-gnu-install_only.tar.gz -linux_arm64_sha256 = 389b9005fb78dd5a6f68df5ea45ab7b30d9a4b3222af96999e94fd20d4ad0c6a +[python3.12.3] +darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-apple-darwin-install_only.tar.gz +darwin_x86_64_sha256 = c37a22fca8f57d4471e3708de6d13097668c5f160067f264bb2b18f524c890c8 +darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-apple-darwin-install_only.tar.gz +darwin_arm64_sha256 = ccc40e5af329ef2af81350db2a88bbd6c17b56676e82d62048c15d548401519e +linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-unknown-linux-gnu-install_only.tar.gz +linux_x86_64_sha256 = a73ba777b5d55ca89edef709e6b8521e3f3d4289581f174c8699adfb608d09d6 +linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-unknown-linux-gnu-install_only.tar.gz +linux_arm64_sha256 = ec8126de97945e629cca9aedc80a29c4ae2992c9d69f2655e27ae73906ba187d [colima] darwin_x86_64 = https://github.com/abiosoft/colima/releases/download/v0.6.6/colima-Darwin-x86_64 @@ -41,12 +41,12 @@ version = v0.6.6 # kept here only for compatibility with older `devenv` [python] -version = 3.11.8 -darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-x86_64-apple-darwin-install_only.tar.gz -darwin_x86_64_sha256 = 097f467b0c36706bfec13f199a2eaf924e668f70c6e2bd1f1366806962f7e86e -darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-aarch64-apple-darwin-install_only.tar.gz -darwin_arm64_sha256 = 389a51139f5abe071a0d70091ca5df3e7a3dfcfcbe3e0ba6ad85fb4c5638421e -linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-x86_64-unknown-linux-gnu-install_only.tar.gz -linux_x86_64_sha256 = 94e13d0e5ad417035b80580f3e893a72e094b0900d5d64e7e34ab08e95439987 -linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240224/cpython-3.11.8+20240224-aarch64-unknown-linux-gnu-install_only.tar.gz -linux_arm64_sha256 = 389b9005fb78dd5a6f68df5ea45ab7b30d9a4b3222af96999e94fd20d4ad0c6a +version = 3.12.3 +darwin_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-apple-darwin-install_only.tar.gz +darwin_x86_64_sha256 = c37a22fca8f57d4471e3708de6d13097668c5f160067f264bb2b18f524c890c8 +darwin_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-apple-darwin-install_only.tar.gz +darwin_arm64_sha256 = ccc40e5af329ef2af81350db2a88bbd6c17b56676e82d62048c15d548401519e +linux_x86_64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-x86_64-unknown-linux-gnu-install_only.tar.gz +linux_x86_64_sha256 = a73ba777b5d55ca89edef709e6b8521e3f3d4289581f174c8699adfb608d09d6 +linux_arm64 = https://github.com/indygreg/python-build-standalone/releases/download/20240415/cpython-3.12.3+20240415-aarch64-unknown-linux-gnu-install_only.tar.gz +linux_arm64_sha256 = ec8126de97945e629cca9aedc80a29c4ae2992c9d69f2655e27ae73906ba187d diff --git a/pyproject.toml b/pyproject.toml index eba577ac67daf..769f72caaaebd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,10 @@ filterwarnings = [ # this warning in protobuf causes a segfault in 3.12+ protocolbuffers/protobuf#15077 "ignore:Type google\\._upb.*", + # TODO: we should fix these, but for now there's a lot + "ignore:datetime.datetime.utcfromtimestamp\\(\\) is deprecated.*", + "ignore:datetime.datetime.utcnow\\(\\) is deprecated.*", + # The following warning filters are for pytest only. "ignore:.*sentry.digests.backends.dummy.DummyBackend.*:sentry.utils.warnings.UnsupportedBackend", @@ -43,7 +47,7 @@ filterwarnings = [ looponfailroots = ["src", "tests"] [tool.mypy] -python_version = "3.11" +python_version = "3.12" mypy_path = ["fixtures/stubs-for-mypy"] plugins = [ "pydantic.mypy", diff --git a/requirements-dev-frozen.txt b/requirements-dev-frozen.txt index 31eed990419d9..7b5c9d021be8e 100644 --- a/requirements-dev-frozen.txt +++ b/requirements-dev-frozen.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # make freeze-requirements diff --git a/requirements-frozen.txt b/requirements-frozen.txt index 48ebf56efe055..03455030c1bb1 100644 --- a/requirements-frozen.txt +++ b/requirements-frozen.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # make freeze-requirements diff --git a/scripts/lib.sh b/scripts/lib.sh index 7ecf79f609c45..d4b8ba86b99da 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -57,11 +57,11 @@ EOF else minor=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\1/') patch=$(echo "${python_version}" | sed 's/[0-9]*\.\([0-9]*\)\.\([0-9]*\)/\2/') - if [ "$minor" -ne 11 ] || [ "$patch" -lt 6 ]; then + if [ "$minor" -ne 12 ] || [ "$patch" -lt 1 ]; then cat <= 3.11.6, < 3.12. + We only support >= 3.12.1, < 3.13. Either run "rm -rf ${venv_name} && direnv allow" to OR set SENTRY_PYTHON_VERSION=${python_version} to an .env file to bypass this check." EOF diff --git a/self-hosted/Dockerfile b/self-hosted/Dockerfile index 8c5538af6f25f..354b355d2445f 100644 --- a/self-hosted/Dockerfile +++ b/self-hosted/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.11.8-slim-bookworm +FROM python:3.12.3-slim-bookworm LABEL maintainer="oss@sentry.io" LABEL org.opencontainers.image.title="Sentry" diff --git a/tests/sentry/test_devimports.py b/tests/sentry/test_devimports.py index ef33ca2cc9e21..989d2e3fa9233 100644 --- a/tests/sentry/test_devimports.py +++ b/tests/sentry/test_devimports.py @@ -94,7 +94,7 @@ def _import(name, globals=None, locals=None, fromlist=(), level=0): raise SystemExit(f'unexpected success importing {{xfail}}') """ - env = {"SENTRY_ENVIRONMENT": "production", "SETUPTOOLS_USE_DISTUTILS": "stdlib"} + env = {"SENTRY_ENVIRONMENT": "production"} ret = subprocess.run( (sys.executable, "-c", script), env=env,