Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ We welcome direct contributions to the sendgrid-python code base. Thank you!

#### Prerequisites

- Python version 2.7, 3.5, 3.6, 3.7, or 3.8
- Python version 3.8+
- [python_http_client](https://github.com/sendgrid/python-http-client)
- [cryptography](https://github.com/pyca/cryptography)
- [pyenv](https://github.com/yyuu/pyenv)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: venv install test-install test test-integ test-docker clean nopyc

venv: clean
@python --version || (echo "Python is not installed, please install Python 2 or Python 3"; exit 1);
@python --version || (echo "Python is not installed, please install Python 3"; exit 1);
pip install virtualenv
virtualenv --python=python venv

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Please browse the rest of this README for further detail.

## Prerequisites

- Python version 2.7+
- Python version 3.8+
- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-python)

## Setup Environment Variables
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Installation
Prerequisites
-------------

- Python version 2.7 and 3.5+
- Python version 3.8+
- For email, you will need a Twilio SendGrid account, starting at the `free level`_
- For SMS messages, you will need a free `Twilio account`_

Expand Down
11 changes: 0 additions & 11 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,6 @@ In the first case, SENDGRID_API_KEY is in reference to the name of the environme

HTTP exceptions are defined in the [`python_http_client` package](https://github.com/sendgrid/python-http-client/blob/HEAD/python_http_client/exceptions.py).

To read the error message returned by SendGrid's API in Python 2.X:

```python
from python_http_client.exceptions import HTTPError

try:
response = sg.client.mail.send.post(request_body=mail.get())
except HTTPError as e:
print e.to_dict
```

To read the error message returned by Twilio SendGrid's API in Python 3.X:

```python
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Flask==3.1.0
PyYAML>=4.2b1
python-http-client>=3.2.1
six==1.17.0
cryptography>=45.0.6
cryptography>=44.0.1
more-itertools==5.0.0
54 changes: 23 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,46 @@
import io
import os
from setuptools import setup, find_packages

from setuptools import find_packages, setup

__version__ = None
with open('sendgrid/version.py') as f:
with open("sendgrid/version.py") as f:
exec(f.read())


def getRequires():
deps = [
'python_http_client>=3.2.1',
'cryptography>=45.0.6',
"werkzeug>=0.11.15,<1.0.0 ; python_version < '3.0'",
"werkzeug>=0.15.0,<2.0.0 ; python_version >= '3.0' and python_version < '3.7'",
"werkzeug>=0.15.0,<2.3.0 ; python_version >= '3.0' and python_version < '3.8'", # version 2.3.0 dropped support for Python 3.7
"werkzeug>=0.16.0,<3.1.0 ; python_version >= '3.0' and python_version < '3.9'", # version 3.1.0 dropped support for Python 3.8
"werkzeug>=1.0.0 ; python_version >= '3.9'",
"werkzeug>=2.2.0 ; python_version >= '3.11'",
"werkzeug>=2.3.5 ; python_version >= '3.12'"
"python_http_client>=3.2.1",
"cryptography>=44.0.1",
"werkzeug==3.0.6 ; python_version == '3.8'", # version 3.1.0 dropped support for Python 3.8
"werkzeug>=3.0.6 ; python_version >= '3.9'",
]
return deps


dir_path = os.path.abspath(os.path.dirname(__file__))
readme = io.open(os.path.join(dir_path, 'README.rst'), encoding='utf-8').read()
readme = io.open(os.path.join(dir_path, "README.rst"), encoding="utf-8").read()

setup(
name='sendgrid',
name="sendgrid",
version=str(__version__),
author='Elmer Thomas, Yamil Asusta',
author_email='help@twilio.com',
url='https://github.com/sendgrid/sendgrid-python/',
author="Elmer Thomas, Yamil Asusta",
author_email="help@twilio.com",
url="https://github.com/sendgrid/sendgrid-python/",
packages=find_packages(exclude=["temp*.py", "test"]),
include_package_data=True,
license='MIT',
description='Twilio SendGrid library for Python',
license="MIT",
description="Twilio SendGrid library for Python",
long_description=readme,
install_requires=getRequires(),
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*',
python_requires=">=3.8",
classifiers=[
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
]
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
)
28 changes: 1 addition & 27 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py27, py34, py35, py36, py37, py38, py39, py310, py311, py312, py313
envlist = py38, py39, py310, py311, py312, py313

[testenv]
commands = coverage erase
Expand All @@ -14,32 +14,6 @@ deps = -rrequirements.txt
coverage


[testenv:py27]
commands = {[testenv]commands}
deps = {[testenv]deps}
mock
basepython = python2.7

[testenv:py34]
commands = {[testenv]commands}
deps = {[testenv]deps}
basepython = python3.4

[testenv:py35]
commands = {[testenv]commands}
deps = {[testenv]deps}
basepython = python3.5

[testenv:py36]
commands = {[testenv]commands}
deps = {[testenv]deps}
basepython = python3.6

[testenv:py37]
commands = {[testenv]commands}
deps = {[testenv]deps}
basepython = python3.7

[testenv:py38]
commands = {[testenv]commands}
deps = {[testenv]deps}
Expand Down
3 changes: 1 addition & 2 deletions use_cases/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ The neat thing is that CodeStar provides all of this in a pre-configured package
Once this tutorial is complete, you'll have a basic web service for sending email that can be invoked via a link to your newly created API endpoint.

### Prerequisites
Python 2.7 and 3.4 or 3.5 are supported by the sendgrid Python library, however, I was able to utilize 3.6 with no issue.

Before starting this tutorial, you will need to have access to an AWS account in which you are allowed to provision resources. This tutorial also assumes you've already created a Twilio SendGrid account with free-tier access. Finally, it is highly recommended you utilize [virtualenv](https://virtualenv.pypa.io/en/stable/).

Expand Down Expand Up @@ -77,7 +76,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: python3.6
Runtime: python3.9
Role:
Fn::ImportValue:
!Join ['-', [!Ref 'ProjectId', !Ref 'AWS::Region', 'LambdaTrustRole']]
Expand Down
14 changes: 2 additions & 12 deletions use_cases/legacy_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ I hope you are having a great day in -city- :)
import sendgrid
import os
from sendgrid.helpers.mail import Email, Content, Substitution, Mail
try:
# Python 3
import urllib.request as urllib
except ImportError:
# Python 2
import urllib2 as urllib
import urllib.request as urllib

sg = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
from_email = Email("test@example.com")
Expand All @@ -71,12 +66,7 @@ print(response.headers)
```python
import sendgrid
import os
try:
# Python 3
import urllib.request as urllib
except ImportError:
# Python 2
import urllib2 as urllib
import urllib.request as urllib

sg = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
data = {
Expand Down
7 changes: 1 addition & 6 deletions use_cases/sending_html_content.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ Currently, we require both HTML and Plain Text content for improved deliverabili
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import From, To, Subject, PlainTextContent, HtmlContent, Mail
try:
# Python 3
import urllib.request as urllib
except ImportError:
# Python 2
import urllib2 as urllib
import urllib.request as urllib
from bs4 import BeautifulSoup

html_text = """
Expand Down