Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for Python version prior to 3.6. #76

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion googlecloudprofiler/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
31 changes: 5 additions & 26 deletions googlecloudprofiler/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
33 changes: 1 addition & 32 deletions kokoro/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
8 changes: 1 addition & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
])