-
Notifications
You must be signed in to change notification settings - Fork 35
/
setup.py
141 lines (116 loc) · 4.57 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''The setup script.'''
import subprocess
import platform
from setuptools import setup, find_packages, Command
from distutils.command.build import build as _build
with open('README.rst') as readme_file:
readme = readme_file.read()
with open('HISTORY.rst') as history_file:
history = history_file.read()
common_requirements = []
# tensorflow 2.0 wheel has not been released for Raspbian yet
trainer_requirements = [
'ansible==2.8.1',
'tensorflow==2.0.0-beta0',
'tensorflow-datasets==1.0.2',
'tensorflow-hub==0.5.0'
]
trainer_requirements = list(map(
lambda x: x + ';platform_machine=="x86_64"', trainer_requirements
))
rpi_requirements = [
'picamera==1.13.0',
'Pillow==6.0.0'
]
rpi_requirements = list(map(
lambda x: x + ';platform_machine=="armv7l"', rpi_requirements))
if 'arm' in platform.machine():
rpi_requirements.append(
'tensorflow@https://github.com/PINTO0309/Tensorflow-bin/raw/master/tensorflow-2.0.0b1-cp35-cp35m-linux_armv7l.whl')
requirements = common_requirements + trainer_requirements + rpi_requirements
setup_requirements = ['pytest-runner', ]
test_requirements = ['pytest', ]
RPI_LIBS = ['python3-dev', 'cmake']
RPI_CUSTOM_COMMANDS = [['sudo', 'apt-get', 'update'],
['sudo', 'apt-get', 'install', '-y'] + RPI_LIBS
]
TRAINER_DEBIAN_LIBS = ['python3-dev cmake zlib1g-dev']
TRAINER_DEBIAN_CUSTOM_COMMANDS = [['apt-get', 'update'],
['apt-get', 'install', '-y'] + TRAINER_DEBIAN_LIBS]
TRAINER_DARWIN_LIBS = ['cmake']
TRAINER_DARWIN_CUSTOM_COMMANDS = [['brew', 'update'],
['brew', 'install'] + TRAINER_DARWIN_LIBS
]
class CustomCommands(Command):
'''A setuptools Command class able to run arbitrary commands.'''
def initialize_options(self):
pass
def finalize_options(self):
pass
def RunCustomCommand(self, command_list):
print('Running command: %s' % command_list)
p = subprocess.Popen(
command_list,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
# Can use communicate(input='y\n'.encode()) if the command run requires
# some confirmation.
stdout_data, _ = p.communicate()
print('Command output: %s' % stdout_data)
if p.returncode != 0:
raise RuntimeError(
'Command %s failed: exit code: %s' % (
command_list, p.returncode)
)
def run(self):
system = platform.system()
machine = platform.machine()
distro = platform.linux_distribution()
if 'x86' in machine and system == 'Linux' and 'debian' in distro:
if 'debian' in distro:
for command in TRAINER_DEBIAN_CUSTOM_COMMANDS:
self.RunCustomCommand(command)
elif 'arm' in machine and system == 'Linux' and 'debian' in distro:
for command in TRAINER_DEBIAN_CUSTOM_COMMANDS:
self.RunCustomCommand(command)
elif system == 'Darwin':
for command in TRAINER_DARWIN_CUSTOM_COMMANDS:
self.RunCustomCommand(command)
else:
raise NotImplementedError(
'Unsupported Platform: {}. Supported platforms are Debian-derived Linux and Darwin (OS X)'.format(system))
setup(
author='Leigh Johnson',
author_email='[email protected]',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
],
description='Examples and utilities for getting started with computer vision on a Raspberry Pi usingng Tensorflow',
install_requires=requirements,
license='MIT license',
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='rpi_vision',
name='rpi-vision',
packages=find_packages(include=['rpi_vision']),
setup_requires=setup_requirements,
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/leigh-johnson/rpi-vision',
version='0.1.0',
zip_safe=False,
)