From c64557c8c13cf84f38edeb70080c0db6dd3b2bac Mon Sep 17 00:00:00 2001 From: Garrett Wang Date: Wed, 10 Mar 2021 14:22:02 -0800 Subject: [PATCH] Drop support for Python version prior to 3.6. PiperOrigin-RevId: 362140971 --- README.md | 4 ++++ googlecloudprofiler/__version__.py | 2 +- googlecloudprofiler/client.py | 31 +++++----------------------- kokoro/integration_test.go | 33 +----------------------------- setup.py | 8 +------- 5 files changed, 12 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index fc6dfbb..16f2239 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ See [Google Cloud Profiler profiling Python code](https://cloud.google.com/profiler/docs/profiling-python) for detailed documentation. +## Supported Python Versions + +Python >= 3.6 + ## Installation & usage 1. Install the profiler package using PyPI: diff --git a/googlecloudprofiler/__version__.py b/googlecloudprofiler/__version__.py index 1aedaa6..fe5e6e8 100644 --- a/googlecloudprofiler/__version__.py +++ b/googlecloudprofiler/__version__.py @@ -16,4 +16,4 @@ """Version of Python Cloud Profiler module.""" # setup.py reads the version information from here to set package version -__version__ = '2.0.6' +__version__ = '3.0.0' diff --git a/googlecloudprofiler/client.py b/googlecloudprofiler/client.py index 58d6cd2..30760af 100644 --- a/googlecloudprofiler/client.py +++ b/googlecloudprofiler/client.py @@ -19,28 +19,22 @@ import logging import os import re -import sys import threading import time import traceback +import google.auth +from google.oauth2 import service_account import google_auth_httplib2 import googleapiclient import googleapiclient.discovery import googleapiclient.errors from googlecloudprofiler import __version__ as version from googlecloudprofiler import backoff -# pylint: disable=g-import-not-at-top -if sys.version_info >= (3, 2) and sys.platform.startswith('linux'): - from googlecloudprofiler import cpu_profiler -else: - # CPU profiling is not supported for Python older than 3.2. - cpu_profiler = None +from googlecloudprofiler import cpu_profiler from googlecloudprofiler import pythonprofiler import httplib2 import requests -import google.auth -from google.oauth2 import service_account from google.protobuf import duration_pb2 from google.protobuf import json_format @@ -229,29 +223,14 @@ def start(self): def _config_cpu_profiling(self, disable_cpu_profiling, period_ms): """Adds CPU profiler if CPU profiling is supported and not disabled.""" - cpu_profiling_supported = cpu_profiler is not None - if not cpu_profiling_supported: - logger.info('CPU profiling is not supported on the current Python ' - 'version or Operating System. Python versions 3.2 and higher ' - 'on Linux are supported.') - elif disable_cpu_profiling: + if disable_cpu_profiling: logger.info('CPU profiling is disabled by disable_cpu_profiling') else: self._profilers['CPU'] = cpu_profiler.CPUProfiler(period_ms) def _config_wall_profiling(self, disable_wall_profiling, period_ms): """Adds wall profiler if wall profiling is supported and not disabled.""" - # The Python signal module in Python versions older than 3.6 doesn't handle - # signals properly. See b/123783496. The signal module changed significantly - # in Python 3.6 and the problem no longer exists. For Python 2, the problem - # theoretically can happen, but is much less likely to manifest. Users can - # use it at their own risk. - wall_profiling_supported = ( - sys.version_info >= (3, 6) or sys.version_info < (3, 0)) - if not wall_profiling_supported: - logger.info('Wall profiling is not supported on the current Python ' - 'version. Python 2 and Python 3.6 and higher are supported') - elif disable_wall_profiling: + if disable_wall_profiling: logger.info('Wall profiling is disabled by disable_wall_profiling') else: self._profilers['WALL'] = pythonprofiler.WallProfiler(period_ms) diff --git a/kokoro/integration_test.go b/kokoro/integration_test.go index d098825..2de3acd 100644 --- a/kokoro/integration_test.go +++ b/kokoro/integration_test.go @@ -71,7 +71,7 @@ retry apt-get -o Acquire::ForceIPv4=true update >/dev/null retry apt-get -o Acquire::ForceIPv4=true install -yq git build-essential python3-distutils {{.PythonDev}} {{if .InstallPythonVersion}}{{.InstallPythonVersion}}{{end}} >/dev/ttyS2 # Install Python dependencies. -retry wget -O /tmp/get-pip.py {{.PipURL}} >/dev/null +retry wget -O /tmp/get-pip.py https://bootstrap.pypa.io/get-pip.py >/dev/null retry {{.PythonCommand}} /tmp/get-pip.py >/dev/null retry {{.PythonCommand}} -m pip install --upgrade pyasn1 >/dev/null @@ -169,8 +169,6 @@ type testCase struct { pythonCommand string // The python-dev package to install, e.g "python-dev" or "python3.5-dev". pythonDev string - // URL to use to bootstrap the pip installation. See b/178278868 for details. - pipURL string // Used in the bench code to check the Python version, e.g // "sys.version_info[:2] == (2.7)". versionCheck string @@ -194,7 +192,6 @@ func (tc *testCase) initializeStartUpScript(template *template.Template) error { InstallPythonVersion string PythonCommand string PythonDev string - PipURL string VersionCheck string FinishString string ErrorString string @@ -206,7 +203,6 @@ func (tc *testCase) initializeStartUpScript(template *template.Template) error { InstallPythonVersion: tc.installPythonVersion, PythonCommand: tc.pythonCommand, PythonDev: tc.pythonDev, - PipURL: tc.pipURL, VersionCheck: tc.versionCheck, FinishString: benchFinishString, ErrorString: errorString, @@ -285,36 +281,10 @@ func TestAgentIntegration(t *testing.T) { }, pythonCommand: "python3", pythonDev: "python3-dev", - pipURL: "https://bootstrap.pypa.io/get-pip.py", versionCheck: "sys.version_info[:2] >= (3, 6)", timeout: gceTestTimeout, benchDuration: gceBenchDuration, }, - // Test Python 3.5. - { - InstanceConfig: proftest.InstanceConfig{ - ProjectID: projectID, - Zone: zone, - Name: fmt.Sprintf("profiler-test-python35-%s", runID), - MachineType: "n1-standard-1", - ImageProject: "ubuntu-os-cloud", - ImageFamily: "ubuntu-1804-lts", - Scopes: []string{storageReadScope}, - }, - name: fmt.Sprintf("profiler-test-python35-%s-gce", runID), - wantProfiles: map[string]string{ - "CPU": "repeat_bench", - // Wall profiling should be disabled on Python 3.5. - "WALL": "", - }, - installPythonVersion: "python3.5", - pythonCommand: "python3.5", - pythonDev: "python3.5-dev", - pipURL: "https://bootstrap.pypa.io/pip/2.7/get-pip.py", - versionCheck: "sys.version_info[:2] == (3, 5)", - timeout: gceTestTimeout, - benchDuration: gceBenchDuration, - }, } if *runBackoffTest { @@ -341,7 +311,6 @@ func TestAgentIntegration(t *testing.T) { }, pythonCommand: "python3", pythonDev: "python3-dev", - pipURL: "https://bootstrap.pypa.io/get-pip.py", versionCheck: "sys.version_info[:2] >= (3, 6)", timeout: backoffTestTimeout, benchDuration: backoffBenchDuration, diff --git a/setup.py b/setup.py index 2d0d898..9590e7a 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,7 @@ install_requires = [ # google-api-python-client V1.12.0 has an known issue,see # https://github.com/googleapis/google-api-python-client/issues/1029. - # TODO: Allow use of later versions of google-api-python-client - # once there is a new release which is compatible with this profiling agent. - 'google-api-python-client!=1.12.0,<2', + 'google-api-python-client!=1.12.0', 'google-auth>=1.0.0', 'google-auth-httplib2', 'protobuf', @@ -105,10 +103,6 @@ def get_version(): 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 3.2', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', ])