From 6a5479907d88dd2a276133ccd41b2759c2f92ae6 Mon Sep 17 00:00:00 2001 From: Cameron Yick Date: Sat, 16 Apr 2022 17:57:20 -0400 Subject: [PATCH] designate python runtime test --- Makefile | 3 ++- demo/requirements.txt | 2 ++ plugins/datasette_publish_vercel_functions.py | 6 +++--- vercel.json | 10 ++-------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 028c588..e2b7da8 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,5 @@ publish-vercel: install datasette publish vercel demo/happy_planet_index.db \ --project=datasette-nteract-data-explorer \ --scope=datasette-visualization-plugin-demos \ - --token=${VERCEL_TOKEN} + --token=${VERCEL_TOKEN} \ + --vercel-json=vercel.json diff --git a/demo/requirements.txt b/demo/requirements.txt index 2a8aab0..19d284c 100644 --- a/demo/requirements.txt +++ b/demo/requirements.txt @@ -1,3 +1,5 @@ + +# This is supposed to be added by the publish step. pysqlite3-binary sqlite-utils>=3.2 datasette>=0.61 diff --git a/plugins/datasette_publish_vercel_functions.py b/plugins/datasette_publish_vercel_functions.py index 987bcce..4b9ddd7 100644 --- a/plugins/datasette_publish_vercel_functions.py +++ b/plugins/datasette_publish_vercel_functions.py @@ -214,8 +214,8 @@ def _publish_vercel( { "name": project, "version": 2, - "builds": [{"src": "index.py", "use": "@vercel/python"}], - "routes": [{"src": "(.*)", "dest": "index.py"}], + "functions": {"api/index.py": {}}, + "rewrites": [{"src": "/(.*)", "dest": "api/index.py"}], }, indent=4, ) @@ -257,7 +257,7 @@ def _publish_vercel( statics = [item[0] for item in static] - open("index.py", "w").write( + open("api/index.py", "w").write( INDEX_PY.format( database_files=json.dumps([os.path.split(f)[-1] for f in files]), extras=", {}".format(", ".join(extras)) if extras else "", diff --git a/vercel.json b/vercel.json index 5fc5865..6122543 100644 --- a/vercel.json +++ b/vercel.json @@ -1,14 +1,8 @@ { "name": "datasette-nteract-data-explorer", "version": 2, - "builds": [ - { - "src": "index.py", - "use": "@vercel/python" - } - ], "functions": { - "index.py" + "api/index.py": {} }, - "rewrites": [{ "src": "/(.*)", "dest": "index.py" }] + "rewrites": [{ "src": "/(.*)", "dest": "api/index.py" }] }