@vercel/python 6.16.1 → 6.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/python",
3
- "version": "6.16.1",
3
+ "version": "6.18.0",
4
4
  "main": "./dist/index.js",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
@@ -15,7 +15,7 @@
15
15
  "directory": "packages/python"
16
16
  },
17
17
  "dependencies": {
18
- "@vercel/python-analysis": "0.7.0"
18
+ "@vercel/python-analysis": "0.8.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@renovatebot/pep440": "4.2.1",
@@ -35,9 +35,9 @@
35
35
  "which": "3.0.0",
36
36
  "get-port": "5.1.1",
37
37
  "is-port-reachable": "3.1.0",
38
- "@vercel/python-runtime": "0.5.1",
39
- "@vercel/build-utils": "13.5.0",
40
- "@vercel/error-utils": "2.0.3"
38
+ "@vercel/python-runtime": "0.5.3",
39
+ "@vercel/error-utils": "2.0.3",
40
+ "@vercel/build-utils": "13.6.1"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "node ../../utils/build-builder.mjs",
package/vc_init_dev.py CHANGED
@@ -5,7 +5,7 @@ import sys
5
5
  import os
6
6
  import inspect
7
7
  from os import path as _p
8
- from importlib import import_module
8
+ from importlib import util as _importlib_util
9
9
  import mimetypes
10
10
 
11
11
 
@@ -72,8 +72,20 @@ def _strip_service_route_prefix(path_value):
72
72
 
73
73
 
74
74
  # ASGI/WSGI app detection
75
- USER_MODULE = "__VC_DEV_MODULE_PATH__"
76
- _mod = import_module(USER_MODULE)
75
+ _MODULE_NAME = "__VC_DEV_MODULE_NAME__"
76
+ _ENTRY_ABS = "__VC_DEV_ENTRY_ABS__"
77
+
78
+ # Import user module by file path, matching vc_init.py's approach.
79
+ # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
80
+ _spec = _importlib_util.spec_from_file_location(_MODULE_NAME, _ENTRY_ABS)
81
+ if _spec is None or _spec.loader is None:
82
+ raise RuntimeError(
83
+ f"Could not load module spec for '{_MODULE_NAME}' at {_ENTRY_ABS}"
84
+ )
85
+ _mod = _importlib_util.module_from_spec(_spec)
86
+ sys.modules[_MODULE_NAME] = _mod
87
+ _spec.loader.exec_module(_mod)
88
+
77
89
  _user_app_name = (
78
90
  "app"
79
91
  if hasattr(_mod, "app")
@@ -83,7 +95,7 @@ _user_app_name = (
83
95
  )
84
96
  if _user_app_name is None:
85
97
  raise RuntimeError(
86
- f"Missing 'app' or 'application' in module '{USER_MODULE}'. "
98
+ f"Missing 'app' or 'application' in module '{_MODULE_NAME}'. "
87
99
  f"Define `app = ...` or `application = ...` in your entrypoint."
88
100
  )
89
101
 
@@ -137,7 +149,7 @@ def _detect_app_type(app_obj):
137
149
 
138
150
  print(
139
151
  _color(
140
- f"Could not determine the application interface for '{USER_MODULE}:{_user_app_name}'\n"
152
+ f"Could not determine the application interface for '{_MODULE_NAME}:{_user_app_name}'\n"
141
153
  f"Expected either:\n"
142
154
  f" - An ASGI app: async callable(scope, receive, send)\n"
143
155
  f" - A WSGI app: callable(environ, start_response)",