|
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
|
|
|
break |
|
47
|
|
|
else: |
|
48
|
|
|
buf.append(line.rstrip()) |
|
49
|
|
|
return sep.join(buf) |
|
50
|
|
|
|
|
51
|
|
|
packages = find_packages(exclude="tests") |
|
52
|
|
|
|
|
53
|
|
|
long_description = read('README.rst') |
|
54
|
|
|
print(long_description) |
|
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
|
|
|
package_data = {'': ['*.xml']}, |
|
78
|
|
|
zip_safe = True, |
|
79
|
|
|
include_package_data = True, |
|
80
|
|
|
packages = packages, |
|
81
|
|
|
install_requires = required + ['pyobjc ; sys.platform == "darwin"', |
|
82
|
|
|
'bricknil-bleak ; sys.platform != "darwin"'], |
|
83
|
|
|
dependency_links = dependency_links, |
|
84
|
|
|
entry_points = { |
|
85
|
|
|
'console_scripts': [ |
|
86
|
|
|
'bricknil = bricknil.bricknil:main' |
|
87
|
|
|
], |
|
88
|
|
|
}, |
|
89
|
|
|
options = { |
|
90
|
|
|
"pyinstaller": {"packages": packages} |
|
91
|
|
|
}, |
|
92
|
|
|
cmdclass = {'test':PyTest} |
|
93
|
|
|
|
|
94
|
|
|
) |
|
95
|
|
|
|