From b96c7a17cf75a49ec74ad19043e55f40a58d827a Mon Sep 17 00:00:00 2001 From: Daniel Parks Date: Wed, 13 Sep 2017 11:03:25 -0700 Subject: [PATCH] Include static and templates in the built package --- MANIFEST.in | 2 ++ infinitory/cli.py | 8 ++++++-- {static => infinitory/static}/general.css | 0 {static => infinitory/static}/general.js | 0 {static => infinitory/static}/moment.js | 0 {templates => infinitory/templates}/home.html | 0 {templates => infinitory/templates}/layout.html | 0 {templates => infinitory/templates}/node.html | 0 {templates => infinitory/templates}/nodes.html | 0 {templates => infinitory/templates}/roles.html | 0 {templates => infinitory/templates}/service.html | 0 {templates => infinitory/templates}/services.html | 0 setup.py | 2 +- 13 files changed, 9 insertions(+), 3 deletions(-) rename {static => infinitory/static}/general.css (100%) rename {static => infinitory/static}/general.js (100%) rename {static => infinitory/static}/moment.js (100%) rename {templates => infinitory/templates}/home.html (100%) rename {templates => infinitory/templates}/layout.html (100%) rename {templates => infinitory/templates}/node.html (100%) rename {templates => infinitory/templates}/nodes.html (100%) rename {templates => infinitory/templates}/roles.html (100%) rename {templates => infinitory/templates}/service.html (100%) rename {templates => infinitory/templates}/services.html (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 9561fb1..71c516f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,3 @@ include README.rst +graft infinitory/static +graft infinitory/templates diff --git a/infinitory/cli.py b/infinitory/cli.py index 23bfbc9..a5921f6 100755 --- a/infinitory/cli.py +++ b/infinitory/cli.py @@ -24,7 +24,10 @@ def output_html(inventory, directory): if os.path.isdir(directory): shutil.rmtree(directory) os.mkdir(directory, 0o755) - shutil.copytree("static", "{}/static".format(directory)) + + shutil.copytree( + "{}/static".format(os.path.dirname(os.path.abspath(__file__))), + "{}/static".format(directory)) with open("{}/pygments.css".format(directory), "w", encoding="utf-8") as css: css.write(pygments.formatters.HtmlFormatter().get_style_defs('.codehilite')) @@ -126,8 +129,9 @@ def output_html(inventory, directory): def render_template(template_name, **kwargs): + data_path = os.path.dirname(os.path.abspath(__file__)) environment = jinja2.Environment( - loader=jinja2.FileSystemLoader("templates"), + loader=jinja2.FileSystemLoader("{}/templates".format(data_path)), autoescape=jinja2.select_autoescape(default=True)) md = markdown2.Markdown(extras=[ diff --git a/static/general.css b/infinitory/static/general.css similarity index 100% rename from static/general.css rename to infinitory/static/general.css diff --git a/static/general.js b/infinitory/static/general.js similarity index 100% rename from static/general.js rename to infinitory/static/general.js diff --git a/static/moment.js b/infinitory/static/moment.js similarity index 100% rename from static/moment.js rename to infinitory/static/moment.js diff --git a/templates/home.html b/infinitory/templates/home.html similarity index 100% rename from templates/home.html rename to infinitory/templates/home.html diff --git a/templates/layout.html b/infinitory/templates/layout.html similarity index 100% rename from templates/layout.html rename to infinitory/templates/layout.html diff --git a/templates/node.html b/infinitory/templates/node.html similarity index 100% rename from templates/node.html rename to infinitory/templates/node.html diff --git a/templates/nodes.html b/infinitory/templates/nodes.html similarity index 100% rename from templates/nodes.html rename to infinitory/templates/nodes.html diff --git a/templates/roles.html b/infinitory/templates/roles.html similarity index 100% rename from templates/roles.html rename to infinitory/templates/roles.html diff --git a/templates/service.html b/infinitory/templates/service.html similarity index 100% rename from templates/service.html rename to infinitory/templates/service.html diff --git a/templates/services.html b/infinitory/templates/services.html similarity index 100% rename from templates/services.html rename to infinitory/templates/services.html diff --git a/setup.py b/setup.py index dd57152..efeb328 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ import setuptools setuptools.setup( name = "infinitory", - version = "0.0.1", + version = "0.0.2", description = "SRE host, role, and service inventory", author = "Daniel Parks",