mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
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:
@@ -33,8 +33,6 @@ cache:
|
|||||||
install:
|
install:
|
||||||
- pip install --upgrade setuptools pip
|
- pip install --upgrade setuptools pip
|
||||||
- pip install $DJANGO
|
- pip install $DJANGO
|
||||||
# For now, install all ESPs and test at once
|
- pip install .
|
||||||
# (in future, might want to matrix ESPs to test cross-dependencies)
|
|
||||||
- pip install .[mailgun,mandrill,sendgrid]
|
|
||||||
- pip list
|
- pip list
|
||||||
script: python -Wall setup.py test
|
script: python -Wall setup.py test
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ Anymail 1-2-3
|
|||||||
This example uses Mailgun, but you can substitute Postmark or SendGrid
|
This example uses Mailgun, but you can substitute Postmark or SendGrid
|
||||||
or any other supported ESP where you see "mailgun":
|
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
|
.. code-block:: console
|
||||||
|
|
||||||
$ pip install django-anymail[mailgun] # or [postmark,sendgrid] or ...
|
$ pip install django-anymail
|
||||||
|
|
||||||
|
|
||||||
2. Edit your project's ``settings.py``:
|
2. Edit your project's ``settings.py``:
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
|
import requests
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from six.moves.urllib.parse import urljoin
|
from six.moves.urllib.parse import urljoin
|
||||||
|
|
||||||
from .base import AnymailBaseBackend, BasePayload
|
from .base import AnymailBaseBackend, BasePayload
|
||||||
from ..exceptions import AnymailImproperlyInstalled, AnymailRequestsAPIError, AnymailSerializationError
|
from ..exceptions import AnymailRequestsAPIError, AnymailSerializationError
|
||||||
from .._version import __version__
|
from .._version import __version__
|
||||||
|
|
||||||
try:
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
import requests
|
|
||||||
except ImportError:
|
|
||||||
raise AnymailImproperlyInstalled('requests')
|
|
||||||
|
|
||||||
|
|
||||||
class AnymailRequestsBackend(AnymailBaseBackend):
|
class AnymailRequestsBackend(AnymailBaseBackend):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.mail import make_msgid
|
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 ..message import AnymailRecipientStatus
|
||||||
from ..utils import get_anymail_setting, timestamp
|
from ..utils import get_anymail_setting, timestamp
|
||||||
|
|
||||||
from .base_requests import AnymailRequestsBackend, RequestsPayload
|
from .base_requests import AnymailRequestsBackend, RequestsPayload
|
||||||
|
|
||||||
try:
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from requests.structures import CaseInsensitiveDict
|
|
||||||
except ImportError:
|
|
||||||
raise AnymailImproperlyInstalled('requests', backend="sendgrid")
|
|
||||||
|
|
||||||
|
|
||||||
class SendGridBackend(AnymailRequestsBackend):
|
class SendGridBackend(AnymailRequestsBackend):
|
||||||
|
|||||||
@@ -1,14 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
from requests import HTTPError
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class AnymailError(Exception):
|
class AnymailError(Exception):
|
||||||
|
|||||||
@@ -6,24 +6,14 @@ Installation and configuration
|
|||||||
Installing Anymail
|
Installing Anymail
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
Install Anymail from PyPI using pip.
|
It's easiest to 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:
|
|
||||||
|
|
||||||
.. code-block:: console
|
.. code-block:: console
|
||||||
|
|
||||||
$ pip install django-anymail[mailgun]
|
$ pip install django-anymail
|
||||||
|
|
||||||
...or with both Postmark and SendGrid support:
|
If you don't want to use pip, you'll also need to install Anymail's
|
||||||
|
dependencies (requests and six).
|
||||||
.. code-block:: console
|
|
||||||
|
|
||||||
$ pip install django-anymail[postmark,sendgrid]
|
|
||||||
|
|
||||||
|
|
||||||
.. _backend-configuration:
|
.. _backend-configuration:
|
||||||
|
|||||||
@@ -19,18 +19,15 @@ Figuring out what's wrong
|
|||||||
|
|
||||||
**Check your ESPs API logs**
|
**Check your ESPs API logs**
|
||||||
|
|
||||||
Many ESPs offer an incredibly-helpful log
|
Most ESPs offer some sort of API activity log in their dashboards.
|
||||||
of your recent API calls in their dashboards. Check the logs to see if the
|
Check the logs to see if the
|
||||||
data you thought you were sending actually made it to your ESP, and
|
data you thought you were sending actually made it to your ESP, and
|
||||||
if they recorded any errors there.
|
if they recorded any errors there.
|
||||||
|
|
||||||
**Double-check common issues**
|
**Double-check common issues**
|
||||||
|
|
||||||
* Did you install Anymail with the ESPs you want available?
|
* Did you add any required settings for your ESP to your settings.py?
|
||||||
(E.g., `pip install django-anymail[mailgun,sendgrid]` --
|
(E.g., `ANYMAIL_SENDGRID_API_KEY` for SendGrid.) See :ref:`supported-esps`.
|
||||||
*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 ``'anymail'`` to the list of :setting:`INSTALLED_APPS` in settings.py?
|
* 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",
|
* 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
|
which won't cut it. Either specify the ``from_email`` explicitly on every message
|
||||||
|
|||||||
12
setup.py
12
setup.py
@@ -31,11 +31,15 @@ setup(
|
|||||||
license="BSD License",
|
license="BSD License",
|
||||||
packages=["anymail"],
|
packages=["anymail"],
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
install_requires=["django>=1.8", "six"],
|
install_requires=["django>=1.8", "requests>=2.4.3", "six"],
|
||||||
extras_require={
|
extras_require={
|
||||||
"mailgun": ["requests>=2.4.3"],
|
# This can be used if particular backends have unique dependencies
|
||||||
"mandrill": ["requests>=1.0.0"],
|
# (e.g., AWS-SES would want boto).
|
||||||
"sendgrid": ["requests>=2.4.3"],
|
# For simplicity, requests is included in the base requirements.
|
||||||
|
"mailgun": [],
|
||||||
|
"mandrill": [],
|
||||||
|
"postmark": [],
|
||||||
|
"sendgrid": [],
|
||||||
},
|
},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
test_suite="runtests.runtests",
|
test_suite="runtests.runtests",
|
||||||
|
|||||||
Reference in New Issue
Block a user