Skip to content

Commit

Permalink
Create Python package
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Oct 19, 2017
1 parent 11b8f1a commit ef7911c
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 17 deletions.
15 changes: 14 additions & 1 deletion .gitignore
Expand Up @@ -4,5 +4,18 @@ node_modules/*
bower_components/*
npm-debug.log
.DS_Store
final/*
hass_frontend/*

# Python stuff
*.py[cod]
*.egg
*.egg-info

# venv stuff
pyvenv.cfg
pip-selfcheck.json
venv
.venv
lib
bin
dist
4 changes: 4 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,4 @@
include README.md
include LICENSE.md
graft hass_frontend
recursive-exclude * *.py[co]
2 changes: 1 addition & 1 deletion gulp/tasks/gen-service-worker.js
Expand Up @@ -23,7 +23,7 @@ const config = require('../config');

const DEV = !!JSON.parse(process.env.BUILD_DEV || 'true');

var rootDir = 'final';
var rootDir = 'hass_frontend';
var panelDir = path.resolve(rootDir, 'panels');

var dynamicUrlToDependencies = {
Expand Down
33 changes: 20 additions & 13 deletions script/build_frontend
Expand Up @@ -6,43 +6,50 @@ set -e

cd "$(dirname "$0")/.."

rm -rf final
cp -r public final
OUTPUT_DIR=hass_frontend

rm -rf $OUTPUT_DIR
cp -r public $OUTPUT_DIR

# Build frontend
# BUILD_DEV=0 ./node_modules/.bin/gulp

# Entry points
cp build/*.js build/*.html final
cp build/*.js build/*.html $OUTPUT_DIR

# Panels
mkdir final/panels
cp build/panels/*.html final/panels
mkdir $OUTPUT_DIR/panels
cp build/panels/*.html $OUTPUT_DIR/panels

# Local Roboto
cp -r bower_components/font-roboto-local/fonts final
cp -r bower_components/font-roboto-local/fonts $OUTPUT_DIR

# Polyfill web components
cp bower_components/webcomponentsjs/webcomponents-lite.js final
cp bower_components/webcomponentsjs/custom-elements-es5-adapter.js final
cp bower_components/webcomponentsjs/webcomponents-lite.js $OUTPUT_DIR
cp bower_components/webcomponentsjs/custom-elements-es5-adapter.js $OUTPUT_DIR

# Icons
script/update_mdi.py

# Leaflet
mkdir final/images/leaflet
cp bower_components/leaflet/dist/leaflet.css final/images/leaflet
cp -r bower_components/leaflet/dist/images final/images/leaflet/
mkdir $OUTPUT_DIR/images/leaflet
cp bower_components/leaflet/dist/leaflet.css $OUTPUT_DIR/images/leaflet
cp -r bower_components/leaflet/dist/images $OUTPUT_DIR/images/leaflet/

# Generate service worker
BUILD_DEV=0 ./node_modules/.bin/gulp gen-service-worker
cp build/service_worker.js final
cp build/service_worker.js $OUTPUT_DIR


# GZIP frontend
cd final
cd $OUTPUT_DIR
gzip -f -n -k -9 *.html *.js ./panels/*.html ./fonts/roboto/*.ttf ./fonts/robotomono/*.ttf
cd ..

# Generate the MD5 hash of the new frontend
script/fingerprint_frontend.py

# Generat the __init__ file
echo '"""AUTO-GENERATED. DO NOT MODIFY"""' > $OUTPUT_DIR/__init__.py
echo "VERSION = '`git rev-parse HEAD`'" >> $OUTPUT_DIR/__init__.py
echo "CREATED_AT = `date +%s`" >> $OUTPUT_DIR/__init__.py
2 changes: 1 addition & 1 deletion script/fingerprint_frontend.py
Expand Up @@ -7,7 +7,7 @@
import json

fingerprint_file = '../version.py'
base_dir = 'final/'
base_dir = 'hass_frontend/'


def fingerprint():
Expand Down
2 changes: 1 addition & 1 deletion script/update_mdi.py
Expand Up @@ -12,7 +12,7 @@
DOWNLOAD_LINK = re.compile(r'(/api/download/polymer/v1/([A-Z0-9-]{36}))')
START_ICONSET = '<iron-iconset-svg'

OUTPUT_BASE = 'final'
OUTPUT_BASE = 'hass_frontend'
ICONSET_OUTPUT = os.path.join(OUTPUT_BASE, 'mdi.html')


Expand Down
11 changes: 11 additions & 0 deletions setup.py
@@ -0,0 +1,11 @@
from setuptools import setup, find_packages

setup(name='home-assistant-frontend',
version='0.1',
description='The Home Assistant frontend',
url='https://github.com/home-assistant/home-assistant-polymer',
author='Paulus Schoutsen',
author_email='Paulus@PaulusSchoutsen.nl',
license='Apache License 2.0',
packages=find_packages(include=['hass_frontend', 'hass_frontend.*']),
zip_safe=True)

0 comments on commit ef7911c

Please sign in to comment.