diff --git a/.gitignore b/.gitignore index fa633ebb..7c5b47d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,37 +1,2 @@ -*.py[cod] - -test.py - -# C extensions -*.so - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox -nosetests.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject +.mypy_cache +Pipfile.lock diff --git a/LICENSE b/LICENSE index 9ae45db6..6ee700f9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 William Scanlon +Copyright (c) 2016 William Scanlon, 2018 Aaron Bach Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..eb74559c --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +init: + pip install --upgrade pip pipenv + pipenv lock + pipenv install --dev +lint: + pipenv run flake8 simplisafe-python + pipenv run pydocstyle simplisafe-python +publish: + python setup.py sdist bdist_wheel + pipenv run twine upload dist/* + rm -rf dist/ build/ .egg simplisafe-python.egg-info/ diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000..94c13e1a --- /dev/null +++ b/Pipfile @@ -0,0 +1,16 @@ +[[source]] + +url = "https://pypi.python.org/simple" +verify_ssl = true + + +[dev-packages] + +"flake8" = "*" +pydocstyle = "*" +tox = "*" +twine = "*" + +[packages] + +requests = "*" diff --git a/pylintrc b/pylintrc deleted file mode 100644 index a8cf4856..00000000 --- a/pylintrc +++ /dev/null @@ -1,13 +0,0 @@ -[MASTER] -max-line-length=120 -max-args=10 -ignore=test - -# Reasons disabled: -# locally-disabled - Because that's the whole point! -disable= - missing-docstring - , global-statement - , invalid-name - , fixme - , locally-disabled diff --git a/script/lint b/script/lint deleted file mode 100755 index ff4e9317..00000000 --- a/script/lint +++ /dev/null @@ -1,19 +0,0 @@ -# Run style checks - -cd "$(dirname "$0")/.." - -echo "Checking style with flake8..." -flake8 src/simplipy - -FLAKE8_STATUS=$? - -echo "Checking style with pylint..." -pylint src/simplipy -PYLINT_STATUS=$? - -if [ $FLAKE8_STATUS -eq 0 ] -then - exit $PYLINT_STATUS -else - exit $FLAKE8_STATUS -fi diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b88034e4..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..b297bbf8 --- /dev/null +++ b/setup.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +"""Define publication options.""" + +# Note: To use the 'upload' functionality of this file, you must: +# $ pip install twine + +import io +import os +import sys +from shutil import rmtree + +from setuptools import find_packages, setup, Command # type: ignore + +# Package meta-data. +NAME = 'simplisafe-python' +DESCRIPTION = 'A unofficial Python 3 library for SimpliSafe alarm systems' +URL = 'https://github.com/w1ll1am23/simplisafe-python' +EMAIL = '' +AUTHOR = 'William Scanlon' +REQUIRES_PYTHON = '>=3.5.0' +VERSION = None + +# What packages are required for this module to be executed? +REQUIRED = [ # type: ignore + 'requests>=2.0' +] + +# The rest you shouldn't have to touch too much :) +# ------------------------------------------------ +# Except, perhaps the License and Trove Classifiers! +# If you do change the License, remember to change the Trove Classifier for +# that! + +HERE = os.path.abspath(os.path.dirname(__file__)) + +# Import the README and use it as the long-description. +# Note: this will only work if 'README.md' is present in your MANIFEST.in file! +with io.open(os.path.join(HERE, 'README.rst'), encoding='utf-8') as f: + LONG_DESC = '\n' + f.read() + +# Load the package's __version__.py module as a dictionary. +ABOUT = {} # type: ignore +if not VERSION: + with open(os.path.join(HERE, NAME, '__version__.py')) as f: + exec(f.read(), ABOUT) # pylint: disable=exec-used +else: + ABOUT['__version__'] = VERSION + + +class UploadCommand(Command): + """Support setup.py upload.""" + + description = 'Build and publish the package.' + user_options = [] # type: ignore + + @staticmethod + def status(string): + """Prints things in bold.""" + print('\033[1m{0}\033[0m'.format(string)) + + def initialize_options(self): + """Add options for initialization.""" + pass + + def finalize_options(self): + """Add options for finalization.""" + pass + + def run(self): + """Run.""" + try: + self.status('Removing previous builds…') + rmtree(os.path.join(HERE, 'dist')) + except OSError: + pass + + self.status('Building Source and Wheel (universal) distribution…') + os.system('{0} setup.py sdist bdist_wheel --universal'.format( + sys.executable)) + + self.status('Uploading the package to PyPi via Twine…') + os.system('twine upload dist/*') + + self.status('Pushing git tags…') + os.system('git tag v{0}'.format(ABOUT['__version__'])) + os.system('git push --tags') + + sys.exit() + + +# Where the magic happens: +setup( + name=NAME, + version=ABOUT['__version__'], + description=DESCRIPTION, + long_description=LONG_DESC, + long_description_content_type='text/markdown', + author=AUTHOR, + # author_email=EMAIL, + python_requires=REQUIRES_PYTHON, + url=URL, + packages=find_packages(exclude=('tests',)), + # If your package is a single module, use this instead of 'packages': + # py_modules=['mypackage'], + + # entry_points={ + # 'console_scripts': ['mycli=mymodule:cli'], + # }, + install_requires=REQUIRED, + include_package_data=True, + license='MIT', + classifiers=[ + # Trove classifiers + # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: Implementation :: CPython', + 'Programming Language :: Python :: Implementation :: PyPy' + ], + # $ setup.py publish support. + cmdclass={ + 'upload': UploadCommand, + }, +) diff --git a/src/simplipy/__init__.py b/simplipy/__init__.py similarity index 100% rename from src/simplipy/__init__.py rename to simplipy/__init__.py diff --git a/simplipy/__version__.py b/simplipy/__version__.py new file mode 100644 index 00000000..941cc39b --- /dev/null +++ b/simplipy/__version__.py @@ -0,0 +1,2 @@ +"""Define a version constant.""" +__version__ = '2.0.2' diff --git a/src/simplipy/api.py b/simplipy/api.py similarity index 100% rename from src/simplipy/api.py rename to simplipy/api.py diff --git a/src/simplipy/sensor.py b/simplipy/sensor.py similarity index 100% rename from src/simplipy/sensor.py rename to simplipy/sensor.py diff --git a/src/simplipy/system.py b/simplipy/system.py similarity index 100% rename from src/simplipy/system.py rename to simplipy/system.py diff --git a/src/setup.py b/src/setup.py deleted file mode 100644 index dbd8642d..00000000 --- a/src/setup.py +++ /dev/null @@ -1,13 +0,0 @@ -from setuptools import setup, find_packages - -setup(name='simplisafe-python', - version='2.0.2', - description='Python 3 support for SimpliSafe alarm', - url='https://github.com/w1ll1am23/simplisafe-python', - author='William Scanlon', - license='MIT', - install_requires=['requests>=2.0'], - tests_require=['mock'], - test_suite='tests', - packages=find_packages(exclude=["dist", "*.test", "*.test.*", "test.*", "test"]), - zip_safe=True) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 6deafc26..00000000 --- a/tox.ini +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -max-line-length = 120