michael-s-molina commented on code in PR #24436:
URL: https://github.com/apache/superset/pull/24436#discussion_r1273615681


##########
setup.py:
##########
@@ -16,15 +16,37 @@
 # under the License.
 import json
 import os
+import re
 import subprocess
+import sys
 
 from setuptools import find_packages, setup
 
 BASE_DIR = os.path.abspath(os.path.dirname(__file__))
 PACKAGE_JSON = os.path.join(BASE_DIR, "superset-frontend", "package.json")
 
-with open(PACKAGE_JSON) as package_file:
-    version_string = json.load(package_file)["version"]
+parameters = {}
+
+# Regex pattern to match arguments in the form --param=value
+pattern = re.compile(r"^--(\w+)=(.+)$")
+
+# Check for custom parameters in sys.argv
+for arg in sys.argv:
+    match = pattern.match(arg)
+    if match:
+        key = match.group(1)
+        value = match.group(2)
+        parameters[key] = value
+
+# Access the passed parameters and their values
+version_string = parameters.get("version")
+
+# Remove custom parameters from sys.argv to allow other commands to be 
processed
+sys.argv = [arg for arg in sys.argv if not pattern.match(arg)]

Review Comment:
   ```suggestion
   pattern = re.compile(r"^--(\w+)=(.+)$")
   
   non_custom_parameters = []
   
   # Check for custom parameters in sys.argv
   for arg in sys.argv:
       match = pattern.match(arg)
       if match:
           key = match.group(1)
           value = match.group(2)
           parameters[key] = value
       else:
           non_custom_parameters.append(arg)
   
   # Access the passed parameters and their values
   version_string = parameters.get("version")
   
   sys.argv = non_custom_parameters
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to