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

Do not force the requests module to always be included #422

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
112 changes: 56 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ jobs:
matrix:
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, '3.10', 3.11]
framework:
- FLASK_VERSION=0.12.5 Werkzeug\>=0.7,\<1.0
- FLASK_VERSION=1.1.4
- FLASK_VERSION=2.2.3
- DJANGO_VERSION=1.11.29
- DJANGO_VERSION=2.2.28
- DJANGO_VERSION=3.2.18
- DJANGO_VERSION=4.0.10
- DJANGO_VERSION=4.1.7
- TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- TWISTED_VERSION=20.3.0
- TWISTED_VERSION=21.7.0
- TWISTED_VERSION=22.10.0
- PYRAMID_VERSION=1.10.8
- FLASK_VERSION=0.12.5 Werkzeug\>=0.7,\<1.0 requests==2.27.1
- FLASK_VERSION=1.1.4 requests==2.27.1
- FLASK_VERSION=2.2.3 requests==2.27.1
- DJANGO_VERSION=1.11.29 requests==2.27.1
- DJANGO_VERSION=2.2.28 requests==2.27.1
- DJANGO_VERSION=3.2.18 requests==2.27.1
- DJANGO_VERSION=4.0.10 requests==2.27.1
- DJANGO_VERSION=4.1.7 requests==2.27.1
- TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
- TWISTED_VERSION=20.3.0 requests==2.27.1
- TWISTED_VERSION=21.7.0 requests==2.27.1
- TWISTED_VERSION=22.10.0 requests==2.27.1
- PYRAMID_VERSION=1.10.8 requests==2.27.1
- STARLETTE_VERSION=0.12.13 httpx==0.18.1 python-multipart==0.0.5
- STARLETTE_VERSION=0.14.2 httpx==0.18.1 python-multipart==0.0.5
- FASTAPI_VERSION=0.40.0 httpx==0.18.1 python-multipart==0.0.5
Expand All @@ -35,93 +35,93 @@ jobs:
exclude:
# Test frameworks on the python versions they support, according to pypi registry
# Flask
- framework: FLASK_VERSION=1.1.4
- framework: FLASK_VERSION=1.1.4 requests==2.27.1
python-version: 3.4
- framework: FLASK_VERSION=2.2.3
- framework: FLASK_VERSION=2.2.3 requests==2.27.1
python-version: 2.7
- framework: FLASK_VERSION=2.2.3
- framework: FLASK_VERSION=2.2.3 requests==2.27.1
python-version: 3.4
- framework: FLASK_VERSION=2.2.3
- framework: FLASK_VERSION=2.2.3 requests==2.27.1
python-version: 3.5
- framework: FLASK_VERSION=2.2.3
- framework: FLASK_VERSION=2.2.3 requests==2.27.1
python-version: 3.6

# Django
- framework: DJANGO_VERSION=1.11.29
- framework: DJANGO_VERSION=1.11.29 requests==2.27.1
python-version: 3.8
- framework: DJANGO_VERSION=1.11.29
- framework: DJANGO_VERSION=1.11.29 requests==2.27.1
python-version: 3.9
- framework: DJANGO_VERSION=1.11.29
- framework: DJANGO_VERSION=1.11.29 requests==2.27.1
python-version: '3.10'
- framework: DJANGO_VERSION=1.11.29
- framework: DJANGO_VERSION=1.11.29 requests==2.27.1
python-version: 3.11
- framework: DJANGO_VERSION=2.2.28
- framework: DJANGO_VERSION=2.2.28 requests==2.27.1
python-version: 2.7
- framework: DJANGO_VERSION=2.2.28
- framework: DJANGO_VERSION=2.2.28 requests==2.27.1
python-version: 3.4
- framework: DJANGO_VERSION=3.2.18
- framework: DJANGO_VERSION=3.2.18 requests==2.27.1
python-version: 2.7
- framework: DJANGO_VERSION=3.2.18
- framework: DJANGO_VERSION=3.2.18 requests==2.27.1
python-version: 3.4
- framework: DJANGO_VERSION=3.2.18
- framework: DJANGO_VERSION=3.2.18 requests==2.27.1
python-version: 3.5
- framework: DJANGO_VERSION=4.0.10
- framework: DJANGO_VERSION=4.0.10 requests==2.27.1
python-version: 2.7
- framework: DJANGO_VERSION=4.0.10
- framework: DJANGO_VERSION=4.0.10 requests==2.27.1
python-version: 3.4
- framework: DJANGO_VERSION=4.0.10
- framework: DJANGO_VERSION=4.0.10 requests==2.27.1
python-version: 3.5
- framework: DJANGO_VERSION=4.0.10
- framework: DJANGO_VERSION=4.0.10 requests==2.27.1
python-version: 3.6
- framework: DJANGO_VERSION=4.0.10
- framework: DJANGO_VERSION=4.0.10 requests==2.27.1
python-version: 3.7
- framework: DJANGO_VERSION=4.1.7
- framework: DJANGO_VERSION=4.1.7 requests==2.27.1
python-version: 2.7
- framework: DJANGO_VERSION=4.1.7
- framework: DJANGO_VERSION=4.1.7 requests==2.27.1
python-version: 3.4
- framework: DJANGO_VERSION=4.1.7
- framework: DJANGO_VERSION=4.1.7 requests==2.27.1
python-version: 3.5
- framework: DJANGO_VERSION=4.1.7
- framework: DJANGO_VERSION=4.1.7 requests==2.27.1
python-version: 3.6
- framework: DJANGO_VERSION=4.1.7
- framework: DJANGO_VERSION=4.1.7 requests==2.27.1
python-version: 3.7

