Skip to content

Commit

Permalink
Do not force the requests module to always be included
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipuniverse committed Mar 2, 2023
1 parent c3b6510 commit 343b9e3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ jobs:
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=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 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

0 comments on commit 343b9e3

Please sign in to comment.