From 377bf7e06c1fd8d104daa4a653d7941fac3df2ca Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Mon, 14 Apr 2014 23:12:36 +0100 Subject: [PATCH] v1.1.2 Fix package data packaging. Closes #2 --- MANIFEST.in | 5 ++-- setup.py | 26 +++--------------- shoebill/__init__.py | 7 ++++- {static => shoebill/static}/favicon.ico | Bin {views => shoebill/views}/admin_page.tpl | 0 {views => shoebill/views}/edit.tpl | 0 {views => shoebill/views}/login_form.tpl | 0 {views => shoebill/views}/msgbox.tpl | 0 .../views}/password_change_form.tpl | 0 9 files changed, 13 insertions(+), 25 deletions(-) rename {static => shoebill/static}/favicon.ico (100%) rename {views => shoebill/views}/admin_page.tpl (100%) rename {views => shoebill/views}/edit.tpl (100%) rename {views => shoebill/views}/login_form.tpl (100%) rename {views => shoebill/views}/msgbox.tpl (100%) rename {views => shoebill/views}/password_change_form.tpl (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 9117a8f..3ab9132 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,7 @@ +# Used by setup.py sdist to include files in the source package include tests/*.py include setup.py include README.md include LICENSE -include views/*.tpl -include static/favicon.ico +#include views/*.tpl +#include static/favicon.ico diff --git a/setup.py b/setup.py index 08b22af..e05b59d 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,8 @@ #!/usr/bin/env python -from glob import glob from setuptools import setup -import os.path -__version__ = '0.1.1' +__version__ = '0.1.2' CLASSIFIERS = map(str.strip, """Environment :: Console @@ -16,21 +14,6 @@ Topic :: Internet :: WWW/HTTP :: WSGI """.splitlines()) -data_files_globs = [ - ['views', ['*.tpl']], - ['static', ['*.ico']], -] - - -data_files = [] -for dirname, globs in data_files_globs: - expanded_fnames = set() - for g in globs: - ffn = os.path.join(dirname, g) - expanded_fnames.update(glob(ffn)) - - data_files.append((dirname, sorted(expanded_fnames))) - entry_points = { 'console_scripts': [ 'shoebill = shoebill:main', @@ -57,13 +40,12 @@ 'setproctitle>=1.0.1', ], packages=['shoebill'], - data_files=data_files, + package_dir={'shoebill': 'shoebill'}, platforms=['Linux'], zip_safe=False, test_suite='nose.collector', tests_require=['nose'], entry_points=entry_points, - - package_data = {'': ['*.tpl']}, - include_package_data=True, + # Used by setup.py bdist to include files in the binary package + package_data={'shoebill': ['views/*.tpl', 'static/*']}, ) diff --git a/shoebill/__init__.py b/shoebill/__init__.py index 6757485..2df7f66 100755 --- a/shoebill/__init__.py +++ b/shoebill/__init__.py @@ -20,6 +20,7 @@ from base64 import b64encode from datetime import datetime from git import Repo, InvalidGitRepositoryError +from pkg_resources import resource_filename from setproctitle import setproctitle import argparse import bottle @@ -33,6 +34,10 @@ app = bottle.app() aaa = None +tpl_path = resource_filename('shoebill', 'views') +bottle.TEMPLATE_PATH.insert(0, tpl_path) +static_path = resource_filename('shoebill', 'static') + try: from beaker.middleware import SessionMiddleware from cork import Cork @@ -386,7 +391,7 @@ def route_run_make_target(target): @bottle.route('/favicon.ico') def serve_favicon(): - return bottle.static_file('favicon.ico', root='static/') + return bottle.static_file('favicon.ico', root=static_path) # Admin-only pages diff --git a/static/favicon.ico b/shoebill/static/favicon.ico similarity index 100% rename from static/favicon.ico rename to shoebill/static/favicon.ico diff --git a/views/admin_page.tpl b/shoebill/views/admin_page.tpl similarity index 100% rename from views/admin_page.tpl rename to shoebill/views/admin_page.tpl diff --git a/views/edit.tpl b/shoebill/views/edit.tpl similarity index 100% rename from views/edit.tpl rename to shoebill/views/edit.tpl diff --git a/views/login_form.tpl b/shoebill/views/login_form.tpl similarity index 100% rename from views/login_form.tpl rename to shoebill/views/login_form.tpl diff --git a/views/msgbox.tpl b/shoebill/views/msgbox.tpl similarity index 100% rename from views/msgbox.tpl rename to shoebill/views/msgbox.tpl diff --git a/views/password_change_form.tpl b/shoebill/views/password_change_form.tpl similarity index 100% rename from views/password_change_form.tpl rename to shoebill/views/password_change_form.tpl