From f0899dc9b24fb1da4ddcf4485dbed7f95ce5d43d Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Thu, 4 Oct 2018 23:48:50 +0300 Subject: [PATCH 1/2] converted README and version as plain text --- .gitignore | 2 +- .travis.yml | 3 - MANIFEST.in | 4 +- README.md | 233 ------------------------------- README.rst | 317 ++++++++++++++++++++++++++++++++++++++++++ VERSION.txt | 1 + register.py | 20 --- sendgrid/__init__.py | 8 +- sendgrid/sendgrid.py | 6 +- sendgrid/version.py | 2 - setup.py | 27 ++-- test/test_project.py | 8 +- test/test_sendgrid.py | 3 +- 13 files changed, 352 insertions(+), 282 deletions(-) delete mode 100644 README.md create mode 100644 README.rst create mode 100644 VERSION.txt delete mode 100644 register.py delete mode 100644 sendgrid/version.py diff --git a/.gitignore b/.gitignore index 96232a5bf..4ac2623b4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,4 @@ htmlcov temp*.py sendgrid.env .vscode - +sendgrid/VERSION.txt diff --git a/.travis.yml b/.travis.yml index 5ad33bccf..5be160182 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,6 @@ install: - pip install pyyaml - pip install flask - pip install six -- pip install pypandoc - pip install coverage - pip install codecov # - sudo apt-get install -y pandoc @@ -34,8 +33,6 @@ script: after_script: - codecov - ./cc-test-reporter after-build --exit-code $? -before_deploy: -- python ./register.py deploy: provider: pypi user: thinkingserious diff --git a/MANIFEST.in b/MANIFEST.in index 94d2153e7..3833b2419 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,8 @@ include README.rst include LICENSE.txt +include VERSION.txt include app.json include Procfile include requirements.txt -recursive-exclude test * +recursive-include sendgrid *.py *.txt +prune test diff --git a/README.md b/README.md deleted file mode 100644 index f019c1ce3..000000000 --- a/README.md +++ /dev/null @@ -1,233 +0,0 @@ -![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) - -[![Travis Badge](https://travis-ci.org/sendgrid/sendgrid-python.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-python) -[![codecov](https://img.shields.io/codecov/c/github/sendgrid/sendgrid-python/master.svg?style=flat-square&label=Codecov+Coverage)](https://codecov.io/gh/sendgrid/sendgrid-python) -[![Docker Badge](https://img.shields.io/docker/automated/sendgrid/sendgrid-python.svg)](https://hub.docker.com/r/sendgrid/sendgrid-python/) -[![Email Notifications Badge](https://dx.sendgrid.com/badge/python)](https://dx.sendgrid.com/newsletter/python) -[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt) -[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid) -[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-python.svg)](https://github.com/sendgrid/sendgrid-python/graphs/contributors) -[![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-python/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-python) - -**NEW:** - -* Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/python) for releases and breaking changes. -* Quickly get started with [Docker](https://github.com/sendgrid/sendgrid-python/tree/master/docker). - -**This library allows you to quickly and easily use the SendGrid Web API v3 via Python.** - -Version 3.X.X+ of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint). - -This library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-python/issues) and [pull requests](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests. - -Please browse the rest of this README for further detail. - -We appreciate your continued support, thank you! - -# Table of Contents - -* [Installation](#installation) -* [Quick Start](#quick-start) -* [Processing Inbound Email](#inbound) -* [Usage](#usage) -* [Use Cases](#use-cases) -* [Announcements](#announcements) -* [Roadmap](#roadmap) -* [How to Contribute](#contribute) -* [Troubleshooting](#troubleshooting) -* [About](#about) -* [License](#license) - - - -# Installation - -## Prerequisites - -- Python version 2.6, 2.7, 3.4, 3.5 or 3.6 -- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-python) - -## Setup Environment Variables -### Mac - -Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) (more info [here](https://sendgrid.com/docs/User_Guide/Settings/api_keys.html)), for example: - -```bash -echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env -echo "sendgrid.env" >> .gitignore -source ./sendgrid.env -``` -SendGrid also supports local environment file `.env`. Copy or rename `.env_sample` into `.env` and update [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) with your key. - -### Windows -Temporarily set the environment variable(accessible only during the current cli session): -```bash -set SENDGRID_API_KEY=YOUR_API_KEY -``` -Permanently set the environment variable(accessible in all subsequent cli sessions): -```bash -setx SENDGRID_API_KEY "YOUR_API_KEY" -``` - -## Install Package -```bash -pip install sendgrid -``` - -## Dependencies - -- [Python-HTTP-Client](https://github.com/sendgrid/python-http-client) - - - -# Quick Start - -## Hello Email - -The following is the minimum needed code to send an email with the [/mail/send Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) ([here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/helpers/mail/mail_example.py#L20) is a full example): - -### With Mail Helper Class - -```python -import sendgrid -import os -from sendgrid.helpers.mail import * - -sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) -from_email = Email("test@example.com") -to_email = Email("test@example.com") -subject = "Sending with SendGrid is Fun" -content = Content("text/plain", "and easy to do anywhere, even with Python") -mail = Mail(from_email, subject, to_email, content) -response = sg.client.mail.send.post(request_body=mail.get()) -print(response.status_code) -print(response.body) -print(response.headers) -``` - -The `Mail` constructor creates a [personalization object](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html) for you. [Here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/helpers/mail_example.py#L16) is an example of how to add it. - -### Without Mail Helper Class - -The following is the minimum needed code to send an email without the /mail/send Helper ([here](https://github.com/sendgrid/sendgrid-python/blob/master/examples/mail/mail.py#L27) is a full example): - -```python -import sendgrid -import os - -sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) -data = { - "personalizations": [ - { - "to": [ - { - "email": "test@example.com" - } - ], - "subject": "Sending with SendGrid is Fun" - } - ], - "from": { - "email": "test@example.com" - }, - "content": [ - { - "type": "text/plain", - "value": "and easy to do anywhere, even with Python" - } - ] -} -response = sg.client.mail.send.post(request_body=data) -print(response.status_code) -print(response.body) -print(response.headers) -``` - -## General v3 Web API Usage (With [Fluent Interface](https://sendgrid.com/blog/using-python-to-implement-a-fluent-interface-to-any-rest-api/)) - -```python -import sendgrid -import os - -sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) -response = sg.client.suppression.bounces.get() -print(response.status_code) -print(response.body) -print(response.headers) -``` - -## General v3 Web API Usage (Without Fluent Interface) - -```python -import sendgrid -import os - -sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) -response = sg.client._("suppression/bounces").get() -print(response.status_code) -print(response.body) -print(response.headers) -``` - - -# Processing Inbound Email - -Please see [our helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook. - - -# Usage - -- [SendGrid Documentation](https://sendgrid.com/docs/API_Reference/index.html) -- [Library Usage Documentation](https://github.com/sendgrid/sendgrid-python/tree/master/USAGE.md) -- [Example Code](https://github.com/sendgrid/sendgrid-python/tree/master/examples) -- [How-to: Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) -- [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call. -- [Processing Inbound Email](https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/inbound) - - -# Use Cases - -[Examples of common API use cases](https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/README.md), such as how to send an email with a transactional template. - - -# Announcements - -Join an experienced and passionate team that focuses on making an impact. Opportunities abound to grow the product - and grow your career! Check out our [Data Platform Engineer role](http://grnh.se/wbx1701) - -Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-python/issues/217). Your support is appreciated! - -All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/java) for releases and breaking changes. - - -# Roadmap - -If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/sendgrid/sendgrid-python/issues) and [pull requests](https://github.com/sendgrid/sendgrid-python/pulls). We would love to hear your feedback. - - -# How to Contribute - -We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md) guide for details. - -Quick links: - -- [Feature Request](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#feature-request) -- [Bug Reports](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#submit-a-bug-report) -- [Sign the CLA to Create a Pull Request](https://cla.sendgrid.com/sendgrid/sendgrid-python) -- [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#improvements-to-the-codebase) -- [Review Pull Requests](https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#code-reviews) - - -# Troubleshooting - -Please see our [troubleshooting guide](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md) for common library issues. - - -# About - -sendgrid-python is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com). - -sendgrid-python is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-python are trademarks of SendGrid, Inc. - - -# License -[The MIT License (MIT)](LICENSE.txt) diff --git a/README.rst b/README.rst new file mode 100644 index 000000000..0557fffa0 --- /dev/null +++ b/README.rst @@ -0,0 +1,317 @@ +.. image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png + :target: https://www.sendgrid.com + +|Travis Badge| |codecov| |Python Versions| |PyPI Version| |Docker Badge| |Email Notifications Badge| |MIT licensed| |Twitter Follow| |GitHub contributors| |Open Source Helpers| + +**NEW:** + +- Subscribe to email `notifications`_ for releases and breaking changes. +- Quickly get started with `Docker`_. + +**This library allows you to quickly and easily use the SendGrid Web API v3 via Python.** + +Version 3.X.X+ of this library provides full support for all SendGrid `Web API v3`_ endpoints, including the new `v3 /mail/send`_. + +This library represents the beginning of a new path for SendGrid. +We want this library to be community driven and SendGrid led. +We need your help to realize this goal. +To help make sure we are building the right things in the right order, +we ask that you create `issues`_ and `pull requests`_ or simply upvote or comment on existing issues or pull requests. + +Please browse the rest of this README for further detail. + +We appreciate your continued support, thank you! + +Table of Contents +================= + +- `Installation <#installation>`__ +- `Quick Start <#quick-start>`__ +- `Processing Inbound Email <#processing-inbound-email>`__ +- `Usage <#usage>`__ +- `Use Cases <#use-cases>`__ +- `Announcements <#announcements>`__ +- `Roadmap <#roadmap>`__ +- `How to Contribute <#how-to-contribute>`__ +- `Troubleshooting <#troubleshooting>`__ +- `About <#about>`__ +- `License <#license>`__ + +Installation +============ + +Prerequisites +------------- + +- Python version 2.6, 2.7, 3.4, 3.5 or 3.6 +- The SendGrid service, starting at the `free level`_ + +Setup Environment Variables +--------------------------- + +Mac +~~~ + +Update the development environment with your `SENDGRID_API_KEY`_ (more info `here `__), for example: + +.. code:: bash + + echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env + echo "sendgrid.env" >> .gitignore + source ./sendgrid.env + +SendGrid also supports local environment file ``.env``. +Copy or rename ``.env_sample`` into ``.env`` and update `SENDGRID_API_KEY`_ with your key. + +Windows +~~~~~~~ + +Temporarily set the environment variable (accessible only during the current CLI session): + +.. code:: bash + + set SENDGRID_API_KEY=YOUR_API_KEY + +Permanently set the environment variable (accessible in all subsequent CLI sessions): + +.. code:: bash + + setx SENDGRID_API_KEY "YOUR_API_KEY" + +Install Package +--------------- + +.. code:: bash + + pip install sendgrid + +Dependencies +------------ + +- `Python-HTTP-Client`_ + +Quick Start +=========== + +Hello Email +----------- + +The following is the minimum needed code to send an email with the `/mail/send Helper`_ +(`here `__ is a full example): + +With Mail Helper Class +~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: python + + import sendgrid + import os + from sendgrid.helpers.mail import * + + sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) + from_email = Email("test@example.com") + to_email = Email("test@example.com") + subject = "Sending with SendGrid is Fun" + content = Content("text/plain", "and easy to do anywhere, even with Python") + mail = Mail(from_email, subject, to_email, content) + response = sg.client.mail.send.post(request_body=mail.get()) + print(response.status_code) + print(response.body) + print(response.headers) + +The ``Mail`` constructor creates a `personalization object`_ for you. +`Here `__ is an example of how to add it. + +Without Mail Helper Class +~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following is the minimum needed code to send an email without the /mail/send Helper +(`here `__ is a full example): + +.. code:: python + + import sendgrid + import os + + sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) + data = { + "personalizations": [ + { + "to": [ + { + "email": "test@example.com" + } + ], + "subject": "Sending with SendGrid is Fun" + } + ], + "from": { + "email": "test@example.com" + }, + "content": [ + { + "type": "text/plain", + "value": "and easy to do anywhere, even with Python" + } + ] + } + response = sg.client.mail.send.post(request_body=data) + print(response.status_code) + print(response.body) + print(response.headers) + +General v3 Web API Usage (With `Fluent Interface`_) +--------------------------------------------------- + +.. code:: python + + import sendgrid + import os + + sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) + response = sg.client.suppression.bounces.get() + print(response.status_code) + print(response.body) + print(response.headers) + +General v3 Web API Usage (Without `Fluent Interface`_) +------------------------------------------------------ + +.. code:: python + + import sendgrid + import os + + sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) + response = sg.client._("suppression/bounces").get() + print(response.status_code) + print(response.body) + print(response.headers) + +Processing Inbound Email +======================== + +Please see `our helper`_ for utilizing our Inbound Parse webhook. + +Usage +===== + +- `SendGrid Documentation`_ +- `Library Usage Documentation`_ +- `Example Code`_ +- `How-to: Migration from v2 to v3`_ +- `v3 Web API Mail Send Helper`_ - build a request object payload for a v3 /mail/send API call. +- `Processing Inbound Email`_ + +Use Cases +========= + +`Examples of common API use cases`_, such as how to send an email with a transactional template. + +Announcements +============= + +Join an experienced and passionate team that focuses on making an impact. +Opportunities abound to grow the product - and grow your career! +Check out our `Data Platform Engineer role`_. + +Please see our announcement regarding `breaking changes`_. +Your support is appreciated! + +All updates to this library are documented in our `CHANGELOG`_ and `releases`_. +You may also subscribe to email `release notifications`_ for releases and breaking changes. + +Roadmap +======= + +If you are interested in the future direction of this project, +please take a look at our open `issues`_ and `pull requests `__. +We would love to hear your feedback. + +How to Contribute +================= + +We encourage contribution to our libraries (you might even score some nifty swag), please see our `CONTRIBUTING`_ guide for details. + +Quick links: + +- `Feature Request`_ +- `Bug Reports`_ +- `Improvements to the Codebase`_ +- `Review Pull Requests`_ +- `Sign the CLA to Create a Pull Request`_ + +Troubleshooting +=============== + +Please see our `troubleshooting guide`_ for common library issues. + +About +===== + +**sendgrid-python** is guided and supported by the SendGrid Developer Experience Team. +Email the Developer Experience Team `here `__ in case of any queries. + +**sendgrid-python** is maintained and funded by SendGrid, Inc. +The names and logos for **sendgrid-python** are trademarks of SendGrid, Inc. + +License +======= + +`The MIT License (MIT)`_ + +.. _notifications: https://dx.sendgrid.com/newsletter/python +.. _Docker: https://github.com/sendgrid/sendgrid-python/tree/master/docker +.. _Web API v3: https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html +.. _v3 /mail/send: https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint +.. _issues: https://github.com/sendgrid/sendgrid-python/issues +.. _pull requests: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md +.. _free level: https://sendgrid.com/free?source=sendgrid-python +.. _SENDGRID_API_KEY: https://app.sendgrid.com/settings/api_keys +.. _Python-HTTP-Client: https://github.com/sendgrid/python-http-client +.. _/mail/send Helper: https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail +.. _personalization object: https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/personalizations.html +.. _Fluent Interface: https://sendgrid.com/blog/using-python-to-implement-a-fluent-interface-to-any-rest-api/ +.. _our helper: https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/inbound +.. _SendGrid Documentation: https://sendgrid.com/docs/API_Reference/index.html +.. _Library Usage Documentation: https://github.com/sendgrid/sendgrid-python/tree/master/USAGE.md +.. _Example Code: https://github.com/sendgrid/sendgrid-python/tree/master/examples +.. _`How-to: Migration from v2 to v3`: https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html +.. _v3 Web API Mail Send Helper: https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/mail +.. _Processing Inbound Email: https://github.com/sendgrid/sendgrid-python/tree/master/sendgrid/helpers/inbound +.. _Examples of common API use cases: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/README.md +.. _Data Platform Engineer role: http://grnh.se/wbx1701 +.. _breaking changes: https://github.com/sendgrid/sendgrid-python/issues/217 +.. _CHANGELOG: https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md +.. _releases: https://github.com/sendgrid/sendgrid-python/releases +.. _release notifications: https://dx.sendgrid.com/newsletter/python +.. _CONTRIBUTING: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md +.. _Feature Request: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#feature-request +.. _Bug Reports: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#submit-a-bug-report +.. _Sign the CLA to Create a Pull Request: https://cla.sendgrid.com/sendgrid/sendgrid-python +.. _Improvements to the Codebase: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#improvements-to-the-codebase +.. _Review Pull Requests: https://github.com/sendgrid/sendgrid-python/blob/master/CONTRIBUTING.md#code-reviews +.. _troubleshooting guide: https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md +.. _Developer Experience Team: mailto:dx@sendgrid.com +.. _The MIT License (MIT): https://github.com/sendgrid/sendgrid-python/blob/master/LICENSE.txt + +.. |Travis Badge| image:: https://travis-ci.org/sendgrid/sendgrid-python.svg?branch=master + :target: https://travis-ci.org/sendgrid/sendgrid-python +.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/sendgrid.svg + :target: https://pypi.org/project/sendgrid/ +.. |PyPI Version| image:: https://img.shields.io/pypi/v/sendgrid.svg + :target: https://pypi.org/project/sendgrid/ +.. |codecov| image:: https://img.shields.io/codecov/c/github/sendgrid/sendgrid-python/master.svg?style=flat-square&label=Codecov+Coverage + :target: https://codecov.io/gh/sendgrid/sendgrid-python +.. |Docker Badge| image:: https://img.shields.io/docker/automated/sendgrid/sendgrid-python.svg + :target: https://hub.docker.com/r/sendgrid/sendgrid-python/ +.. |Email Notifications Badge| image:: https://dx.sendgrid.com/badge/python + :target: https://dx.sendgrid.com/newsletter/python +.. |MIT licensed| image:: https://img.shields.io/badge/license-MIT-blue.svg + :target: ./LICENSE.txt +.. |Twitter Follow| image:: https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow + :target: https://twitter.com/sendgrid +.. |GitHub contributors| image:: https://img.shields.io/github/contributors/sendgrid/sendgrid-python.svg + :target: https://github.com/sendgrid/sendgrid-python/graphs/contributors +.. |Open Source Helpers| image:: https://www.codetriage.com/sendgrid/sendgrid-python/badges/users.svg + :target: https://www.codetriage.com/sendgrid/sendgrid-python diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 000000000..1bc788d3b --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +5.6.0 diff --git a/register.py b/register.py deleted file mode 100644 index 0a7ffe8d8..000000000 --- a/register.py +++ /dev/null @@ -1,20 +0,0 @@ -import pypandoc -from io import open - -output = pypandoc.convert('README.md', 'rst') -with open('README.txt', 'w+') as f: - f.write(output) - -readme_rst = open('./README.txt', 'r', encoding='utf-8').read() -replace = ''' - .. figure:: https://uiux.s3.amazonaws.com/2016-logos/email-logo - %402x.png\n :alt: SendGrid Logo\n\n SendGrid Logo\n - ''' -replacement = ''' - |SendGrid Logo|\n\n.. |SendGrid Logo| image:: - https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png - \n :target: https://www.sendgrid.com - ''' -final_text = readme_rst.replace(replace, replacement) -with open('./README.txt', 'w', encoding='utf-8') as f: - f.write(final_text) diff --git a/sendgrid/__init__.py b/sendgrid/__init__.py index 1b5100c01..84dc0670e 100644 --- a/sendgrid/__init__.py +++ b/sendgrid/__init__.py @@ -15,7 +15,13 @@ Modules to help with common tasks. """ -from .version import __version__ # noqa +import os + # v3 API from .sendgrid import SendGridAPIClient # noqa from .helpers.mail import Email # noqa + + +dir_path = os.path.dirname(os.path.realpath(__file__)) +if os.path.isfile(os.path.join(dir_path, 'VERSION.txt')): + __version__ = open(os.path.join(dir_path, 'VERSION.txt')).read().strip() diff --git a/sendgrid/sendgrid.py b/sendgrid/sendgrid.py index cc3450091..c2e3197ce 100644 --- a/sendgrid/sendgrid.py +++ b/sendgrid/sendgrid.py @@ -18,8 +18,6 @@ import python_http_client -from .version import __version__ - class SendGridAPIClient(object): """The SendGrid API Client. @@ -69,8 +67,8 @@ def __init__( self.apikey = apikey or api_key or os.environ.get('SENDGRID_API_KEY') self.impersonate_subuser = impersonate_subuser self.host = host - self.useragent = 'sendgrid/{0};python'.format(__version__) - self.version = __version__ + self.useragent = 'sendgrid/{0};python'.format(sendgrid.__version__) + self.version = sendgrid.__version__ self.client = python_http_client.Client(host=self.host, request_headers=self._default_headers, diff --git a/sendgrid/version.py b/sendgrid/version.py deleted file mode 100644 index fffe2c469..000000000 --- a/sendgrid/version.py +++ /dev/null @@ -1,2 +0,0 @@ -version_info = (5, 6, 0) -__version__ = '.'.join(str(v) for v in version_info) diff --git a/setup.py b/setup.py index 014691b61..3ef141aa8 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,9 @@ -import sys +import io import os -from io import open +import sys +from distutils.file_util import copy_file from setuptools import setup, find_packages -__version__ = None -with open('sendgrid/version.py') as f: - exec(f.read()) - -long_description = 'Please see our GitHub README' -if os.path.exists('README.txt'): - long_description = open('README.txt', 'r', encoding='utf-8').read() - def getRequires(): deps = ['python_http_client>=3.0'] @@ -20,17 +13,25 @@ def getRequires(): deps.append('unittest2py3k') 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() +version = io.open(os.path.join(dir_path, 'VERSION.txt'), encoding='utf-8').read().strip() +copy_file(os.path.join(dir_path, 'VERSION.txt'), + os.path.join(dir_path, 'sendgrid', 'VERSION.txt'), + verbose=0) + setup( name='sendgrid', - version=str(__version__), + version=version, author='Elmer Thomas, Yamil Asusta', author_email='dx@sendgrid.com', url='https://github.com/sendgrid/sendgrid-python/', - packages=find_packages(exclude=["temp*.py", "register.py", "test"]), + packages=find_packages(exclude=["temp*.py", "test"]), include_package_data=True, license='MIT', description='SendGrid library for Python', - long_description=long_description, + long_description=readme, install_requires=getRequires(), classifiers=[ 'Programming Language :: Python :: 2.6', diff --git a/test/test_project.py b/test/test_project.py index 4fbc8147c..b29da573c 100644 --- a/test/test_project.py +++ b/test/test_project.py @@ -55,9 +55,9 @@ def test_license(self): def test_pr_template(self): self.assertTrue(os.path.isfile('./.github/PULL_REQUEST_TEMPLATE')) - # ./README.md + # ./README.rst def test_readme(self): - self.assertTrue(os.path.isfile('./README.md')) + self.assertTrue(os.path.isfile('./README.rst')) # ./TROUBLESHOOTING.md def test_troubleshooting(self): @@ -67,6 +67,10 @@ def test_troubleshooting(self): def test_usage(self): self.assertTrue(os.path.isfile('./USAGE.md')) + # ./VERSION.txt + def test_usage(self): + self.assertTrue(os.path.isfile('./VERSION.txt')) + # ./use-cases/README.md def test_use_cases(self): self.assertTrue(os.path.isfile('./use_cases/README.md')) diff --git a/test/test_sendgrid.py b/test/test_sendgrid.py index c545cbb2d..6e4e5892d 100644 --- a/test/test_sendgrid.py +++ b/test/test_sendgrid.py @@ -1,6 +1,5 @@ import sendgrid from sendgrid.helpers.mail import * -from sendgrid.version import __version__ try: import unittest2 as unittest except ImportError: @@ -101,7 +100,7 @@ def test_impersonate_subuser_init(self): self.assertEqual(sg_impersonate.impersonate_subuser, temp_subuser) def test_useragent(self): - useragent = '{0}{1}{2}'.format('sendgrid/', __version__, ';python') + useragent = '{0}{1}{2}'.format('sendgrid/', sendgrid.__version__, ';python') self.assertEqual(self.sg.useragent, useragent) def test_host(self): From 94cb3037e76028101e2639ce893726a1683a68df Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Fri, 5 Oct 2018 01:28:14 +0300 Subject: [PATCH 2/2] hotfix --- MANIFEST.in | 2 +- sendgrid/__init__.py | 1 - sendgrid/sendgrid.py | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 3833b2419..21d9e9a11 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,4 +5,4 @@ include app.json include Procfile include requirements.txt recursive-include sendgrid *.py *.txt -prune test +recursive-exclude test * diff --git a/sendgrid/__init__.py b/sendgrid/__init__.py index 84dc0670e..621b3b0d7 100644 --- a/sendgrid/__init__.py +++ b/sendgrid/__init__.py @@ -16,7 +16,6 @@ """ import os - # v3 API from .sendgrid import SendGridAPIClient # noqa from .helpers.mail import Email # noqa diff --git a/sendgrid/sendgrid.py b/sendgrid/sendgrid.py index c2e3197ce..309cbb0de 100644 --- a/sendgrid/sendgrid.py +++ b/sendgrid/sendgrid.py @@ -60,6 +60,7 @@ def __init__( :param opts: dispatcher for deprecated arguments. Added for backward-compatibility with `path` parameter. Should be removed during 6.x release """ + from . import __version__ if opts: warnings.warn( 'Unsupported argument(s) provided: {}'.format(list(opts.keys())), @@ -67,8 +68,8 @@ def __init__( self.apikey = apikey or api_key or os.environ.get('SENDGRID_API_KEY') self.impersonate_subuser = impersonate_subuser self.host = host - self.useragent = 'sendgrid/{0};python'.format(sendgrid.__version__) - self.version = sendgrid.__version__ + self.useragent = 'sendgrid/{0};python'.format(__version__) + self.version = __version__ self.client = python_http_client.Client(host=self.host, request_headers=self._default_headers,