From 1110509ed933795f1d88e8634a3c13ebd3cbb914 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 9 Aug 2018 11:16:04 -0400 Subject: [PATCH 1/3] PyPi setup. --- .gitignore | 9 ++++--- .pylintrc | 2 +- .travis.yml | 38 +++++++++++++++--------------- docs/conf.py | 2 +- requirements.txt | 2 +- setup.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 25 deletions(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index b1dfd54..55f127b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ +*.mpy +.idea __pycache__ _build *.pyc -*.mpy -.vscode -*~ .env build* bundles +*.DS_Store +.eggs +dist +**/*.egg-info \ No newline at end of file diff --git a/.pylintrc b/.pylintrc index 946d694..cb8d23d 100644 --- a/.pylintrc +++ b/.pylintrc @@ -155,7 +155,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules= +ignored-modules=board # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. diff --git a/.travis.yml b/.travis.yml index 664fb3d..1f3b0f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,32 @@ -# This is a common .travis.yml for generating library release zip files for -# CircuitPython library releases using circuitpython-build-tools. -# See https://github.com/adafruit/circuitpython-build-tools for detailed setup -# instructions. - dist: trusty sudo: false language: python python: - - "3.6" - +- '3.6' cache: - pip: true - + pip: true deploy: - provider: releases - api_key: $GITHUB_TOKEN +- provider: releases + api_key: "$GITHUB_TOKEN" file_glob: true - file: $TRAVIS_BUILD_DIR/bundles/* + file: "$TRAVIS_BUILD_DIR/bundles/*" skip_cleanup: true overwrite: true on: tags: true - +- provider: pypi + user: adafruit-travis + on: + tags: true + password: + secure: vbm1F3ytAJ5KowFopPDIAaOyUe1bxvBG6+9iq5M1eLcz7cGzO+bFYDYAc6mSvNzWTxfJj0OhAacLYdvvl+LuEbBpFAABRmC0klbWAHwPDHO49eMcT4F2Optrc4HmEwyA+7vwlYoWJIyANz9gbAmVhiBoXw0bMTb+kn9465v3NR86XVTnKnPeAMtsXWgEw3YHdaLa93tFEiMN73bntlQXMSbxCqAqTJUqe8ekGuaezLmR7VtfTeYN6jvGNMZuPYGA/F8Gi91qXuqmQmZLhQ9hc4KVuq1hMudDHlqNeVzw9/rRPKnoO93UuGVXuJVosCdgU/STVCpd13Lqa97XnozeKxWo10PFdwlrc7vlebqlZAw9If2tR3KhKDhDxakZHlXdxnPyFGK43csIOjO/ctjv+/A2pga6ys+VcdM9uDONkGdCh2AvYlN+yezR11GR01LRMOyeF0g5bB+FzNh6V69F3UuD4ydtPpLuHVuwWvGkDTiwfIhkNF3BVTohqpDJadCj+jJgw6271PjET1PXo+VlT3S+gCqD527lAXaxyNrIvTr9iupJGnhOBdU5EBepbAxHgAyNrqiL/vS0kH4LuxSFGYPCnxHx4Ep8LAB0zcDneJFHrbhIeqJipR+MY8PnDNGXX+5pmrb1++OS8oQZPFesn0Ap8M1jfAw9UDe+H8WpnIM= install: - - pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme - +- pip install -r requirements.txt +- pip install pylint circuitpython-build-tools Sphinx sphinx-rtd-theme +- pip install --force-reinstall pylint==1.9.2 script: - - pylint adafruit_hid/*.py - - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-hid --library_location . - - cd docs && sphinx-build -E -W -b html . _build/html +- pylint adafruit_hid/*.py +- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name examples/*.py) +- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-hid --library_location + . +- cd docs && sphinx-build -E -W -b html . _build/html && cd .. diff --git a/docs/conf.py b/docs/conf.py index 1348cb3..e2e2424 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -31,7 +31,7 @@ author = u'Scott Shawcroft' # Ignore imports of these modules, which sphinx will not know about. -autodoc_mock_imports = ["micropython", "usb_hid"] +autodoc_mock_imports = ["usb_hid"] # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/requirements.txt b/requirements.txt index 8b13789..edf9394 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ - +Adafruit-Blinka diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..933d039 --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" + +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +# To use a consistent encoding +from codecs import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the README file +with open(path.join(here, 'README.rst'), encoding='utf-8') as f: + long_description = f.read() + +setup( + name='adafruit-circuitpython-hid', + + use_scm_version=True, + setup_requires=['setuptools_scm'], + + description='CircuitPython helper library for simulating HID devices.', + long_description=long_description, + long_description_content_type='text/x-rst', + + # The project's main homepage. + url='https://github.com/adafruit/Adafruit_CircuitPython_HID', + + # Author details + author='Adafruit Industries', + author_email='circuitpython@adafruit.com', + + install_requires=['Adafruit-Blinka'], + + # Choose your license + license='MIT', + + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Libraries', + 'Topic :: System :: Hardware', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + ], + + # What does your project relate to? + keywords='adafruit hid human interface device keyboard mouse keycode keypad' + 'hardware micropython circuitpython', + + # You can just specify the packages manually here if your project is + # simple. Or you can use find_packages(). + py_modules=['adafruit_hid'], +) From b2cdaee1f398ad478170d517dd3803e5bd5b6178 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 9 Aug 2018 11:20:11 -0400 Subject: [PATCH 2/3] Linting. --- adafruit_hid/keyboard.py | 4 ++-- examples/joywing_gamepad.py | 2 +- examples/keyboard_shortcuts.py | 4 ++-- examples/scroll.py | 2 +- examples/simple_gamepad.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_hid/keyboard.py b/adafruit_hid/keyboard.py index 4b68b79..e3858db 100644 --- a/adafruit_hid/keyboard.py +++ b/adafruit_hid/keyboard.py @@ -29,12 +29,12 @@ """ import time -import usb_hid - from micropython import const +import usb_hid from .keycode import Keycode + class Keyboard: """Send HID keyboard reports.""" diff --git a/examples/joywing_gamepad.py b/examples/joywing_gamepad.py index ea22050..92cee5c 100644 --- a/examples/joywing_gamepad.py +++ b/examples/joywing_gamepad.py @@ -4,9 +4,9 @@ import board import busio +from micropython import const import adafruit_seesaw from adafruit_hid.gamepad import Gamepad -from micropython import const def range_map(value, in_min, in_max, out_min, out_max): return (value - in_min) * (out_max - out_min) // (in_max - in_min) + out_min diff --git a/examples/keyboard_shortcuts.py b/examples/keyboard_shortcuts.py index 7196ff0..f922bed 100644 --- a/examples/keyboard_shortcuts.py +++ b/examples/keyboard_shortcuts.py @@ -1,8 +1,8 @@ import time -from adafruit_hid.keyboard import Keyboard -from adafruit_hid.keycode import Keycode import board import digitalio +from adafruit_hid.keyboard import Keyboard +from adafruit_hid.keycode import Keycode kbd = Keyboard() diff --git a/examples/scroll.py b/examples/scroll.py index 62e7915..fc7817a 100644 --- a/examples/scroll.py +++ b/examples/scroll.py @@ -1,7 +1,7 @@ import time -from adafruit_hid.mouse import Mouse import board import digitalio +from adafruit_hid.mouse import Mouse mouse = Mouse() diff --git a/examples/simple_gamepad.py b/examples/simple_gamepad.py index 347ce5c..881ad4b 100644 --- a/examples/simple_gamepad.py +++ b/examples/simple_gamepad.py @@ -1,6 +1,6 @@ -import analogio import board import digitalio +import analogio from adafruit_hid.gamepad import Gamepad From 1d6eb7a00f0ad7c399fe049ab4f699f71165e6ae Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 9 Aug 2018 11:30:56 -0400 Subject: [PATCH 3/3] Updated py_modules to packages --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 933d039..5927d0d 100644 --- a/setup.py +++ b/setup.py @@ -57,5 +57,5 @@ # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=['adafruit_hid'], + packages=['adafruit_hid'], )