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-05-23 18:51:28 +02:00
|
|
|
from scss import Compiler
|
|
|
|
|
|
|
|
print('Building CSS files')
|
|
|
|
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-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
|
|
|
|
2017-11-03 15:06:29 +01:00
|
|
|
def pkg_files(dir):
|
|
|
|
paths = []
|
|
|
|
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():
|
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(
|
2017-12-11 20:30:57 +01:00
|
|
|
name = "platypush",
|
2019-07-25 18:40:05 +02:00
|
|
|
version = "0.10.6",
|
2017-11-03 12:34:47 +01:00
|
|
|
author = "Fabio Manganiello",
|
|
|
|
author_email = "info@fabiomanganiello.com",
|
2017-12-11 20:30:57 +01:00
|
|
|
description = ("Platypush service"),
|
2017-11-03 18:06:58 +01:00
|
|
|
license = "MIT",
|
2019-05-23 18:51:28 +02:00
|
|
|
python_requires = '>= 3.5',
|
|
|
|
keywords = "home-automation iot mqtt websockets redis dashboard notificaions",
|
2017-12-11 20:30:57 +01:00
|
|
|
url = "https://github.com/BlackLight/platypush",
|
2017-11-09 05:04:48 +01:00
|
|
|
packages = find_packages(),
|
2018-01-29 16:04:01 +01:00
|
|
|
include_package_data = True,
|
2017-11-03 22:54:08 +01:00
|
|
|
entry_points = {
|
|
|
|
'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
|
|
|
],
|
|
|
|
},
|
2019-02-07 14:26:10 +01:00
|
|
|
scripts = ['bin/platyvenv'],
|
2019-05-23 18:51:28 +02:00
|
|
|
cmdclass = {
|
|
|
|
'web_build': WebBuildCommand,
|
|
|
|
'build': BuildCommand,
|
|
|
|
},
|
2018-06-26 01:12:16 +02:00
|
|
|
# data_files = [
|
|
|
|
# ('/etc/platypush', ['platypush/config.example.yaml'])
|
|
|
|
# ],
|
2019-05-23 18:51:28 +02:00
|
|
|
long_description = readfile('README.md'),
|
2019-07-09 02:14:00 +02:00
|
|
|
long_description_content_type = 'text/markdown',
|
2017-11-03 15:06:29 +01:00
|
|
|
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
|
|
|
],
|
2017-11-03 15:06:29 +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',
|
2017-11-03 22:54:08 +01:00
|
|
|
],
|
2017-12-12 20:14:02 +01:00
|
|
|
extras_require = {
|
2019-01-14 00:00:28 +01:00
|
|
|
'Support for custom thread and process names': ['python-prctl'],
|
2017-12-12 20:14:02 +01:00
|
|
|
'Support for Apache Kafka backend': ['kafka-python'],
|
2018-12-27 02:30:34 +01:00
|
|
|
'Support for Pushbullet backend': ['requests', 'pushbullet.py'],
|
2018-12-18 19:01:51 +01:00
|
|
|
'Support for HTTP backend': ['flask','websockets', 'python-dateutil'],
|
2018-01-09 18:44:45 +01:00
|
|
|
'Support for HTTP poll backend': ['frozendict'],
|
2019-02-24 12:35:26 +01:00
|
|
|
'Support for external web server': ['uwsgi'],
|
2018-01-27 04:31:09 +01:00
|
|
|
'Support for database plugin': ['sqlalchemy'],
|
|
|
|
'Support for RSS feeds': ['feedparser'],
|
2018-01-28 02:01:54 +01:00
|
|
|
'Support for PDF generation': ['weasyprint'],
|
2017-12-12 20:14:02 +01:00
|
|
|
'Support for Philips Hue plugin': ['phue'],
|
2017-12-16 02:27:51 +01:00
|
|
|
'Support for MPD/Mopidy music server plugin': ['python-mpd2'],
|
2019-08-16 11:13:09 +02:00
|
|
|
# 'Support for Belkin WeMo Switch plugin': ['git+https://github.com/iancmcc/ouimeaux'],
|
2017-12-27 00:39:06 +01:00
|
|
|
'Support for text2speech plugin': ['mplayer'],
|
2017-12-27 10:18:51 +01:00
|
|
|
'Support for OMXPlayer plugin': ['omxplayer'],
|
2018-05-13 14:29:27 +02:00
|
|
|
'Support for YouTube in the OMXPlayer plugin': ['youtube-dl'],
|
2018-04-25 11:29:03 +02:00
|
|
|
'Support for torrents download': ['python-libtorrent'],
|
2018-01-09 18:44:45 +01:00
|
|
|
'Support for Google Assistant': ['google-assistant-library'],
|
2018-01-17 03:16:59 +01:00
|
|
|
'Support for the Google APIs': ['google-api-python-client'],
|
2018-01-11 19:31:44 +01:00
|
|
|
'Support for most of the HTTP poll backends': ['python-dateutil'],
|
2018-01-15 02:41:54 +01:00
|
|
|
'Support for Last.FM scrobbler plugin': ['pylast'],
|
2018-03-20 23:34:36 +01:00
|
|
|
'Support for custom hotword detection': ['snowboy'],
|
2018-05-23 19:49:54 +02:00
|
|
|
'Support for real-time MIDI events': ['rtmidi'],
|
2018-04-17 01:02:55 +02:00
|
|
|
'Support for GPIO pins access': ['RPi.GPIO'],
|
|
|
|
'Support for MCP3008 analog-to-digital converter plugin': ['adafruit-mcp3008'],
|
2018-05-27 10:50:48 +02:00
|
|
|
'Support for smart cards detection': ['pyscard'],
|
2018-05-30 15:59:07 +02:00
|
|
|
'Support for ICal calendars': ['icalendar', 'python-dateutil'],
|
2018-09-18 18:58:19 +02:00
|
|
|
'Support for joystick backend': ['inputs'],
|
2018-11-12 16:50:20 +01:00
|
|
|
'Support for Kodi plugin': ['kodi-json'],
|
|
|
|
'Support for Plex plugin': ['plexapi'],
|
|
|
|
'Support for Chromecast plugin': ['pychromecast'],
|
2018-12-15 01:18:45 +01:00
|
|
|
'Support for sound devices': ['sounddevice', 'soundfile', 'numpy'],
|
2019-02-12 22:54:53 +01:00
|
|
|
'Support for web media subtitles': ['webvtt-py'],
|
2019-02-12 22:52:29 +01:00
|
|
|
'Support for mopidy backend': ['websocket-client'],
|
2019-02-19 00:15:03 +01:00
|
|
|
'Support for mpv player plugin': ['python-mpv'],
|
2019-05-23 18:51:28 +02:00
|
|
|
'Support for compiling SASS/SCSS styles to CSS': ['pyScss'],
|
2019-07-09 01:44:31 +02:00
|
|
|
'Support for NFC tags': ['nfcpy>=1.0', 'ndef'],
|
2019-08-01 22:40:41 +02:00
|
|
|
'Support for enviropHAT': ['envirophat'],
|
2019-08-03 02:06:06 +02:00
|
|
|
'Support for GPS': ['gps'],
|
2019-08-14 21:27:25 +02:00
|
|
|
'Support for BME280 environment sensor': ['pimoroni-bme280'],
|
|
|
|
'Support for LTR559 light/proximity sensor': ['ltr559'],
|
2019-08-15 00:24:57 +02:00
|
|
|
'Support for VL53L1X laser ranger/distance sensor': ['smbus2','vl53l1x'],
|
2018-06-14 12:37:09 +02:00
|
|
|
# 'Support for Leap Motion backend': ['git+ssh://git@github.com:BlackLight/leap-sdk-python3.git'],
|
2018-12-18 19:01:51 +01:00
|
|
|
# 'Support for Flic buttons': ['git+https://@github.com/50ButtonsEach/fliclib-linux-hci.git']
|
2019-02-12 01:30:55 +01:00
|
|
|
# 'Support for media subtitles': ['git+https://github.com/agonzalezro/python-opensubtitles#egg=python-opensubtitles']
|
2017-12-12 20:14:02 +01:00
|
|
|
},
|
2017-11-03 12:34:47 +01:00
|
|
|
)
|
|
|
|
|