This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 30483ce chore: fix version info (#8196)
30483ce is described below
commit 30483cee3151277f76f615bd9a5447794b8fb4c5
Author: Maxime Beauchemin <[email protected]>
AuthorDate: Tue Sep 10 22:25:58 2019 -0700
chore: fix version info (#8196)
* Fix version info
Ran into Cypress issues while getting too ambitious in #8157
this is a simplified more targeted version of it
* include package.json (but not under static/)
* use package.json as single source of truth for version info
* typo
---
MANIFEST.in | 2 ++
setup.py | 14 +++++++++-----
superset/config.py | 22 +++++++++++++---------
3 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/MANIFEST.in b/MANIFEST.in
index 082b101..49e90d3 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -21,6 +21,8 @@ include README.md
recursive-include superset/examples *
recursive-include superset/migrations *
+include superset/assets/package.json
+
# Whitelist anything that needs to be added to the static bundle
recursive-exclude superset/static *
recursive-include superset/static/assets/branding *
diff --git a/setup.py b/setup.py
index 229f8f8..222b9b8 100644
--- a/setup.py
+++ b/setup.py
@@ -26,12 +26,12 @@ if sys.version_info < (3, 6):
sys.exit("Sorry, Python < 3.6 is not supported")
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
-PACKAGE_DIR = os.path.join(BASE_DIR, "superset", "static", "assets")
-PACKAGE_FILE = os.path.join(PACKAGE_DIR, "package.json")
-with open(PACKAGE_FILE) as package_file:
+
+PACKAGE_JSON = os.path.join(BASE_DIR, "superset", "assets", "package.json")
+with open(PACKAGE_JSON, "r") as package_file:
version_string = json.load(package_file)["version"]
-with io.open("README.md", encoding="utf-8") as f:
+with io.open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
@@ -50,7 +50,11 @@ print("VERSION: " + version_string)
print("GIT SHA: " + GIT_SHA)
print("-==-" * 15)
-with open(os.path.join(PACKAGE_DIR, "version_info.json"), "w") as version_file:
+VERSION_INFO_FILE = os.path.join(
+ BASE_DIR, "superset", "static", "assets", "version_info.json"
+)
+
+with open(VERSION_INFO_FILE, "w") as version_file:
json.dump(version_info, version_file)
diff --git a/superset/config.py b/superset/config.py
index e4539f3..f92246f 100644
--- a/superset/config.py
+++ b/superset/config.py
@@ -50,21 +50,25 @@ else:
# ---------------------------------------------------------
PACKAGE_DIR = os.path.join(BASE_DIR, "static", "assets")
VERSION_INFO_FILE = os.path.join(PACKAGE_DIR, "version_info.json")
-PACKAGE_JSON_FILE = os.path.join(PACKAGE_DIR, "package.json")
+PACKAGE_JSON_FILE = os.path.join(BASE_DIR, "assets" "package.json")
+
+
+def _try_json_readfile(filepath):
+ try:
+ with open(filepath, "r") as f:
+ return json.load(f).get("version")
+ except Exception:
+ return None
+
-#
# 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"]
+VERSION_STRING = _try_json_readfile(VERSION_INFO_FILE) or _try_json_readfile(
+ PACKAGE_JSON_FILE
+)
ROW_LIMIT = 50000
VIZ_ROW_LIMIT = 10000