2017-11-03 12:41:15 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2017-11-03 15:06:29 +01:00
|
|
|
import errno
|
2017-11-03 12:34:47 +01:00
|
|
|
import os
|
2019-05-26 03:53:48 +02:00
|
|
|
import re
|
2019-05-23 18:51:28 +02:00
|
|
|
import distutils.cmd
|
|
|
|
from distutils.command.build import build
|
2017-11-09 05:04:48 +01:00
|
|
|
from setuptools import setup, find_packages
|
2017-11-03 12:34:47 +01:00
|
|
|
|
2019-05-23 18:51:28 +02:00
|
|
|
|
|
|
|
class WebBuildCommand(distutils.cmd.Command):
|
|
|
|
"""
|
|
|
|
Custom command to build the web files
|
|
|
|
"""
|
|
|
|
|
|
|
|
description = 'Build components and styles for the web pages'
|
|
|
|
user_options = []
|
|
|
|
|
2019-05-26 03:53:48 +02:00
|
|
|
@classmethod
|
|
|
|
def generate_css_files(cls):
|
2019-12-02 00:15:46 +01:00
|
|
|
try:
|
2020-01-01 15:40:42 +01:00
|
|
|
# noinspection PyPackageRequirements
|
2019-12-02 00:15:46 +01:00
|
|
|
from scss import Compiler
|
|
|
|
except ImportError:
|
2019-12-02 00:24:28 +01:00
|
|
|
print('pyScss module not found: {}. You will have to generate ' +
|
|
|
|
'the CSS files manually through python setup.py build install')
|
|
|
|
return
|
2019-05-23 18:51:28 +02:00
|
|
|
|
|
|
|
print('Building CSS files')
|
2020-01-01 15:40:42 +01:00
|
|
|
base_path = path(os.path.join('platypush', 'backend', 'http', 'static', 'css'))
|
|
|
|
input_path = path(os.path.join(base_path, 'source'))
|
|
|
|
output_path = path(os.path.join(base_path, 'dist'))
|
2019-05-23 18:51:28 +02:00
|
|
|
|
2019-06-14 00:54:20 +02:00
|
|
|
for root, dirs, files in os.walk(input_path, followlinks=True):
|
2019-05-23 18:51:28 +02:00
|
|
|
scss_file = os.path.join(root, 'index.scss')
|
|
|
|
if os.path.isfile(scss_file):
|
|
|
|
css_path = os.path.split(scss_file[len(input_path):])[0][1:] + '.css'
|
|
|
|
css_dir = os.path.join(output_path, os.path.dirname(css_path))
|
|
|
|
css_file = os.path.join(css_dir, os.path.basename(css_path))
|
|
|
|
|
|
|
|
os.makedirs(css_dir, exist_ok=True)
|
|
|
|
print('\tGenerating CSS {scss} -> {css}'.format(scss=scss_file, css=css_file))
|
|
|
|
|
|
|
|
with open(css_file, 'w') as f:
|
|
|
|
css_content = Compiler(output_style='compressed', search_path=[root, input_path]).compile(scss_file)
|
2019-05-26 03:53:48 +02:00
|
|
|
css_content = cls._fix_css4_vars(css_content)
|
2019-05-23 18:51:28 +02:00
|
|
|
f.write(css_content)
|
|
|
|
|
2019-05-26 03:53:48 +02:00
|
|
|
@staticmethod
|
|
|
|
def _fix_css4_vars(css):
|
|
|
|
return re.sub(r'var\("--([^"]+)"\)', r'var(--\1)', css)
|
|
|
|
|
2019-05-23 18:51:28 +02:00
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.generate_css_files()
|
|
|
|
|
|
|
|
|
|
|
|
class BuildCommand(build):
|
|
|
|
def run(self):
|
|
|
|
build.run(self)
|
|
|
|
self.run_command('web_build')
|
|
|
|
|
|
|
|
|
|
|
|
def path(fname=''):
|
|
|
|
return os.path.abspath(os.path.join(os.path.dirname(__file__), fname))
|
|
|
|
|
|
|
|
|
|
|
|
def readfile(fname):
|
|
|
|
with open(path(fname)) as f:
|
|
|
|
return f.read()
|
|
|
|
|
2017-11-03 12:34:47 +01:00
|
|
|
|
2020-01-01 15:40:42 +01:00
|
|
|
# noinspection PyShadowingBuiltins
|
2017-11-03 15:06:29 +01:00
|
|
|
def pkg_files(dir):
|
|
|
|
paths = []
|
2020-01-01 15:40:42 +01:00
|
|
|
# noinspection PyShadowingNames
|
2017-11-03 15:06:29 +01:00
|
|
|
for (path, dirs, files) in os.walk(dir):
|
|
|
|
for file in files:
|
|
|
|
paths.append(os.path.join('..', path, file))
|
|
|
|
return paths
|
|
|
|
|
2019-05-23 18:51:28 +02:00
|
|
|
|
2017-11-03 15:06:29 +01:00
|
|
|
def create_etc_dir():
|
2020-01-01 15:40:42 +01:00
|
|
|
# noinspection PyShadowingNames
|
2017-12-11 20:30:57 +01:00
|
|
|
path = '/etc/platypush'
|
2017-11-03 15:06:29 +01:00
|
|
|
try:
|
|
|
|
os.makedirs(path)
|
|
|
|
except OSError as e:
|
2017-11-03 23:14:19 +01:00
|
|
|
if isinstance(e, PermissionError):
|
2017-12-11 20:30:57 +01:00
|
|
|
print('WARNING: Could not create /etc/platypush')
|
2017-11-03 23:14:19 +01:00
|
|
|
elif e.errno == errno.EEXIST and os.path.isdir(path):
|
2017-11-03 15:06:29 +01:00
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2019-05-23 18:51:28 +02:00
|
|
|
|
2017-12-11 20:30:57 +01:00
|
|
|
plugins = pkg_files('platypush/plugins')
|
|
|
|
backend = pkg_files('platypush/backend')
|
2018-06-26 01:12:16 +02:00
|
|
|
# create_etc_dir()
|
2017-11-03 15:06:29 +01:00
|
|
|
|
2017-11-03 12:34:47 +01:00
|
|
|
setup(
|
2020-01-01 15:40:42 +01:00
|
|
|
name="platypush",
|
2020-01-20 22:38:36 +01:00
|
|
|
version="0.11.5",
|
2020-01-01 15:40:42 +01:00
|
|
|
author="Fabio Manganiello",
|
|
|
|
author_email="info@fabiomanganiello.com",
|
|
|
|
description="Platypush service",
|
|
|
|
license="MIT",
|
|
|
|
python_requires='>= 3.5',
|
|
|
|
keywords="home-automation iot mqtt websockets redis dashboard notificaions",
|
|
|
|
url="https://github.com/BlackLight/platypush",
|
|
|
|
packages=find_packages(),
|
|
|
|
include_package_data=True,
|
|
|
|
entry_points={
|
2017-11-03 22:54:08 +01:00
|
|
|
'console_scripts': [
|
2018-01-04 16:11:54 +01:00
|
|
|
'platypush=platypush:main',
|
|
|
|
'pusher=platypush.pusher:main',
|
2018-12-19 02:08:13 +01:00
|
|
|
'platydock=platypush.platydock:main',
|
2017-11-03 22:54:08 +01:00
|
|
|
],
|
|
|
|
},
|
2020-01-01 15:40:42 +01:00
|
|
|
scripts=['bin/platyvenv'],
|
|
|
|
cmdclass={
|
2019-05-23 18:51:28 +02:00
|
|
|
'web_build': WebBuildCommand,
|
|
|
|
'build': BuildCommand,
|
|
|
|
},
|
2018-06-26 01:12:16 +02:00
|
|
|
# data_files = [
|
|
|
|
# ('/etc/platypush', ['platypush/config.example.yaml'])
|
|
|
|
# ],
|
2020-01-01 15:40:42 +01:00
|
|
|
long_description=readfile('README.md'),
|
|
|
|
long_description_content_type='text/markdown',
|
|
|
|
classifiers=[
|
2017-11-03 12:34:47 +01:00
|
|
|
"Topic :: Utilities",
|
2017-11-03 23:09:19 +01:00
|
|
|
"License :: OSI Approved :: MIT License",
|
2017-11-03 22:54:08 +01:00
|
|
|
"Development Status :: 3 - Alpha",
|
2017-11-03 12:34:47 +01:00
|
|
|
],
|
2020-01-01 15:40:42 +01:00
|
|
|
install_requires=[
|
2017-11-09 05:04:48 +01:00
|
|
|
'pyyaml',
|
2018-06-14 12:37:09 +02:00
|
|
|
'redis',
|
2018-12-18 19:01:51 +01:00
|
|
|
'requests',
|
2019-09-28 01:34:27 +02:00
|
|
|
'croniter',
|
2019-12-01 19:54:56 +01:00
|
|
|
'pyScss',
|
2019-12-08 23:19:49 +01:00
|
|
|
'sqlalchemy',
|
2020-01-20 11:47:10 +01:00
|
|
|
'websockets',
|
|
|
|
'websocket-client',
|
2017-11-03 22:54:08 +01:00
|
|
|
],
|
2019-12-01 19:54:56 +01:00
|
|
|
|
2020-01-01 15:40:42 +01:00
|
|
|
extras_require={
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for thread custom name
|
|
|
|
'threadname': ['python-prctl'],
|
|
|
|
# Support for Kafka backend and plugin
|
|
|
|
'kafka': ['kafka-python'],
|
|
|
|
# Support for Pushbullet backend and plugin
|
2020-01-20 22:48:07 +01:00
|
|
|
'pushbullet': ['pushbullet.py @ https://github.com/rbrcsk/pushbullet.py/tarball/master'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for HTTP backend
|
2020-01-20 11:47:10 +01:00
|
|
|
'http': ['flask', 'python-dateutil', 'tz', 'frozendict', 'bcrypt'],
|
2019-12-01 21:31:41 +01:00
|
|
|
# Support for uWSGI HTTP backend
|
2020-01-20 11:47:10 +01:00
|
|
|
'uwsgi': ['flask', 'python-dateutil', 'tz', 'frozendict', 'uwsgi', 'bcrypt'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for database
|
|
|
|
'db': ['sqlalchemy'],
|
|
|
|
# Support for MQTT backends
|
|
|
|
'mqtt': ['paho-mqtt'],
|
|
|
|
# Support for RSS feeds parser
|
|
|
|
'rss': ['feedparser'],
|
|
|
|
# Support for PDF generation
|
|
|
|
'pdf': ['weasyprint'],
|
|
|
|
# Support for Philips Hue plugin
|
2019-12-01 21:31:41 +01:00
|
|
|
'hue': ['phue'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for MPD/Mopidy music server plugin and backend
|
2020-01-20 11:47:10 +01:00
|
|
|
'mpd': ['python-mpd2'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for text2speech plugin
|
|
|
|
'tts': ['mplayer'],
|
|
|
|
# Support for Google text2speech plugin
|
2019-12-08 23:19:49 +01:00
|
|
|
'google-tts': ['oauth2client', 'google-api-python-client', 'google-cloud-texttospeech'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for OMXPlayer plugin
|
|
|
|
'omxplayer': ['omxplayer-wrapper'],
|
|
|
|
# Support for YouTube
|
|
|
|
'youtube': ['youtube-dl'],
|
|
|
|
# Support for torrents download
|
|
|
|
'torrent': ['python-libtorrent'],
|
|
|
|
# Support for RaspberryPi camera
|
|
|
|
'picamera': ['picamera'],
|
|
|
|
# Support for inotify file monitors
|
|
|
|
'inotify': ['inotify'],
|
|
|
|
# Support for Google Assistant
|
|
|
|
'google-assistant-legacy': ['google-assistant-library'],
|
|
|
|
'google-assistant': ['google-assistant-sdk[samples]'],
|
|
|
|
# Support for the Google APIs
|
|
|
|
'google': ['oauth2client', 'google-api-python-client'],
|
|
|
|
# Support for Last.FM scrobbler plugin
|
|
|
|
'lastfm': ['pylast'],
|
|
|
|
# Support for custom hotword detection
|
|
|
|
'hotword': ['snowboy'],
|
|
|
|
# Support for real-time MIDI events
|
|
|
|
'midi': ['rtmidi'],
|
|
|
|
# Support for RaspberryPi GPIO
|
|
|
|
'rpi-gpio': ['RPi.GPIO'],
|
|
|
|
# Support for MCP3008 analog-to-digital converter plugin
|
|
|
|
'mcp3008': ['adafruit-mcp3008'],
|
|
|
|
# Support for smart cards detection
|
|
|
|
'scard': ['pyscard'],
|
|
|
|
# Support for serial port plugin
|
|
|
|
'serial': ['pyserial'],
|
|
|
|
# Support for ICal calendars
|
|
|
|
'ical': ['icalendar', 'python-dateutil'],
|
|
|
|
# Support for joystick backend
|
|
|
|
'joystick': ['inputs'],
|
|
|
|
# Support for Kodi plugin
|
|
|
|
'kodi': ['kodi-json'],
|
|
|
|
# Support for Plex plugin
|
|
|
|
'plex': ['plexapi'],
|
|
|
|
# Support for Chromecast plugin
|
|
|
|
'chromecast': ['pychromecast'],
|
|
|
|
# Support for sound devices
|
|
|
|
'sound': ['sounddevice', 'soundfile', 'numpy'],
|
|
|
|
# Support for web media subtitles
|
|
|
|
'subtitles': [
|
2020-01-01 15:40:42 +01:00
|
|
|
'webvtt-py',
|
|
|
|
'python-opensubtitles @ https://github.com/agonzalezro/python-opensubtitles/tarball/master'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for mpv player plugin
|
|
|
|
'mpv': ['python-mpv'],
|
|
|
|
# Support for NFC tags
|
|
|
|
'nfc': ['nfcpy>=1.0', 'ndef'],
|
|
|
|
# Support for enviropHAT
|
|
|
|
'envirophat': ['envirophat'],
|
|
|
|
# Support for GPS
|
|
|
|
'gps': ['gps'],
|
|
|
|
# Support for BME280 environment sensor
|
|
|
|
'bme280': ['pimoroni-bme280'],
|
|
|
|
# Support for LTR559 light/proximity sensor
|
|
|
|
'ltr559': ['ltr559'],
|
|
|
|
# Support for VL53L1X laser ranger/distance sensor
|
2020-01-01 15:40:42 +01:00
|
|
|
'vl53l1x': ['smbus2', 'vl53l1x'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for Dropbox integration
|
|
|
|
'dropbox': ['dropbox'],
|
|
|
|
# Support for Leap Motion backend
|
|
|
|
'leap': ['leap-sdk @ https://github.com/BlackLight/leap-sdk-python3/tarball/master'],
|
|
|
|
# Support for Flic buttons
|
|
|
|
'flic': ['flic @ https://github.com/50ButtonsEach/fliclib-linux-hci/tarball/master'],
|
|
|
|
# Support for Alexa/Echo plugin
|
|
|
|
'alexa': ['avs @ https://github.com:BlackLight/avs/tarball/master'],
|
2019-12-11 18:05:17 +01:00
|
|
|
# Support for bluetooth devices
|
|
|
|
'bluetooth': ['pybluez', 'gattlib',
|
2020-01-20 22:48:07 +01:00
|
|
|
'pyobex @ https://github.com/BlackLight/PyOBEX/tarball/master'],
|
2019-12-01 19:54:56 +01:00
|
|
|
# Support for TP-Link devices
|
|
|
|
'tplink': ['pyHS100'],
|
|
|
|
# Support for PWM3901 2-Dimensional Optical Flow Sensor
|
|
|
|
'pwm3901': ['pwm3901'],
|
|
|
|
# Support for MLX90640 thermal camera
|
|
|
|
'mlx90640': ['Pillow'],
|
|
|
|
# Support for machine learning and CV plugin
|
|
|
|
'cv': ['cv2', 'numpy'],
|
2019-12-08 16:25:03 +01:00
|
|
|
# Support for the generation of HTML documentation from docstring
|
|
|
|
'htmldoc': ['docutils'],
|
2019-12-08 19:02:08 +01:00
|
|
|
# Support for Node-RED integration
|
|
|
|
'nodered': ['pynodered'],
|
2019-12-25 20:32:54 +01:00
|
|
|
# Support for Todoist integration
|
2019-12-27 15:55:56 +01:00
|
|
|
'todoist': ['todoist-python'],
|
|
|
|
# Support for Trello integration
|
|
|
|
'trello': ['py-trello'],
|
2019-12-30 09:33:26 +01:00
|
|
|
# Support for Google Pub/Sub
|
|
|
|
'google-pubsub': ['google-cloud-pubsub'],
|
2019-12-30 21:35:35 +01:00
|
|
|
# Support for keyboard/mouse plugin
|
|
|
|
'inputs': ['pyuserinput'],
|
2020-01-01 15:40:42 +01:00
|
|
|
# Support for Buienradar weather forecast
|
|
|
|
'buienradar': ['buienradar'],
|
|
|
|
# Support for Telegram integration
|
|
|
|
'telegram': ['python-telegram-bot'],
|
2020-01-05 00:46:46 +01:00
|
|
|
# Support for Arduino integration
|
|
|
|
'arduino': ['pyserial', 'pyfirmata2'],
|
2020-01-05 19:25:20 +01:00
|
|
|
# Support for CUPS printers management
|
|
|
|
'cups': ['pycups'],
|
2020-01-06 15:24:52 +01:00
|
|
|
# Support for Graphite integration
|
|
|
|
'graphite': ['graphyte'],
|
2020-01-07 22:44:23 +01:00
|
|
|
# Support for CPU and memory monitoring and info
|
|
|
|
'sys': ['py-cpuinfo', 'psutil'],
|
2020-01-11 18:51:54 +01:00
|
|
|
# Support for nmap integration
|
|
|
|
'nmap': ['python-nmap'],
|
2020-02-05 22:26:52 +01:00
|
|
|
# Support for zigbee2mqtt
|
|
|
|
'zigbee': ['paho-mqtt'],
|
|
|
|
# Support for Z-Wave
|
|
|
|
'zwave': ['python-openzwave'],
|
2017-12-12 20:14:02 +01:00
|
|
|
},
|
2017-11-03 12:34:47 +01:00
|
|
|
)
|