# Twisted
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.4
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.5
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.6
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.7
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.8
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.9
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: '3.10'
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- framework: TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0 requests==2.27.1
python-version: 3.11
- framework: TWISTED_VERSION=20.3.0
- framework: TWISTED_VERSION=20.3.0 requests==2.27.1
python-version: 2.7
- framework: TWISTED_VERSION=20.3.0
- framework: TWISTED_VERSION=20.3.0 requests==2.27.1
python-version: 3.4
- framework: TWISTED_VERSION=20.3.0
- framework: TWISTED_VERSION=20.3.0 requests==2.27.1
python-version: 3.11
- framework: TWISTED_VERSION=21.7.0
- framework: TWISTED_VERSION=21.7.0 requests==2.27.1
python-version: 2.7
- framework: TWISTED_VERSION=21.7.0
- framework: TWISTED_VERSION=21.7.0 requests==2.27.1
python-version: 3.4
- framework: TWISTED_VERSION=21.7.0
- framework: TWISTED_VERSION=21.7.0 requests==2.27.1
python-version: 3.5
- framework: TWISTED_VERSION=22.10.0
- framework: TWISTED_VERSION=22.10.0 requests==2.27.1
python-version: 2.7
- framework: TWISTED_VERSION=22.10.0
- framework: TWISTED_VERSION=22.10.0 requests==2.27.1
python-version: 3.4
- framework: TWISTED_VERSION=22.10.0
- framework: TWISTED_VERSION=22.10.0 requests==2.27.1
python-version: 3.5
- framework: TWISTED_VERSION=22.10.0
- framework: TWISTED_VERSION=22.10.0 requests==2.27.1
python-version: 3.6


Expand Down Expand Up @@ -178,7 +178,7 @@ jobs:
# certifi dropped support for Python 2 in 2020.4.5.2 but only started
# using Python 3 syntax in 2022.5.18. 2021.10.8 is the last release with
# Python 2 support.
run: pip install certifi==2021.10.8 requests==2.27.1 incremental==21.3.0
run: pip install certifi==2021.10.8 incremental==21.3.0

- name: Install Python 3.4 dependencies
if: ${{ contains(matrix.python-version, '3.4') }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Pipfile
Pipfile.lock
.pytest_cache/
.python-version
build
17 changes: 14 additions & 3 deletions rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import wsgiref.util
import warnings

import requests
import six

from rollbar.lib import events, filters, dict_merge, parse_qs, text, transport, urljoin, iteritems, defaultJSONEncode
Expand All @@ -34,6 +33,11 @@
# 3.x
import queue

try:
import requests
except ImportError:
requests = None

# import request objects from various frameworks, if available
try:
from webob import BaseRequest as WebobBaseRequest
Expand Down Expand Up @@ -548,6 +552,9 @@ def send_payload(payload, access_token):

payload_str = _serialize_payload(payload)
if handler == 'blocking':
if requests is None:
log.error('Unable to find requests module')
return
_send_payload(payload_str, access_token)
elif handler == 'agent':
agent_log.error(payload_str)
Expand Down Expand Up @@ -576,11 +583,15 @@ def send_payload(payload, access_token):
log.error('Unable to find async handler')
return
_send_payload_async(payload_str, access_token)
elif handler == 'thread':
_send_payload_thread(payload_str, access_token)
elif handler == 'thread_pool':
if requests is None:
log.error('Unable to find requests module')
return
_send_payload_thread_pool(payload_str, access_token)
else:
if requests is None:
log.error('Unable to find requests module')
return
# default to 'thread'
_send_payload_thread(payload_str, access_token)

Expand Down
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@
'mock<=3.0.5; python_version < "3.3"',
'enum34; python_version < "3.4"',
'httpx; python_version >= "3.6"',
'aiocontextvars; python_version == "3.6"'
'aiocontextvars; python_version == "3.6"',
# The currently used version of `setuptools` has a bug,
# so the version requirements are not properly respected.
#
# In the current version, `requests>= 0.12.1`
# always installs the latest version of the package.
'requests>=0.12.1; python_version == "2.7"',
'requests>=0.12.1; python_version >= "3.6"',
'requests>=0.12.1; python_version == "3.5"',
'requests>=0.12.1; python_version == "3.4"',
]

setup(
Expand Down Expand Up @@ -78,15 +87,6 @@
"Topic :: System :: Monitoring",
],
install_requires=[
# The currently used version of `setuptools` has a bug,
# so the version requirements are not properly respected.
#
# In the current version, `requests>= 0.12.1`
# always installs the latest version of the package.
'requests>=0.12.1; python_version == "2.7"',
'requests>=0.12.1; python_version >= "3.6"',
'requests>=0.12.1; python_version == "3.5"',
'requests>=0.12.1; python_version == "3.4"',
'six>=1.9.0'
],
tests_require=tests_require,
Expand Down