diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index af950715..39144e92 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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) diff --git a/Makefile b/Makefile index 96161106..3e2f846c 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index b1b36686..a508b0dd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README.rst b/README.rst index 526c4ca4..e5dc437b 100644 --- a/README.rst +++ b/README.rst @@ -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`_ diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 0a7f54c6..5eb1011e 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -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 diff --git a/requirements.txt b/requirements.txt index ed2594a9..c1781089 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 diff --git a/setup.py b/setup.py index 904cd654..bcc512cc 100644 --- a/setup.py +++ b/setup.py @@ -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", + ], ) diff --git a/tox.ini b/tox.ini index 8f4f2db9..f5c44d9b 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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} diff --git a/use_cases/aws.md b/use_cases/aws.md index 2e63bd1f..b191bec9 100644 --- a/use_cases/aws.md +++ b/use_cases/aws.md @@ -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/). @@ -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']] diff --git a/use_cases/legacy_templates.md b/use_cases/legacy_templates.md index c8188a25..cbc12498 100644 --- a/use_cases/legacy_templates.md +++ b/use_cases/legacy_templates.md @@ -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") @@ -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 = { diff --git a/use_cases/sending_html_content.md b/use_cases/sending_html_content.md index 4a828e73..d80a6f69 100644 --- a/use_cases/sending_html_content.md +++ b/use_cases/sending_html_content.md @@ -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 = """