From 97efa7cdf6ea87ec654ca3c6027dbe44b993b176 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Mon, 4 Sep 2017 15:57:23 +0800 Subject: bugfix: leverage data_files to stop hacking setup.py 1) leverage data_files to distribute ui related files, and dispatch them under /usr/local/share/opnfv_testapi 2) delete hacking coding, no more extra processes 3) utilize MANIFEST.in to include 3rd_party when producing a source distribution Change-Id: Idb83a02be11f6b24610191e9f85e0db80d92e972 Signed-off-by: SerenaFeng --- testapi/MANIFEST.in | 1 + testapi/etc/config.ini | 3 +++ testapi/opnfv_testapi/cmd/server.py | 2 +- testapi/opnfv_testapi/common/config.py | 4 ---- testapi/opnfv_testapi/router/url_mappings.py | 2 +- testapi/opnfv_testapi/ui/root.py | 2 +- testapi/setup.cfg | 15 +++------------ testapi/setup.py | 9 +-------- 8 files changed, 11 insertions(+), 27 deletions(-) create mode 100644 testapi/MANIFEST.in (limited to 'testapi') diff --git a/testapi/MANIFEST.in b/testapi/MANIFEST.in new file mode 100644 index 0000000..0ba1808 --- /dev/null +++ b/testapi/MANIFEST.in @@ -0,0 +1 @@ +recursive-include 3rd_party \ No newline at end of file diff --git a/testapi/etc/config.ini b/testapi/etc/config.ini index db0e191..a7d8da6 100644 --- a/testapi/etc/config.ini +++ b/testapi/etc/config.ini @@ -21,6 +21,9 @@ authenticate = False [ui] url = http://localhost:8000 +# this path should be the seem with data_files installation path +static_path = /usr/local/share/opnfv_testapi + [lfid] # Linux Foundation cas URL cas_url = https://identity.linuxfoundation.org/cas/ diff --git a/testapi/opnfv_testapi/cmd/server.py b/testapi/opnfv_testapi/cmd/server.py index 50ac049..b7d3caa 100644 --- a/testapi/opnfv_testapi/cmd/server.py +++ b/testapi/opnfv_testapi/cmd/server.py @@ -38,7 +38,7 @@ from opnfv_testapi.tornado_swagger import swagger def make_app(): swagger.docs(base_url=CONF.ui_url, - static_path=CONF.static_path) + static_path=CONF.ui_static_path) return swagger.Application( url_mappings.mappings, debug=CONF.api_debug, diff --git a/testapi/opnfv_testapi/common/config.py b/testapi/opnfv_testapi/common/config.py index 4cd53c6..0b85f4e 100644 --- a/testapi/opnfv_testapi/common/config.py +++ b/testapi/opnfv_testapi/common/config.py @@ -20,10 +20,6 @@ class Config(object): self._set_config_file() self._parse() self._parse_per_page() - self.static_path = os.path.join( - os.path.dirname(os.path.normpath(__file__)), - os.pardir, - 'static') def _parse(self): if not os.path.exists(self.config_file): diff --git a/testapi/opnfv_testapi/router/url_mappings.py b/testapi/opnfv_testapi/router/url_mappings.py index be6240e..c038e88 100644 --- a/testapi/opnfv_testapi/router/url_mappings.py +++ b/testapi/opnfv_testapi/router/url_mappings.py @@ -72,7 +72,7 @@ mappings = [ # static path (r'/(.*\.(css|png|gif|js|html|json|map|woff2|woff|ttf))', tornado.web.StaticFileHandler, - {'path': CONF.static_path}), + {'path': CONF.ui_static_path}), (r'/', root.RootHandler), (r'/api/v1/auth/signin', sign.SigninHandler), diff --git a/testapi/opnfv_testapi/ui/root.py b/testapi/opnfv_testapi/ui/root.py index 069ad5e..576cbdd 100644 --- a/testapi/opnfv_testapi/ui/root.py +++ b/testapi/opnfv_testapi/ui/root.py @@ -5,7 +5,7 @@ from opnfv_testapi.resources import handlers class RootHandler(handlers.GenericApiHandler): def get_template_path(self): - return CONF.static_path + return CONF.ui_static_path @check.login def get(self): diff --git a/testapi/setup.cfg b/testapi/setup.cfg index ab1ef55..030e05a 100644 --- a/testapi/setup.cfg +++ b/testapi/setup.cfg @@ -23,18 +23,10 @@ setup-hooks = [files] packages = opnfv_testapi -package_data = - opnfv_testapi = - static/*.* - static/*/*.* - static/*/*/*.* - static/*/*/*/*.* - static/*/*/*/*/*.* - static/*/*/*/*/*/*.* - static/*/*/*/*/*/*/*.* + data_files = - /etc/opnfv_testapi = - etc/config.ini + etc/opnfv_testapi = etc/config.ini + /usr/local/share/opnfv_testapi = 3rd_party/static/* [entry_points] console_scripts = @@ -44,4 +36,3 @@ console_scripts = tag_build = tag_date = 0 tag_svn_revision = 0 - diff --git a/testapi/setup.py b/testapi/setup.py index dd52373..f9d95a3 100644 --- a/testapi/setup.py +++ b/testapi/setup.py @@ -1,6 +1,3 @@ -import os -import subprocess - import setuptools __author__ = 'serena' @@ -10,11 +7,7 @@ try: except ImportError: pass -dirpath = os.path.dirname(os.path.abspath(__file__)) -subprocess.call(['ln', '-s', - '{}/3rd_party/static'.format(dirpath), - '{}/opnfv_testapi/static'.format(dirpath)]) setuptools.setup( - setup_requires=['pbr==2.0.0'], + setup_requires=['pbr>=2.0.0'], pbr=True) -- cgit 1.2.3-korg