]> Repositories - Adafruit_Blinka-hackapet.git/blob - setup.py
Lint! Untested.
[Adafruit_Blinka-hackapet.git] / setup.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # Note: To use the 'upload' functionality of this file, you must:
5 #   $ pip install twine
6
7 import io
8 import os
9 import sys
10 from shutil import rmtree
11
12 from setuptools import find_packages, setup, Command
13
14 # Package meta-data.
15 NAME = 'Adafruit-Blinka'
16 DESCRIPTION = 'CircuitPython APIs for non-CircuitPython versions of Python such as CPython on Linux and MicroPython.'
17 URL = 'https://github.com/adafruit/Adafruit_Blinka'
18 EMAIL = 'python@adafruit.com'
19 AUTHOR = 'Adafruit Industries'
20 REQUIRES_PYTHON = '>=3.6.0'
21 VERSION = None
22
23 # What packages are required for this module to be executed?
24 REQUIRED = [
25     # 'requests', 'maya', 'records',
26 ]
27
28 here = os.path.abspath(os.path.dirname(__file__))
29
30 # Import the README and use it as the long-description.
31 # Note: this will only work if 'README.md' is present in your MANIFEST.in file!
32 with io.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
33     long_description = '\n' + f.read()
34
35 # Load the package's __version__.py module as a dictionary.
36 about = {}
37 if not VERSION:
38     # with open(os.path.join(here, NAME, '__version__.py')) as f:
39     with open(os.path.join(here, 'src', '__version__.py')) as f:
40         exec(f.read(), about)
41 else:
42     about['__version__'] = VERSION
43
44
45 class UploadCommand(Command):
46     """Support setup.py upload."""
47
48     description = 'Build and publish the package.'
49     user_options = []
50
51     @staticmethod
52     def status(s):
53         """Prints things in bold."""
54         print('\033[1m{0}\033[0m'.format(s))
55
56     def initialize_options(self):
57         pass
58
59     def finalize_options(self):
60         pass
61
62     def run(self):
63         try:
64             self.status('Removing previous builds…')
65             rmtree(os.path.join(here, 'dist'))
66         except OSError:
67             pass
68
69         self.status('Building Source and Wheel (universal) distribution…')
70         os.system('{0} setup.py sdist bdist_wheel --universal'.format(sys.executable))
71
72         self.status('Uploading the package to PyPi via Twine…')
73         os.system('twine upload dist/*')
74
75         self.status('Pushing git tags…')
76         os.system('git tag v{0}'.format(about['__version__']))
77         os.system('git push --tags')
78
79         sys.exit()
80
81
82 # Where the magic happens:
83 setup(
84     name=NAME,
85     version=about['__version__'],
86     description=DESCRIPTION,
87     long_description=long_description,
88     long_description_content_type='text/x-rst',
89     author=AUTHOR,
90     author_email=EMAIL,
91     python_requires=REQUIRES_PYTHON,
92     url=URL,
93     package_dir={'': 'src'},
94     #packages=find_packages(exclude=('tests',)),
95     packages=[
96         'adafruit_blinka',
97         'adafruit_blinka.agnostic',
98         'adafruit_blinka.board',
99         'adafruit_blinka.microcontroller',
100         'adafruit_blinka.microcontroller.esp8266',
101         'adafruit_blinka.microcontroller.stm32',
102         'microcontroller'
103     ],
104     # If your package is a single module, use this instead of 'packages':
105     py_modules=['bitbangio', 'board', 'busio', 'digitalio'],
106     # entry_points={
107     #     'console_scripts': ['mycli=mymodule:cli'],
108     # },
109     install_requires=REQUIRED,
110     include_package_data=True,
111     license='MIT',
112     classifiers=[
113         # Trove classifiers
114         # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
115         'License :: OSI Approved :: MIT License',
116         'Programming Language :: Python',
117         'Programming Language :: Python :: 3',
118         'Programming Language :: Python :: 3.6',
119         'Programming Language :: Python :: Implementation :: MicroPython',
120     ],
121     # $ setup.py publish support.
122     cmdclass={
123         'upload': UploadCommand,
124     },
125 )