Skip to content

Commit

Permalink
Updated Readme
Browse files Browse the repository at this point in the history
Updated setup.py
Updated requirements.txt
Added requirements-dev.txy
Added release.py
  • Loading branch information
Jandro committed Oct 19, 2018
1 parent d59e369 commit 74e4639
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 52 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ m.body = "George Best quote: I've stopped drinking, but only while I'm asleep."
m.send()
```

>To use it: **pip install pyo365**

**Python 3.4 is the minimum required**... I was very tempted to just go for 3.6 and use f-strings. Those are fantastic!

Expand All @@ -44,6 +43,7 @@ What follows is kind of a wiki... but you will get more insights by looking at t

## Table of contents

- [Install](#install)
- [Protocols](#protocols)
- [Authentication](#authentication)
- [Account Class and Modularity](#account)
Expand All @@ -55,6 +55,18 @@ What follows is kind of a wiki... but you will get more insights by looking at t
- [Utils](#utils)


## Install
pyo365 is available on pypi.org. Simply run `pip install pyo365` to install it.

Project dependencies installed by pip:
- requests
- requests-oauthlib
- beatifulsoup4
- stringcase
- python-dateutil
- tzlocal
- pytz

## Protocols
Protocols handles the aspects of comunications between different APIs.
This project uses by default either the Office 365 APIs or Microsoft Graph APIs.
Expand Down
61 changes: 61 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
"""
Release script
"""

import os
import shutil
import subprocess
import sys
from pathlib import Path

import click


DIST_PATH = 'dist'


@click.group()
def cli():
pass


@cli.command()
def build():
dist_path = Path(DIST_PATH)
if dist_path.exists() and list(dist_path.glob('*')):
if click.confirm('{} is not empty - delete contents?'.format(dist_path)):
shutil.rmtree(dist_path)
dist_path.mkdir()
else:
click.echo('Aborting')
sys.exit(1)

subprocess.check_call(['python', 'setup.py', 'bdist_wheel'])
subprocess.check_call(['python', 'setup.py', 'sdist',
'--formats=gztar'])


@cli.command()
@click.option('--release/--no-release', default=False)
def upload(release):
if release:
repository = 'pypi'
else:
repository = 'pypitest'

env = os.environ.copy()

args = ['twine', 'upload', '-r', repository, 'dist/*']

p = subprocess.Popen(args, env=env)
p.wait()


@cli.command()
def check():
""" Checks the long description """
subprocess.check_call(['twine', 'check', 'dist/*'])


if __name__ == "__main__":
cli()
9 changes: 9 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
beautifulsoup4==4.6.3
python-dateutil==2.7.3
pytz==2018.5
requests==2.20.0
requests-oauthlib==1.0.0
stringcase==1.2.0
tzlocal==1.5.1
Click==7.0
pytest==3.9.1
16 changes: 5 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
beautifulsoup4==4.6.0
certifi==2018.1.18
chardet==3.0.4
idna==2.6
oauthlib==2.0.7
python-dateutil==2.7.2
pytz==2018.3
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
beautifulsoup4==4.6.3
python-dateutil==2.7.3
pytz==2018.5
requests==2.20.0
requests-oauthlib==1.0.0
stringcase==1.2.0
tzlocal==1.5.1
urllib3==1.22
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

103 changes: 65 additions & 38 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,52 +1,79 @@
#!/usr/bin/env python
import os
from setuptools import setup, find_packages

from setuptools import setup

CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Topic :: Office/Business :: Office Suites',
'Topic :: Software Development :: Libraries'
]
long_desc = """
When I started making this library I was looking for something that would provide a simple interface to an office365 mailbox. I was creating a system that would allow people send an email to our printer without having to require they install drivers or be inside the office firewall (important for students). As I found working with the office API to be fairly easy, I quickly built up solid general use library for working with office 365.
This project aims is to make it easy to interact with Microsoft Graph and Office 365 Email, Contacts, Calendar, OneDrive, etc.
The objective here is to make it easy to make utilities that are to be run against an office 365 account. for example, the code for sending an email is:
This project is inspired on the super work done by [Toben Archer](https://github.com/Narcolapser) [Python-O365](https://github.com/Narcolapser/python-o365).
The oauth part is based on the work done by [Royce Melborn](https://github.com/roycem90) which is now integrated with the original project.
I just want to make this project different in almost every sense, and make it also more pythonic.
So I ended up rewriting the hole project from scratch.
from pyo365 import Message
The result is a package that provides a lot of the Microsoft Graph and Office 365 API capabilities.
authenticiation = ('[email protected]','YourPassword')
This is for example how you send a message:
m = Message(auth=authenticiation)
from pyo365 import Account
m.setRecipients('[email protected]')
credentials = ('client_id', 'client_secret')
m.setSubject('I made an email script.')
account = Account(credentials, auth_method='oauth')
m = account.new_message()
m.to.add('[email protected]')
m.subject = 'Testing!'
m.body = "George Best quote: I've stopped drinking, but only while I'm asleep."
m.send()
"""

m.setBody('Talk to the computer, cause the human does not want to hear it any more.')
# Available classifiers: https://pypi.org/pypi?%3Aaction=list_classifiers
CLASSIFIERS = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Topic :: Office/Business :: Office Suites',
'Topic :: Software Development :: Libraries',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Operating System :: OS Independent',
]

m.sendMessage()

def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname), 'r') as file:
return file.read()

That's it. making and sending emails and events is now very simple and straight forward. I've used it for emailing the printer and creating a overview of our car booking system. simple, easy, but still in development. Any suggestions or advice are quite welcome at the projects github page:
https://github.com/janscas/py-o365
"""

setup(name='py-o365',
version='0.1.0',
description='Python library for working with Microsoft Office 365 REST API',
long_description=long_desc,
author='Toben Archer, Janscas',
author_email='[email protected], [email protected]',
maintainer='Janscas',
maintainer_email='[email protected]',
url='https://github.com/janscas/py-o365',
packages=['O365', 'O365.utils'],
install_requires=['requests', 'oauthlib', 'requests_oauthlib', 'beautifulsoup4', 'stringcase', 'python-dateutil', 'tzlocal'],
license='Apache 2.0',
classifiers=CLASSIFIERS
)

# so I don't have to keep looking it up: python setup.py sdist upload -r pypi
requires = [
'requests>=2.0.0',
'requests_oauthlib>=1.0.0',
'python-dateutil>=2.7',
'pytz>=2018.5',
'tzlocal>=1.5.0',
'beautifulsoup4>=4.0.0',
'stringcase>=1.2.0'
]

setup(
name='pyo365',
version='0.1.0',
# packages=['pyo365', 'pyo365.utils'],
packages=find_packages(),
url=' https://github.com/janscas/pyo365',
license='Apache License 2.0',
author='Janscas',
author_email='[email protected]',
maintainer='Janscas',
maintainer_email='[email protected]',
description='Microsoft Graph and Office 365 API made easy',
long_description=read('README.md'),
long_description_content_type="text/markdown",
classifiers=CLASSIFIERS,
python_requires=">=3.4",
install_requires=requires,
)

0 comments on commit 74e4639

Please sign in to comment.