From d1a4efe406e0bf43c009a2d26dbe070256afc58c Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Sun, 5 Aug 2018 14:51:05 -0400 Subject: [PATCH 1/3] PyPi setup --- .gitignore | 6 +++++ .travis.yml | 39 ++++++++++++++--------------- adafruit_l3gd20.py | 15 ++++++++---- docs/conf.py | 2 +- requirements.txt | 2 +- setup.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 26 deletions(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 0dd8629..55f127b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ +*.mpy +.idea __pycache__ _build *.pyc .env build* bundles +*.DS_Store +.eggs +dist +**/*.egg-info \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 0d9370d..8664be7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,33 @@ -# 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: lutIZNOClPpQck0PTD3xK33HnZlq+82BdT5SUYvY0rj5V+5C19G3gaDRMokHilKovAyaTMFscEVnUmjfLT8rHxyRImdPBp4W37fJ9nNswEe9ACL3ioWVfo9EZnzMSYL+9r3f096zMIu3ozBP9t+HWugKq0UdLU9YYy4P4eGRFrrbwsxJ5KEXL6I6WLe/5XjK96pJdkLjejN34eBGlPNGnLebgVP884oHlIjreQIImu4jWcOEF0WWcLaMeYLxomCGJTkKP3J/hIspRM8OkNWjAmotgMohnVx8Rdqsy7+9jWve3K/KBY1d0FEw4ra7zWZMXiHIqjfE2XAQ8XG3a38HVXxhp8UmhaxkTms7rOtfe1IpAhJgDg5Wcv68//neu73KoZ3IycxZkZN2ttDopUCW3Lf0sEyAvGRz24WCHLQcU2FI3yo8+rTMAOaECXbsnHv3yG1HbJhO2IMAijytKlvMdZzLB8HWdgpLLJqgmE8yXNGfQTHL+9kBmX1i6iThyfLeQipe6ZgqP0fVZ9Kqc34fYp/LzyAhd5PSMD5A5rmLvg94MunIrALh7CKPtzij+T1tge4Wb0HwlpRx6A1Lt+opQhG5Fuht68nxPtYmldlOh8bujnLOrA7xakCGvYderiNBZMj1BUp/YTewLhMoPGc5cdnwrUkRdXibLkvyHfT24kI= 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_l3gd20.py - - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace examples/*.py) - - circuitpython-build-bundles --filename_prefix adafruit-circuitpython-l3gd20 --library_location . - - cd docs && sphinx-build -E -W -b html . _build/html +- pylint adafruit_l3gd20.py +- ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace + examples/*.py) +- circuitpython-build-bundles --filename_prefix adafruit-circuitpython-l3gd20 --library_location + . +- cd docs && sphinx-build -E -W -b html . _build/html && cd .. diff --git a/adafruit_l3gd20.py b/adafruit_l3gd20.py index a1c5c50..eb12939 100644 --- a/adafruit_l3gd20.py +++ b/adafruit_l3gd20.py @@ -83,7 +83,8 @@ _L3GD20_SENSITIVITY_2000DPS = 0.070 ## Roughly 18/256 -class L3GD20: # pylint: disable=no-member +# pylint: disable=no-member +class L3GD20: """ Driver for the L3GD20 3-axis Gyroscope sensor. @@ -92,6 +93,10 @@ class L3GD20: # pylint: disable=no-member """ def __init__(self, rng=L3DS20_RANGE_250DPS): + # pylint: disable=consider-using-in + # This should be refactored to fix this pylint issue. + # Pylint error: Consider merging these comparisons with "in" to + # 'rng not in (L3DS20_RANGE_250DPS, L3DS20_RANGE_500DPS, L3DS20_RANGE_2000DPS)' chip_id = self.read_register(_ID_REGISTER) if chip_id != _L3GD20_CHIP_ID and chip_id != _L3GD20H_CHIP_ID: raise RuntimeError("bad chip id (%x != %x or %x)" % @@ -209,8 +214,8 @@ class L3GD20_I2C(L3GD20): """Gives the raw acceleration readings, in units of the scaled mdps.""" def __init__(self, i2c, rng=L3DS20_RANGE_250DPS, address=0x6B): - import adafruit_bus_device.i2c_device as i2c_device - self.i2c_device = i2c_device.I2CDevice(i2c, address) + import adafruit_bus_device.i2c_device as i2c_dev + self.i2c_device = i2c_dev.I2CDevice(i2c, address) self.buffer = bytearray(2) super().__init__(rng) @@ -249,8 +254,8 @@ class L3GD20_SPI(L3GD20): :param baudrate: spi baud rate default is 100000 """ def __init__(self, spi_busio, cs, rng=L3DS20_RANGE_250DPS, baudrate=100000): - import adafruit_bus_device.spi_device as spi_device - self._spi = spi_device.SPIDevice(spi_busio, cs, baudrate=baudrate) + import adafruit_bus_device.spi_device as spi_dev + self._spi = spi_dev.SPIDevice(spi_busio, cs, baudrate=baudrate) self._spi_bytearray1 = bytearray(1) self._spi_bytearray6 = bytearray(6) super().__init__(rng) diff --git a/docs/conf.py b/docs/conf.py index c7adc0f..3701413 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,7 @@ # Uncomment the below if you use native CircuitPython modules such as # digitalio, micropython and busio. List the modules you use. Without it, the # autodoc module docs will fail to generate with a warning. -autodoc_mock_imports = ["micropython", "adafruit_register"] +# autodoc_mock_imports = ["micropython", "adafruit_register"] intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} diff --git a/requirements.txt b/requirements.txt index 6cb8915..2a5d8fb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ - +Adafruit-Blinka adafruit-circuitpython-register diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8b72daf --- /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-l3gd20', + + use_scm_version=True, + setup_requires=['setuptools_scm'], + + description='CircuitPython library for L3GD20 9-DOF absolute orientation IMU fusion breakout.', + long_description=long_description, + long_description_content_type='text/x-rst', + + # The project's main homepage. + url='https://github.com/adafruit/Adafruit_CircuitPython_L3GD20', + + # Author details + author='Adafruit Industries', + author_email='circuitpython@adafruit.com', + + install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-register'], + + # 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 9dof 9-dof absolute orientation IMU fusion breakout hardware' + 'l3gd20 micropython circuitpython', + + # You can just specify the packages manually here if your project is + # simple. Or you can use find_packages(). + py_modules=['adafruit_l3gd20'], +) From e968762a1bffbaad09a9611e38017252b6b73f95 Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Sun, 5 Aug 2018 14:55:33 -0400 Subject: [PATCH 2/3] linting --- adafruit_l3gd20.py | 4 ---- examples/l3gd20_spi_simpletest.py | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/adafruit_l3gd20.py b/adafruit_l3gd20.py index eb12939..1b13b24 100644 --- a/adafruit_l3gd20.py +++ b/adafruit_l3gd20.py @@ -93,10 +93,6 @@ class L3GD20: """ def __init__(self, rng=L3DS20_RANGE_250DPS): - # pylint: disable=consider-using-in - # This should be refactored to fix this pylint issue. - # Pylint error: Consider merging these comparisons with "in" to - # 'rng not in (L3DS20_RANGE_250DPS, L3DS20_RANGE_500DPS, L3DS20_RANGE_2000DPS)' chip_id = self.read_register(_ID_REGISTER) if chip_id != _L3GD20_CHIP_ID and chip_id != _L3GD20H_CHIP_ID: raise RuntimeError("bad chip id (%x != %x or %x)" % diff --git a/examples/l3gd20_spi_simpletest.py b/examples/l3gd20_spi_simpletest.py index fa717d5..02f839d 100644 --- a/examples/l3gd20_spi_simpletest.py +++ b/examples/l3gd20_spi_simpletest.py @@ -1,8 +1,8 @@ import time from board import SCK, MISO, MOSI, D5 import busio -import adafruit_l3gd20 import digitalio +import adafruit_l3gd20 # define the spi conneciton CS = digitalio.DigitalInOut(D5) # select pin is 5 From 7b09f7bde7694b497b86b22eee4cb8530a64bbfe Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Mon, 6 Aug 2018 12:41:55 -0400 Subject: [PATCH 3/3] refactor to original state --- adafruit_l3gd20.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/adafruit_l3gd20.py b/adafruit_l3gd20.py index 1b13b24..83456b7 100644 --- a/adafruit_l3gd20.py +++ b/adafruit_l3gd20.py @@ -210,8 +210,8 @@ class L3GD20_I2C(L3GD20): """Gives the raw acceleration readings, in units of the scaled mdps.""" def __init__(self, i2c, rng=L3DS20_RANGE_250DPS, address=0x6B): - import adafruit_bus_device.i2c_device as i2c_dev - self.i2c_device = i2c_dev.I2CDevice(i2c, address) + import adafruit_bus_device.i2c_device as i2c_device + self.i2c_device = i2c_device.I2CDevice(i2c, address) self.buffer = bytearray(2) super().__init__(rng) @@ -250,8 +250,8 @@ class L3GD20_SPI(L3GD20): :param baudrate: spi baud rate default is 100000 """ def __init__(self, spi_busio, cs, rng=L3DS20_RANGE_250DPS, baudrate=100000): - import adafruit_bus_device.spi_device as spi_dev - self._spi = spi_dev.SPIDevice(spi_busio, cs, baudrate=baudrate) + import adafruit_bus_device.spi_device as spi_device + self._spi = spi_device.SPIDevice(spi_busio, cs, baudrate=baudrate) self._spi_bytearray1 = bytearray(1) self._spi_bytearray6 = bytearray(6) super().__init__(rng)