Skip to content

Commit

Permalink
adding template files on install
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Nov 28, 2016
1 parent 06292bc commit da62fcf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion aiohttp_devtools/start/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def generate_directory(self, p: Path):
self.generate_directory(pp)
else:
assert pp.is_file()
self.generate_file(pp)
if not pp.name.endswith('.pyc'):
self.generate_file(pp)

def generate_file(self, p: Path):
try:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp_devtools/start/template/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{# This file is special: lines are made unique, stripped and sorted before the new requirements.txt file is created #}

aiohttp==1.1.1
aiohttp==1.1.6
trafaret-config==0.1.1

{% if template_engine.is_jinja2 %}
Expand Down
22 changes: 18 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import os
from importlib.machinery import SourceFileLoader
from pathlib import Path
from setuptools import setup

long_description = Path(__file__).resolve().parent.joinpath('README.rst').read_text()
THIS_DIR = Path(__file__).resolve().parent
long_description = THIS_DIR.joinpath('README.rst').read_text()

# avoid loading the package before requirements are installed:
version = SourceFileLoader('version', 'aiohttp_devtools/version.py').load_module()


def check_livereload_js():
import hashlib
from pathlib import Path
live_reload_221_hash = 'a451e4d39b8d7ef62d380d07742b782f'
live_reload_221_url = 'https://raw.githubusercontent.com/livereload/livereload-js/v2.2.1/dist/livereload.js'

path = Path(__file__).absolute().parent.joinpath('aiohttp_devtools/runserver/livereload.js')
path = THIS_DIR.joinpath('aiohttp_devtools/runserver/livereload.js')

def check_path():
with path.open('rb') as fr:
Expand All @@ -37,6 +38,16 @@ def check_path():

check_livereload_js()

package = THIS_DIR.joinpath('aiohttp_devtools/start')

start_package_data = []

for _root, _, files in os.walk(str(THIS_DIR.joinpath('aiohttp_devtools/start/template'))):
root = Path(_root)
for f in files:
p = root / f
start_package_data.append(str(p.relative_to(package)))

setup(
name='aiohttp-devtools',
version=str(version.VERSION),
Expand All @@ -61,7 +72,10 @@ def check_path():
author_email='[email protected]',
url='https://github.com/samuelcolvin/aiohttp-devtools',
license='MIT',
package_data={'aiohttp_devtools.runserver': ['livereload.js']},
package_data={
'aiohttp_devtools.runserver': ['livereload.js'],
'aiohttp_devtools.start': start_package_data,
},
packages=[
'aiohttp_devtools',
'aiohttp_devtools.runserver',
Expand Down

0 comments on commit da62fcf

Please sign in to comment.