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.
This commit is contained in:
medmunds
2016-03-14 13:26:06 -07:00
parent f95bf1fbc4
commit fed98b14a8
8 changed files with 24 additions and 51 deletions

View File

@@ -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

View File

@@ -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``:

View File

@@ -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):
"""

View File

@@ -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):

View File

@@ -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):

View File

@@ -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:

View File

@@ -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

View File

@@ -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",