Skip to content

Commit fed98b1

Browse files
committed
install: remove need to name [esp]
Simplify install to just `pip install django-anymail`. (Rather than `... django-anymail[mailgun]` All of the ESPs so far require requests, so just move that into the base requirements. (Chances are your Django app already needs requests for some other reason, anyway.) Truly unique ESP dependencies (e.g., boto for AWS-SES) could still use the setup extra features mechanism.
1 parent f95bf1f commit fed98b1

File tree

8 files changed

+24
-51
lines changed

8 files changed

+24
-51
lines changed

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ cache:
3333
install:
3434
- pip install --upgrade setuptools pip
3535
- pip install $DJANGO
36-
# For now, install all ESPs and test at once
37-
# (in future, might want to matrix ESPs to test cross-dependencies)
38-
- pip install .[mailgun,mandrill,sendgrid]
36+
- pip install .
3937
- pip list
4038
script: python -Wall setup.py test

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ Anymail 1-2-3
7272
This example uses Mailgun, but you can substitute Postmark or SendGrid
7373
or any other supported ESP where you see "mailgun":
7474

75-
1. Install Anymail from PyPI, including the ESP(s) you want to use:
75+
1. Install Anymail from PyPI:
7676

7777
.. code-block:: console
7878
79-
$ pip install django-anymail[mailgun] # or [postmark,sendgrid] or ...
79+
$ pip install django-anymail
8080
8181
8282
2. Edit your project's ``settings.py``:

anymail/backends/base_requests.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import json
22

3+
import requests
34
# noinspection PyUnresolvedReferences
45
from six.moves.urllib.parse import urljoin
56

67
from .base import AnymailBaseBackend, BasePayload
7-
from ..exceptions import AnymailImproperlyInstalled, AnymailRequestsAPIError, AnymailSerializationError
8+
from ..exceptions import AnymailRequestsAPIError, AnymailSerializationError
89
from .._version import __version__
910

10-
try:
11-
# noinspection PyUnresolvedReferences
12-
import requests
13-
except ImportError:
14-
raise AnymailImproperlyInstalled('requests')
15-
1611

1712
class AnymailRequestsBackend(AnymailBaseBackend):
1813
"""

anymail/backends/sendgrid.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
from django.core.exceptions import ImproperlyConfigured
22
from django.core.mail import make_msgid
3+
from requests.structures import CaseInsensitiveDict
34

4-
from ..exceptions import AnymailImproperlyInstalled, AnymailRequestsAPIError
5+
from ..exceptions import AnymailRequestsAPIError
56
from ..message import AnymailRecipientStatus
67
from ..utils import get_anymail_setting, timestamp
78

89
from .base_requests import AnymailRequestsBackend, RequestsPayload
910

10-
try:
11-
# noinspection PyUnresolvedReferences
12-
from requests.structures import CaseInsensitiveDict
13-
except ImportError:
14-
raise AnymailImproperlyInstalled('requests', backend="sendgrid")
1511

1612

1713
class SendGridBackend(AnymailRequestsBackend):

anymail/exceptions.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import json
22

33
from django.core.exceptions import ImproperlyConfigured
4-
5-
try:
6-
from requests import HTTPError
7-
except ImportError:
8-
# Backends that don't use requests aren't required to have it installed
9-
# (and could never raise an AnymailRequestsAPIError)
10-
class HTTPError(Exception):
11-
pass
4+
from requests import HTTPError
125

136

147
class AnymailError(Exception):

docs/installation.rst

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,14 @@ Installation and configuration
66
Installing Anymail
77
------------------
88

9-
Install Anymail from PyPI using pip.
10-
11-
Anymail uses python setuptools' "extra features" to pull in dependencies
12-
for specific ESPs. (This avoids installing packages needed by ESPs
13-
you aren't using.)
14-
15-
You'll want to include at least one ESP as an extra in your pip command.
16-
E.g., for Anymail with Mailgun support:
9+
It's easiest to install Anymail from PyPI using pip.
1710

1811
.. code-block:: console
1912
20-
$ pip install django-anymail[mailgun]
21-
22-
...or with both Postmark and SendGrid support:
23-
24-
.. code-block:: console
13+
$ pip install django-anymail
2514
26-
$ pip install django-anymail[postmark,sendgrid]
15+
If you don't want to use pip, you'll also need to install Anymail's
16+
dependencies (requests and six).
2717

2818

2919
.. _backend-configuration:

docs/troubleshooting.rst

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ Figuring out what's wrong
1919

2020
**Check your ESPs API logs**
2121

22-
Many ESPs offer an incredibly-helpful log
23-
of your recent API calls in their dashboards. Check the logs to see if the
22+
Most ESPs offer some sort of API activity log in their dashboards.
23+
Check the logs to see if the
2424
data you thought you were sending actually made it to your ESP, and
2525
if they recorded any errors there.
2626

2727
**Double-check common issues**
2828

29-
* Did you install Anymail with the ESPs you want available?
30-
(E.g., `pip install django-anymail[mailgun,sendgrid]` --
31-
*not* just `pip install django-anymail`.)
32-
* Did you add any required settings for those ESPs to your settings.py?
33-
(E.g., `ANYMAIL_MANDRILL_API_KEY`.)
29+
* Did you add any required settings for your ESP to your settings.py?
30+
(E.g., `ANYMAIL_SENDGRID_API_KEY` for SendGrid.) See :ref:`supported-esps`.
3431
* Did you add ``'anymail'`` to the list of :setting:`INSTALLED_APPS` in settings.py?
3532
* Are you using a valid from address? Django's default is "webmaster@localhost",
3633
which won't cut it. Either specify the ``from_email`` explicitly on every message

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@ def long_description_from_readme(rst):
3131
license="BSD License",
3232
packages=["anymail"],
3333
zip_safe=False,
34-
install_requires=["django>=1.8", "six"],
34+
install_requires=["django>=1.8", "requests>=2.4.3", "six"],
3535
extras_require={
36-
"mailgun": ["requests>=2.4.3"],
37-
"mandrill": ["requests>=1.0.0"],
38-
"sendgrid": ["requests>=2.4.3"],
36+
# This can be used if particular backends have unique dependencies
37+
# (e.g., AWS-SES would want boto).
38+
# For simplicity, requests is included in the base requirements.
39+
"mailgun": [],
40+
"mandrill": [],
41+
"postmark": [],
42+
"sendgrid": [],
3943
},
4044
include_package_data=True,
4145
test_suite="runtests.runtests",

0 commit comments

Comments
 (0)