1
|
|
|
from __future__ import print_function |
2
|
|
|
from setuptools import setup, find_packages |
3
|
|
|
|
4
|
|
|
import io |
5
|
|
|
import os |
6
|
|
|
from setuptools import Command |
7
|
|
|
#from bricknil.version import __version__ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
# Load the package's __version__.py module as a dictionary. |
11
|
|
|
here = os.path.abspath(os.path.dirname(__file__)) |
12
|
|
|
about = {} |
13
|
|
|
with open(os.path.join(here, 'bricknil', 'version.py')) as f: |
14
|
|
|
exec(f.read(), about) |
15
|
|
|
|
16
|
|
|
class PyTest(Command): |
17
|
|
|
user_options = [] |
18
|
|
|
def initialize_options(self): |
19
|
|
|
pass |
20
|
|
|
def finalize_options(self): |
21
|
|
|
pass |
22
|
|
|
def run(self): |
23
|
|
|
import sys,subprocess |
24
|
|
|
cwd = os.getcwd() |
25
|
|
|
os.chdir('test') |
26
|
|
|
errno = subprocess.call([sys.executable, 'runtests.py']) |
27
|
|
|
os.chdir(cwd) |
28
|
|
|
raise SystemExit(errno) |
29
|
|
|
|
30
|
|
|
def read(*filenames, **kwargs): |
31
|
|
|
encoding = kwargs.get('encoding', 'utf-8') |
32
|
|
|
sep = kwargs.get('sep', '\n') |
33
|
|
|
buf = [] |
34
|
|
|
for filename in filenames: |
35
|
|
|
with io.open(filename, encoding=encoding) as f: |
36
|
|
|
headline_count = 0 |
37
|
|
|
found_features = False |
38
|
|
|
for line in f.readlines(): |
39
|
|
|
# Keep reading until we find the first headline |
40
|
|
|
# after Features |
41
|
|
|
if line.startswith('Features'): |
42
|
|
|
found_features = True |
43
|
|
|
if line.startswith('####'): |
44
|
|
|
headline_count += 1 |
45
|
|
|
if found_features and headline_count == 2: |
46
|
|
|
buf = buf[:-1] |
47
|
|
|
break |
48
|
|
|
else: |
49
|
|
|
buf.append(line.rstrip()) |
50
|
|
|
return sep.join(buf) |
51
|
|
|
|
52
|
|
|
packages = find_packages(exclude="tests") |
53
|
|
|
|
54
|
|
|
long_description = read('README.rst') |
55
|
|
|
|
56
|
|
|
required = [] |
57
|
|
|
dependency_links = [] |
58
|
|
|
with open("requirements.txt") as f: |
59
|
|
|
for line in f.read().splitlines(): |
60
|
|
|
if line.startswith('git'): |
61
|
|
|
_, url = line.split('+') |
62
|
|
|
pkg_name = url[url.index('=')+1:] |
63
|
|
|
dependency_links.append(url) |
64
|
|
|
required.append(pkg_name) |
65
|
|
|
else: |
66
|
|
|
required.append(line) |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
setup ( |
70
|
|
|
name = "bricknil", |
71
|
|
|
version = about['__version__'], |
72
|
|
|
description="Control LEGO(tm) BluetoothLE Hubs, Motors, and Sensors using Async Python", |
73
|
|
|
license = "ASL 2.0", |
74
|
|
|
long_description = long_description, |
75
|
|
|
author="Virantha N. Ekanayake", |
76
|
|
|
author_email="[email protected]", # Removed. |
77
|
|
|
url='https://virantha.github.io/bricknil', |
78
|
|
|
package_data = {'': ['*.xml']}, |
79
|
|
|
zip_safe = True, |
80
|
|
|
include_package_data = True, |
81
|
|
|
packages = packages, |
82
|
|
|
install_requires = required + ['pyobjc ; sys.platform == "darwin"', |
83
|
|
|
'bricknil-bleak ; sys.platform != "darwin"'], |
84
|
|
|
dependency_links = dependency_links, |
85
|
|
|
entry_points = { |
86
|
|
|
'console_scripts': [ |
87
|
|
|
'bricknil = bricknil.bricknil:main' |
88
|
|
|
], |
89
|
|
|
}, |
90
|
|
|
options = { |
91
|
|
|
"pyinstaller": {"packages": packages} |
92
|
|
|
}, |
93
|
|
|
cmdclass = {'test':PyTest} |
94
|
|
|
|
95
|
|
|
) |
96
|
|
|
|