From 7b6fcfd143a47a2981245e3afebcbebd1bc62cbc Mon Sep 17 00:00:00 2001 From: StrikerRUS Date: Tue, 9 Oct 2018 15:08:07 +0300 Subject: [PATCH] fixed Travis, converted README and version as file --- .gitignore | 1 + .travis.yml | 8 +-- MANIFEST.in | 4 +- README.md | 111 -------------------------------- README.rst | 149 +++++++++++++++++++++++++++++++++++++++++++ VERSION.txt | 1 + setup.py | 24 ++++++- smtpapi/__init__.py | 9 ++- test/__init__.py | 4 +- test/test_project.py | 10 +-- 10 files changed, 194 insertions(+), 127 deletions(-) delete mode 100644 README.md create mode 100644 README.rst create mode 100644 VERSION.txt diff --git a/.gitignore b/.gitignore index e1b4fb6..40d319c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ bin/ include/ lib/ .env +smtpapi/VERSION.txt diff --git a/.travis.yml b/.travis.yml index ad8f1b6..2d337f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ language: python python: -- '2.6' -- '2.7' -- '3.4' -- '3.5' + - '2.6' + - '2.7' + - '3.4' + - '3.5' install: - python setup.py install - pip install codecov diff --git a/MANIFEST.in b/MANIFEST.in index bb3ec5f..8d138aa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,3 @@ -include README.md +include README.rst LICENSE.txt VERSION.txt +recursive-include smtpapi *.py *.txt +prune test diff --git a/README.md b/README.md deleted file mode 100644 index 7dfe5ab..0000000 --- a/README.md +++ /dev/null @@ -1,111 +0,0 @@ -![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png) - -[![Travis Badge](https://travis-ci.org/sendgrid/smtpapi-python.svg?branch=master)](https://travis-ci.org/sendgrid/smtpapi-python) -[![Email Notifications Badge](https://dx.sendgrid.com/badge/python)](https://dx.sendgrid.com/newsletter/python) -[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid) -[![Codecov branch](https://img.shields.io/codecov/c/github/sendgrid/smtpapi-python/master.svg?style=flat-square&label=Codecov+Coverage)](https://codecov.io/gh/sendgrid/smtpapi-python) -[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/smtpapi-python.svg)](https://github.com/sendgrid/smtpapi-python/graphs/contributors) -[![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE.txt) - -**This module helps build SendGrid's SMTP API headers.** - -Learn more about the SMTP API at [SendGrid's documentation](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html). - -# Announcements - -All updates to this module is documented in our [CHANGELOG](https://github.com/sendgrid/smtpapi-python/blob/master/CHANGELOG.md). - -# Table of Contents -- [Installation](#installation) -- [Quick Start](#quick-start) -- [Usage](#usage) -- [Roadmap](#roadmap) -- [How to Contribute](#contribute) -- [Local set up](#local_setup) -- [About](#about) -- [License](#license) - - -# Installation - -## Prerequisites - -- Python version 2.6, 2.7, 3.4 or 3.5 -- The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-python) - -## Install Package - -```bash -pip install smtpapi -``` - -## Setup Environment Variables - -Update the development environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys), for example: - - -```bash -cp .env_sample .env -``` -In `.env` set `SENDGRID_API_KEY` to your own API key. - -You can add your environment variables to your environment by sourcing the file: - -```source .env``` - - - -# Quick Start - -```python -from smtpapi import SMTPAPIHeader -header = SMTPAPIHeader() -header.add_to('email@email.com') -print(header.json_string()) -``` - - -# Usage - -- [SendGrid Docs](https://sendgrid.com/docs/API_Reference/SMTP_API/index.html) -- [Example Code](https://github.com/sendgrid/smtpapi-python/tree/master/examples) - - -# Roadmap - -If you are interested in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/smtpapi-python/milestones). We would love to hear your feedback. - - -# How to Contribute - -We encourage contribution to our projects, please see our [CONTRIBUTING](https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md) guide for details. - -Quick links: - -- [Feature Request](https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#feature-request) -- [Bug Reports](https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#submit-a-bug-report) -- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#cla) -- [Improvements to the Codebase](https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#improvements-to-the-codebase) - - - -# Local Setup of the project - -The simplest local development workflow is by using docker. - -> Steps - -1. Install Docker -2. Run `docker-compose build` (This builds the container) -3. Run `docker-compose up` (This runs tests by default) - - -# About - -smtpapi-python is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com). - -smtpapi-python is maintained and funded by SendGrid, Inc. The names and logos for smtpapi-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 0000000..4d5df8d --- /dev/null +++ b/README.rst @@ -0,0 +1,149 @@ +.. image:: https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png + :target: https://www.sendgrid.com + :alt: SendGrid Logo + +|Travis Badge| |Email Notifications Badge| |Twitter Follow| |Codecov branch| |Python Versions| |PyPI Version| |GitHub contributors| |MIT Licensed| + +**This module helps build SendGrid's SMTP API headers.** + +Learn more about the SMTP API at `SendGrid documentation`_. + +Announcements +============= + +All updates to this module is documented in our `CHANGELOG`_. + +Table of Contents +================= + +- `Installation <#installation>`__ +- `Quick Start <#quick-start>`__ +- `Usage <#usage>`__ +- `Roadmap <#roadmap>`__ +- `How to Contribute <#how-to-contribute>`__ +- `Local Setup of the Project <#local-setup-of-the-project>`__ +- `About <#about>`__ +- `License <#license>`__ + +Installation +============ + +Prerequisites +------------- + +- Python version 2.6, 2.7, 3.4 or 3.5 +- The SendGrid service, starting at the `free level`_ + +Install Package +--------------- + +.. code:: bash + + pip install smtpapi + +Setup Environment Variables +--------------------------- + +Update the development environment with your `SENDGRID_API_KEY`_, for example: + +.. code:: bash + + cp .env_sample .env + +In ``.env`` set ``SENDGRID_API_KEY`` to your own API key. + +You can add your environment variables to your environment by sourcing the file: + +.. code:: bash + + source .env + +Quick Start +=========== + +.. code:: python + + from smtpapi import SMTPAPIHeader + + header = SMTPAPIHeader() + header.add_to('email@email.com') + print(header.json_string()) + +Usage +===== + +- `SendGrid documentation`_ +- `Example Code`_ + +Roadmap +======= + +If you are interested in the future direction of this project, please take a look at our `milestones`_. +We would love to hear your feedback. + +How to Contribute +================= + +We encourage contribution to our projects, please see our `CONTRIBUTING`_ guide for details. + +Quick links: + +- `Feature Request`_ +- `Bug Reports`_ +- `Sign the CLA to Create a Pull Request`_ +- `Improvements to the Codebase`_ + +Local Setup of the Project +========================== + +The simplest local development workflow is by using docker. + +Steps: + +1. Install Docker +2. Run ``docker-compose build`` (this builds the container) +3. Run ``docker-compose up`` (this runs tests by default) + +About +===== + +**smtpapi-python** is guided and supported by the SendGrid `Developer Experience Team`_. + +**smtpapi-python** is maintained and funded by SendGrid, Inc. +The names and logos for **smtpapi-python** are trademarks of SendGrid, Inc. + +License +======= + +`The MIT License (MIT)`_ + +.. _SendGrid documentation: https://sendgrid.com/docs/API_Reference/SMTP_API/index.html +.. _CHANGELOG: https://github.com/sendgrid/smtpapi-python/blob/master/CHANGELOG.md +.. _free level: https://sendgrid.com/free?source=sendgrid-python +.. _SENDGRID_API_KEY: https://app.sendgrid.com/settings/api_keys +.. _Example Code: https://github.com/sendgrid/smtpapi-python/tree/master/examples +.. _milestones: https://github.com/sendgrid/smtpapi-python/milestones +.. _CONTRIBUTING: https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md +.. _Feature Request: https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#feature-request +.. _Bug Reports: https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#submit-a-bug-report +.. _Sign the CLA to Create a Pull Request: https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#cla +.. _Improvements to the Codebase: https://github.com/sendgrid/smtpapi-python/blob/master/CONTRIBUTING.md#improvements-to-the-codebase +.. _Developer Experience Team: mailto:dx@sendgrid.com +.. _The MIT License (MIT): https://github.com/sendgrid/smtpapi-python/blob/master/LICENSE.txt + +.. |Travis Badge| image:: https://travis-ci.org/sendgrid/smtpapi-python.svg?branch=master + :target: https://travis-ci.org/sendgrid/smtpapi-python +.. |Email Notifications Badge| image:: https://dx.sendgrid.com/badge/python + :target: https://dx.sendgrid.com/newsletter/python +.. |Twitter Follow| image:: https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow + :target: https://twitter.com/sendgrid +.. |Codecov branch| image:: https://img.shields.io/codecov/c/github/sendgrid/smtpapi-python/master.svg?style=flat-square&label=Codecov+Coverage + :target: https://codecov.io/gh/sendgrid/smtpapi-python +.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/smtpapi.svg + :target: https://pypi.org/project/smtpapi/ +.. |PyPI Version| image:: https://img.shields.io/pypi/v/smtpapi.svg + :target: https://pypi.org/project/smtpapi/ +.. |GitHub contributors| image:: https://img.shields.io/github/contributors/sendgrid/smtpapi-python.svg + :target: https://github.com/sendgrid/smtpapi-python/graphs/contributors +.. |MIT Licensed| image:: https://img.shields.io/badge/license-MIT-blue.svg + :target: https://github.com/sendgrid/smtpapi-python/blob/master/LICENSE.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..9e11b32 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +0.3.1 diff --git a/setup.py b/setup.py index 81f015d..a6e11d0 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,30 @@ +import io +import os +from distutils.file_util import copy_file from setuptools import setup, find_packages + +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, 'smtpapi', 'VERSION.txt'), + verbose=0) setup( name='smtpapi', - version='0.3.1', + version=version, author='Yamil Asusta, Kane Kim', author_email='yamil@sendgrid.com, kane.isturm@sendgrid.com', - packages=find_packages(), + url='https://github.com/sendgrid/smtpapi-python/', + packages=find_packages(exclude=["test"]), + include_package_data=True, license='MIT License', description='Simple wrapper to use SendGrid SMTP API', - long_description='Simple wrapper to use SendGrid SMTP API', + long_description=readme, + classifiers=[ + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], ) diff --git a/smtpapi/__init__.py b/smtpapi/__init__.py index 43cbb59..5781d87 100644 --- a/smtpapi/__init__.py +++ b/smtpapi/__init__.py @@ -1,4 +1,11 @@ -import json, decimal +import decimal +import json +import os + + +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() class _CustomJSONEncoder(json.JSONEncoder): diff --git a/test/__init__.py b/test/__init__.py index 69abcfd..83b29d8 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -104,10 +104,10 @@ def setUp(self): './CODE_OF_CONDUCT.md', './CONTRIBUTING.md', ['./LICENSE.md', './LICENSE.txt'], - './README.md', + './README.rst', './TROUBLESHOOTING.md', './USAGE.md', - './USE_CASES.md', + './VERSION.txt', ] self.file_not_found_message = 'File "{0}" does not exist in repo!' diff --git a/test/test_project.py b/test/test_project.py index 88da5a4..daf7d85 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.assertEqual(True, os.path.isfile('./.github/PULL_REQUEST_TEMPLATE')) - # ./README.md + # ./README.rst def test_readme(self): - self.assertEqual(True, os.path.isfile('./README.md')) + self.assertEqual(True, os.path.isfile('./README.rst')) # ./TROUBLESHOOTING.md def test_troubleshooting(self): @@ -67,9 +67,9 @@ def test_troubleshooting(self): def test_usage(self): self.assertEqual(True, os.path.isfile('./USAGE.md')) - # ./USE_CASES.md + # ./VERSION.txt def test_use_cases(self): - self.assertEqual(True, os.path.isfile('./USE_CASES.md')) + self.assertEqual(True, os.path.isfile('./VERSION.txt')) if __name__ == '__main__': -unittest.main() + unittest.main()