diff --git a/.travis.yml b/.travis.yml index c44f638..14f06de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,8 +33,6 @@ cache: install: - pip install --upgrade setuptools pip - pip install $DJANGO - # For now, install all ESPs and test at once - # (in future, might want to matrix ESPs to test cross-dependencies) - - pip install .[mailgun,mandrill,sendgrid] + - pip install . - pip list script: python -Wall setup.py test diff --git a/README.rst b/README.rst index 1935af1..02e50a4 100644 --- a/README.rst +++ b/README.rst @@ -72,11 +72,11 @@ Anymail 1-2-3 This example uses Mailgun, but you can substitute Postmark or SendGrid or any other supported ESP where you see "mailgun": -1. Install Anymail from PyPI, including the ESP(s) you want to use: +1. Install Anymail from PyPI: .. code-block:: console - $ pip install django-anymail[mailgun] # or [postmark,sendgrid] or ... + $ pip install django-anymail 2. Edit your project's ``settings.py``: diff --git a/anymail/backends/base_requests.py b/anymail/backends/base_requests.py index 1fe6271..02f78a9 100644 --- a/anymail/backends/base_requests.py +++ b/anymail/backends/base_requests.py @@ -1,18 +1,13 @@ import json +import requests # noinspection PyUnresolvedReferences from six.moves.urllib.parse import urljoin from .base import AnymailBaseBackend, BasePayload -from ..exceptions import AnymailImproperlyInstalled, AnymailRequestsAPIError, AnymailSerializationError +from ..exceptions import AnymailRequestsAPIError, AnymailSerializationError from .._version import __version__ -try: - # noinspection PyUnresolvedReferences - import requests -except ImportError: - raise AnymailImproperlyInstalled('requests') - class AnymailRequestsBackend(AnymailBaseBackend): """ diff --git a/anymail/backends/sendgrid.py b/anymail/backends/sendgrid.py index 0a50de9..d7ad6c4 100644 --- a/anymail/backends/sendgrid.py +++ b/anymail/backends/sendgrid.py @@ -1,17 +1,13 @@ from django.core.exceptions import ImproperlyConfigured from django.core.mail import make_msgid +from requests.structures import CaseInsensitiveDict -from ..exceptions import AnymailImproperlyInstalled, AnymailRequestsAPIError +from ..exceptions import AnymailRequestsAPIError from ..message import AnymailRecipientStatus from ..utils import get_anymail_setting, timestamp from .base_requests import AnymailRequestsBackend, RequestsPayload -try: - # noinspection PyUnresolvedReferences - from requests.structures import CaseInsensitiveDict -except ImportError: - raise AnymailImproperlyInstalled('requests', backend="sendgrid") class SendGridBackend(AnymailRequestsBackend): diff --git a/anymail/exceptions.py b/anymail/exceptions.py index 89610e7..c3ff7b6 100644 --- a/anymail/exceptions.py +++ b/anymail/exceptions.py @@ -1,14 +1,7 @@ import json from django.core.exceptions import ImproperlyConfigured - -try: - from requests import HTTPError -except ImportError: - # Backends that don't use requests aren't required to have it installed - # (and could never raise an AnymailRequestsAPIError) - class HTTPError(Exception): - pass +from requests import HTTPError class AnymailError(Exception): diff --git a/docs/installation.rst b/docs/installation.rst index 54a5803..20c5497 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,24 +6,14 @@ Installation and configuration Installing Anymail ------------------ -Install Anymail from PyPI using pip. - -Anymail uses python setuptools' "extra features" to pull in dependencies -for specific ESPs. (This avoids installing packages needed by ESPs -you aren't using.) - -You'll want to include at least one ESP as an extra in your pip command. -E.g., for Anymail with Mailgun support: +It's easiest to install Anymail from PyPI using pip. .. code-block:: console - $ pip install django-anymail[mailgun] + $ pip install django-anymail -...or with both Postmark and SendGrid support: - - .. code-block:: console - - $ pip install django-anymail[postmark,sendgrid] +If you don't want to use pip, you'll also need to install Anymail's +dependencies (requests and six). .. _backend-configuration: diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 73dad63..a4ea7e6 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -19,18 +19,15 @@ Figuring out what's wrong **Check your ESPs API logs** - Many ESPs offer an incredibly-helpful log - of your recent API calls in their dashboards. Check the logs to see if the + Most ESPs offer some sort of API activity log in their dashboards. + Check the logs to see if the data you thought you were sending actually made it to your ESP, and if they recorded any errors there. **Double-check common issues** - * Did you install Anymail with the ESPs you want available? - (E.g., `pip install django-anymail[mailgun,sendgrid]` -- - *not* just `pip install django-anymail`.) - * Did you add any required settings for those ESPs to your settings.py? - (E.g., `ANYMAIL_MANDRILL_API_KEY`.) + * Did you add any required settings for your ESP to your settings.py? + (E.g., `ANYMAIL_SENDGRID_API_KEY` for SendGrid.) See :ref:`supported-esps`. * Did you add ``'anymail'`` to the list of :setting:`INSTALLED_APPS` in settings.py? * Are you using a valid from address? Django's default is "webmaster@localhost", which won't cut it. Either specify the ``from_email`` explicitly on every message diff --git a/setup.py b/setup.py index b85287a..06a17cc 100644 --- a/setup.py +++ b/setup.py @@ -31,11 +31,15 @@ setup( license="BSD License", packages=["anymail"], zip_safe=False, - install_requires=["django>=1.8", "six"], + install_requires=["django>=1.8", "requests>=2.4.3", "six"], extras_require={ - "mailgun": ["requests>=2.4.3"], - "mandrill": ["requests>=1.0.0"], - "sendgrid": ["requests>=2.4.3"], + # This can be used if particular backends have unique dependencies + # (e.g., AWS-SES would want boto). + # For simplicity, requests is included in the base requirements. + "mailgun": [], + "mandrill": [], + "postmark": [], + "sendgrid": [], }, include_package_data=True, test_suite="runtests.runtests",