forked from adafruit/Adafruit_Python_DHT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
80 lines (69 loc) · 2.98 KB
/
setup.py
File metadata and controls
80 lines (69 loc) · 2.98 KB
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
from setuptools import setup, find_packages, Extension
import os
import sys
import Adafruit_DHT.platform_detect as platform_detect
BINARY_COMMANDS = [
'build_ext',
'build_clib',
'bdist',
'bdist_dumb',
'bdist_rpm',
'bdist_wininst',
'bdist_wheel',
'install'
]
def is_binary_install():
do_binary = [command for command in BINARY_COMMANDS if command in sys.argv]
return len(do_binary) > 0
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
# Check if an explicit platform was chosen with a command line parameter.
# Kind of hacky to manipulate the argument list before calling setup, but it's
# the best simple option for adding optional config to the setup.
platform = platform_detect.UNKNOWN
pi_version = None
if '--force-pi' in sys.argv:
platform = platform_detect.RASPBERRY_PI
pi_version = 1
sys.argv.remove('--force-pi')
elif '--force-pi2' in sys.argv:
platform = platform_detect.RASPBERRY_PI
pi_version = 2
sys.argv.remove('--force-pi2')
elif '--force-bbb' in sys.argv:
platform = platform_detect.BEAGLEBONE_BLACK
sys.argv.remove('--force-bbb')
elif '--force-test' in sys.argv:
platform = 'TEST'
sys.argv.remove('--force-test')
else:
# No explicit platform chosen, detect the current platform.
platform = platform_detect.platform_detect()
# Pick the right extension to compile based on the platform.
extensions = []
if not is_binary_install():
print('Skipped loading platform-specific extensions for Adafruit_DHT (we are generating a cross-platform source distribution).')
extensions.append(Extension("Adafruit_DHT.Raspberry_Pi_2_Driver",
["source/_Raspberry_Pi_2_Driver.c", "source/common_dht_read.c", "source/Raspberry_Pi_2/pi_2_dht_read.c", "source/Raspberry_Pi_2/pi_2_mmio.c"],
libraries=['rt'],
extra_compile_args=['-std=gnu99']))
classifiers = ['Development Status :: 4 - Beta',
'Operating System :: POSIX :: Linux',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Topic :: Software Development',
'Topic :: System :: Hardware']
# Call setuptools setup function to install package.
setup(name = 'Adafruit_DHT',
version = '1.4.0',
author = 'Tony DiCola',
author_email = 'tdicola@adafruit.com',
description = 'Library to get readings from the DHT11, DHT22, and AM2302 humidity and temperature sensors on a Raspberry Pi or Beaglebone Black.',
long_description = read('README.md'),
license = 'MIT',
classifiers = classifiers,
url = 'https://github.com/adafruit/Adafruit_Python_DHT/',
packages = find_packages(),
ext_modules = extensions)