From f502068f8b8383ab7f822255bd71e3bc1d98ada0 Mon Sep 17 00:00:00 2001 From: Craig Date: Sat, 24 Aug 2019 08:28:12 -0700 Subject: [PATCH 1/4] Moving towards a whitelist approach for MANIFEST.in when it comes to static resources --- .gitignore | 1 + MANIFEST.in | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 27e03b67ae1..ad106b34fa1 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ .DS_Store .eggs .idea +.mypy_cache .python-version .tox .vscode diff --git a/MANIFEST.in b/MANIFEST.in index 363faac03b3..0e7fbcdfe9a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -20,15 +20,14 @@ graft licenses/ include README.md recursive-include superset/examples * recursive-include superset/migrations * -recursive-include superset/static * -recursive-exclude superset/static/assets/docs * -recursive-exclude superset/static/assets/images/viz_thumbnails_large * -recursive-exclude superset/static/docs * -recursive-exclude superset/static/spec * -recursive-exclude superset/static/assets/src * -recursive-include superset/static/assets/src/visualizations/CountryMap/ * + +# Whitelist anything that needs to be added to the static bundle +recursive-include superset/static/assets/branding * +recursive-include superset/static/assets/dist * +recursive-include superset/static/assets/images * recursive-exclude superset/static/images/viz_thumbnails_large * -recursive-exclude superset/static/assets/node_modules * +recursive-include superset/static/assets/stylesheets * + recursive-include superset/templates * recursive-include superset/translations * recursive-exclude tests * From 04921bccabcf5cf54ea254500bf0593f35adf268 Mon Sep 17 00:00:00 2001 From: Craig Date: Sat, 24 Aug 2019 09:13:39 -0700 Subject: [PATCH 2/4] Tuning static exclude --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 0e7fbcdfe9a..10872f48f5f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -22,6 +22,7 @@ recursive-include superset/examples * recursive-include superset/migrations * # Whitelist anything that needs to be added to the static bundle +recursive-exclude superset/static * recursive-include superset/static/assets/branding * recursive-include superset/static/assets/dist * recursive-include superset/static/assets/images * From c16ae0dc97c42d4668624a103f290be53b01b6de Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 26 Aug 2019 09:01:28 -0700 Subject: [PATCH 3/4] Fix for fetching version string from package.json, which no longer exists --- superset/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset/config.py b/superset/config.py index 085c8e2e56b..2f3ef43f330 100644 --- a/superset/config.py +++ b/superset/config.py @@ -48,9 +48,9 @@ # Superset specific config # --------------------------------------------------------- PACKAGE_DIR = os.path.join(BASE_DIR, "static", "assets") -PACKAGE_FILE = os.path.join(PACKAGE_DIR, "package.json") -with open(PACKAGE_FILE) as package_file: - VERSION_STRING = json.load(package_file)["version"] +VERSION_INFO_FILE = os.path.join(PACKAGE_DIR, "version_info.json") +with open(VERSION_INFO_FILE) as version_info_file: + VERSION_STRING = json.load(version_info_file)["version"] ROW_LIMIT = 50000 VIZ_ROW_LIMIT = 10000 From 6936c1c12e6db0c7b09ac5eb39bd6dec8813532f Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 26 Aug 2019 09:33:10 -0700 Subject: [PATCH 4/4] Adding package.json fallback for unit tests --- superset/config.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/superset/config.py b/superset/config.py index 2f3ef43f330..b242e46dc16 100644 --- a/superset/config.py +++ b/superset/config.py @@ -49,8 +49,21 @@ # --------------------------------------------------------- PACKAGE_DIR = os.path.join(BASE_DIR, "static", "assets") VERSION_INFO_FILE = os.path.join(PACKAGE_DIR, "version_info.json") -with open(VERSION_INFO_FILE) as version_info_file: - VERSION_STRING = json.load(version_info_file)["version"] +PACKAGE_JSON_FILE = os.path.join(PACKAGE_DIR, "package.json") + +# +# Depending on the context in which this config is loaded, the version_info.json file +# may or may not be available, as it is generated on install via setup.py. In the event +# that we're actually running Superset, we will have already installed, therefore it WILL +# exist. When unit tests are running, however, it WILL NOT exist, so we fall +# back to reading package.json +# +try: + with open(VERSION_INFO_FILE) as version_file: + VERSION_STRING = json.load(version_file)["version"] +except Exception: + with open(PACKAGE_JSON_FILE) as version_file: + VERSION_STRING = json.load(version_file)["version"] ROW_LIMIT = 50000 VIZ_ROW_LIMIT = 10000