@vercel/python 6.54.1 → 6.55.1
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/dist/index.js +575 -376
- package/package.json +5 -5
- package/templates/vc_compileall.py +21 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/python",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.55.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"directory": "packages/python"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vercel/python-analysis": "0.
|
|
17
|
+
"@vercel/python-analysis": "0.13.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@renovatebot/pep440": "4.2.1",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"smol-toml": "1.5.2",
|
|
36
36
|
"vitest": "2.1.4",
|
|
37
37
|
"which": "3.0.0",
|
|
38
|
-
"@vercel/build-utils": "
|
|
39
|
-
"@vercel/
|
|
40
|
-
"@vercel/
|
|
38
|
+
"@vercel/build-utils": "14.0.1",
|
|
39
|
+
"@vercel/error-utils": "2.2.1",
|
|
40
|
+
"@vercel/python-runtime": "0.17.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "node ../../utils/build-builder.mjs",
|
|
@@ -2,21 +2,24 @@ import compileall
|
|
|
2
2
|
import json
|
|
3
3
|
import signal
|
|
4
4
|
import sys
|
|
5
|
+
import time
|
|
5
6
|
from multiprocessing import Pool
|
|
6
7
|
from py_compile import PycInvalidationMode
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def compile_source(source_file):
|
|
10
11
|
try:
|
|
11
|
-
|
|
12
|
+
start = time.perf_counter()
|
|
13
|
+
ok = compileall.compile_file(
|
|
12
14
|
source_file,
|
|
13
15
|
force=True,
|
|
14
16
|
quiet=1,
|
|
15
17
|
invalidation_mode=PycInvalidationMode.UNCHECKED_HASH,
|
|
16
18
|
)
|
|
19
|
+
return (source_file, ok, time.perf_counter() - start)
|
|
17
20
|
except Exception as error:
|
|
18
21
|
print(f"Failed to compile {source_file}: {error}", file=sys.stderr)
|
|
19
|
-
return False
|
|
22
|
+
return (source_file, False, 0.0)
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
def main():
|
|
@@ -26,6 +29,10 @@ def main():
|
|
|
26
29
|
if not source_files:
|
|
27
30
|
return 0
|
|
28
31
|
|
|
32
|
+
# Optional argv[2]: write per-file compile timings (seconds) as JSON,
|
|
33
|
+
# used by bytecode packing to rank files by compile cost per byte.
|
|
34
|
+
timings_path = sys.argv[2] if len(sys.argv) > 2 else None
|
|
35
|
+
|
|
29
36
|
try:
|
|
30
37
|
with Pool() as pool:
|
|
31
38
|
def abort_pool(signum, _):
|
|
@@ -35,11 +42,22 @@ def main():
|
|
|
35
42
|
for sig in signal.SIGINT, signal.SIGTERM:
|
|
36
43
|
signal.signal(sig, abort_pool)
|
|
37
44
|
|
|
38
|
-
pool.map(compile_source, source_files)
|
|
45
|
+
results = pool.map(compile_source, source_files)
|
|
39
46
|
except Exception as error:
|
|
40
47
|
print(f"Bytecode compilation unavailable: {error}", file=sys.stderr)
|
|
41
48
|
return 1
|
|
42
49
|
|
|
50
|
+
if timings_path:
|
|
51
|
+
try:
|
|
52
|
+
timings = {
|
|
53
|
+
path: elapsed for path, ok, elapsed in results if ok and elapsed > 0
|
|
54
|
+
}
|
|
55
|
+
with open(timings_path, "w", encoding="utf-8") as out:
|
|
56
|
+
json.dump(timings, out)
|
|
57
|
+
except Exception as error:
|
|
58
|
+
# Timings are advisory; never fail the compile over them.
|
|
59
|
+
print(f"Could not write compile timings: {error}", file=sys.stderr)
|
|
60
|
+
|
|
43
61
|
return 0
|
|
44
62
|
|
|
45
63
|
|