@vercel/python-analysis 0.3.0 → 0.3.2

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.
@@ -1,185 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var python_selector_exports = {};
20
- __export(python_selector_exports, {
21
- buildMatchesConstraint: () => buildMatchesConstraint,
22
- buildMatchesRequest: () => buildMatchesRequest,
23
- implementationsMatch: () => implementationsMatch,
24
- pep440ConstraintsToString: () => pep440ConstraintsToString,
25
- pythonVersionToString: () => pythonVersionToString,
26
- selectPython: () => selectPython,
27
- variantsMatch: () => variantsMatch
28
- });
29
- module.exports = __toCommonJS(python_selector_exports);
30
- var import_pep440 = require("./pep440");
31
- var import_python_specifiers = require("./python-specifiers");
32
- function selectPython(constraints, available) {
33
- const warnings = [];
34
- const errors = [];
35
- if (constraints.length === 0) {
36
- return {
37
- build: available.length > 0 ? available[0] : null,
38
- errors: available.length === 0 ? ["No Python builds available"] : void 0
39
- };
40
- }
41
- const constraintMatches = /* @__PURE__ */ new Map();
42
- for (let i = 0; i < constraints.length; i++) {
43
- constraintMatches.set(i, []);
44
- }
45
- for (const build of available) {
46
- let matchesAll = true;
47
- for (let i = 0; i < constraints.length; i++) {
48
- const constraint = constraints[i];
49
- if (buildMatchesConstraint(build, constraint)) {
50
- constraintMatches.get(i)?.push(build);
51
- } else {
52
- matchesAll = false;
53
- }
54
- }
55
- if (matchesAll) {
56
- return {
57
- build,
58
- warnings: warnings.length > 0 ? warnings : void 0
59
- };
60
- }
61
- }
62
- if (constraints.length > 1) {
63
- const constraintsWithMatches = [];
64
- for (let i = 0; i < constraints.length; i++) {
65
- const matches = constraintMatches.get(i) ?? [];
66
- if (matches.length > 0) {
67
- constraintsWithMatches.push(i);
68
- }
69
- }
70
- if (constraintsWithMatches.length > 1) {
71
- const sources = constraintsWithMatches.map((i) => constraints[i].source);
72
- warnings.push(
73
- `Python version constraints may not overlap: ${sources.join(", ")}`
74
- );
75
- }
76
- }
77
- const constraintDescriptions = constraints.map((c) => c.source).join(", ");
78
- errors.push(
79
- `No Python build satisfies all constraints: ${constraintDescriptions}`
80
- );
81
- return {
82
- build: null,
83
- errors,
84
- warnings: warnings.length > 0 ? warnings : void 0
85
- };
86
- }
87
- function pythonVersionToString(version) {
88
- let str = `${version.major}.${version.minor}`;
89
- if (version.patch !== void 0) {
90
- str += `.${version.patch}`;
91
- }
92
- if (version.prerelease) {
93
- str += version.prerelease;
94
- }
95
- return str;
96
- }
97
- function pep440ConstraintsToString(constraints) {
98
- return constraints.map((c) => `${c.operator}${c.prefix}${c.version}`).join(",");
99
- }
100
- function implementationsMatch(buildImpl, requestImpl) {
101
- if (import_python_specifiers.PythonImplementation.isUnknown(buildImpl)) {
102
- if (import_python_specifiers.PythonImplementation.isUnknown(requestImpl)) {
103
- return buildImpl.implementation === requestImpl.implementation;
104
- }
105
- return false;
106
- }
107
- if (import_python_specifiers.PythonImplementation.isUnknown(requestImpl)) {
108
- return false;
109
- }
110
- return buildImpl === requestImpl;
111
- }
112
- function variantsMatch(buildVariant, requestVariant) {
113
- if (typeof buildVariant === "object" && "type" in buildVariant) {
114
- if (typeof requestVariant === "object" && "type" in requestVariant) {
115
- return buildVariant.variant === requestVariant.variant;
116
- }
117
- return false;
118
- }
119
- if (typeof requestVariant === "object" && "type" in requestVariant) {
120
- return false;
121
- }
122
- return buildVariant === requestVariant;
123
- }
124
- function buildMatchesRequest(build, request) {
125
- if (request.implementation !== void 0) {
126
- if (!implementationsMatch(build.implementation, request.implementation)) {
127
- return false;
128
- }
129
- }
130
- if (request.version !== void 0) {
131
- const versionConstraints = request.version.constraint;
132
- if (versionConstraints.length > 0) {
133
- const buildVersionStr = pythonVersionToString(build.version);
134
- const specifier = pep440ConstraintsToString(versionConstraints);
135
- if (!(0, import_pep440.pep440Satisfies)(buildVersionStr, specifier)) {
136
- return false;
137
- }
138
- }
139
- if (request.version.variant !== void 0) {
140
- if (!variantsMatch(build.variant, request.version.variant)) {
141
- return false;
142
- }
143
- }
144
- }
145
- if (request.platform !== void 0) {
146
- const platform = request.platform;
147
- if (platform.os !== void 0) {
148
- if (build.os.toLowerCase() !== platform.os.toLowerCase()) {
149
- return false;
150
- }
151
- }
152
- if (platform.arch !== void 0) {
153
- if (build.architecture.toLowerCase() !== platform.arch.toLowerCase()) {
154
- return false;
155
- }
156
- }
157
- if (platform.libc !== void 0) {
158
- if (build.libc.toLowerCase() !== platform.libc.toLowerCase()) {
159
- return false;
160
- }
161
- }
162
- }
163
- return true;
164
- }
165
- function buildMatchesConstraint(build, constraint) {
166
- if (constraint.request.length === 0) {
167
- return true;
168
- }
169
- for (const request of constraint.request) {
170
- if (buildMatchesRequest(build, request)) {
171
- return true;
172
- }
173
- }
174
- return false;
175
- }
176
- // Annotate the CommonJS export names for ESM import in node:
177
- 0 && (module.exports = {
178
- buildMatchesConstraint,
179
- buildMatchesRequest,
180
- implementationsMatch,
181
- pep440ConstraintsToString,
182
- pythonVersionToString,
183
- selectPython,
184
- variantsMatch
185
- });
@@ -1,156 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var python_specifiers_exports = {};
20
- __export(python_specifiers_exports, {
21
- PythonBuild: () => PythonBuild,
22
- PythonImplementation: () => PythonImplementation,
23
- PythonVariant: () => PythonVariant,
24
- PythonVersion: () => PythonVersion
25
- });
26
- module.exports = __toCommonJS(python_specifiers_exports);
27
- const PythonImplementation = {
28
- knownLongNames() {
29
- return {
30
- python: "cpython",
31
- cpython: "cpython",
32
- pypy: "pypy",
33
- pyodide: "pyodide",
34
- graalpy: "graalpy"
35
- };
36
- },
37
- knownShortNames() {
38
- return { cp: "cpython", pp: "pypy", gp: "graalpy" };
39
- },
40
- knownNames() {
41
- return { ...this.knownLongNames(), ...this.knownShortNames() };
42
- },
43
- parse(s) {
44
- const impl = this.knownNames()[s];
45
- if (impl !== void 0) {
46
- return impl;
47
- } else {
48
- return { implementation: s };
49
- }
50
- },
51
- isUnknown(impl) {
52
- return impl.implementation !== void 0;
53
- },
54
- toString(impl) {
55
- switch (impl) {
56
- case "cpython":
57
- return "cpython";
58
- case "pypy":
59
- return "pypy";
60
- case "pyodide":
61
- return "pyodide";
62
- case "graalpy":
63
- return "graalpy";
64
- default:
65
- return impl.implementation;
66
- }
67
- },
68
- toStringPretty(impl) {
69
- switch (impl) {
70
- case "cpython":
71
- return "CPython";
72
- case "pypy":
73
- return "PyPy";
74
- case "pyodide":
75
- return "PyOdide";
76
- case "graalpy":
77
- return "GraalPy";
78
- default:
79
- return impl.implementation;
80
- }
81
- }
82
- };
83
- const PythonVariant = {
84
- parse(s) {
85
- switch (s) {
86
- case "default":
87
- return "default";
88
- case "d":
89
- case "debug":
90
- return "debug";
91
- case "freethreaded":
92
- return "freethreaded";
93
- case "t":
94
- return "freethreaded";
95
- case "gil":
96
- return "gil";
97
- case "freethreaded+debug":
98
- return "freethreaded+debug";
99
- case "td":
100
- return "freethreaded+debug";
101
- case "gil+debug":
102
- return "gil+debug";
103
- default:
104
- return { type: "unknown", variant: s };
105
- }
106
- },
107
- toString(v) {
108
- switch (v) {
109
- case "default":
110
- return "default";
111
- case "debug":
112
- return "debug";
113
- case "freethreaded":
114
- return "freethreaded";
115
- case "gil":
116
- return "gil";
117
- case "freethreaded+debug":
118
- return "freethreaded+debug";
119
- case "gil+debug":
120
- return "gil+debug";
121
- default:
122
- return v.variant;
123
- }
124
- }
125
- };
126
- const PythonVersion = {
127
- toString(version) {
128
- let verstr = `${version.major}.${version.minor}`;
129
- if (version.patch !== void 0) {
130
- verstr = `${verstr}.${version.patch}`;
131
- }
132
- if (version.prerelease !== void 0) {
133
- verstr = `${verstr}${version.prerelease}`;
134
- }
135
- return verstr;
136
- }
137
- };
138
- const PythonBuild = {
139
- toString(build) {
140
- const parts = [
141
- PythonImplementation.toString(build.implementation),
142
- `${PythonVersion.toString(build.version)}+${PythonVariant.toString(build.variant)}`,
143
- build.os,
144
- build.architecture,
145
- build.libc
146
- ];
147
- return parts.join("-");
148
- }
149
- };
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
152
- PythonBuild,
153
- PythonImplementation,
154
- PythonVariant,
155
- PythonVersion
156
- });
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var schema_exports = {};
20
- __export(schema_exports, {
21
- DependencySourceSchema: () => DependencySourceSchema,
22
- HashDigestSchema: () => HashDigestSchema,
23
- NormalizedRequirementSchema: () => NormalizedRequirementSchema
24
- });
25
- module.exports = __toCommonJS(schema_exports);
26
- var import_schema = require("./schema.zod");
27
- const DependencySourceSchema = import_schema.dependencySourceSchema.passthrough();
28
- const NormalizedRequirementSchema = import_schema.normalizedRequirementSchema;
29
- const HashDigestSchema = import_schema.hashDigestSchema;
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- DependencySourceSchema,
33
- HashDigestSchema,
34
- NormalizedRequirementSchema
35
- });
@@ -1,49 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var schema_zod_exports = {};
20
- __export(schema_zod_exports, {
21
- dependencySourceSchema: () => dependencySourceSchema,
22
- hashDigestSchema: () => hashDigestSchema,
23
- normalizedRequirementSchema: () => normalizedRequirementSchema
24
- });
25
- module.exports = __toCommonJS(schema_zod_exports);
26
- var import_zod = require("zod");
27
- const dependencySourceSchema = import_zod.z.object({
28
- index: import_zod.z.string().optional(),
29
- git: import_zod.z.string().optional(),
30
- rev: import_zod.z.string().optional(),
31
- path: import_zod.z.string().optional(),
32
- editable: import_zod.z.boolean().optional()
33
- });
34
- const normalizedRequirementSchema = import_zod.z.object({
35
- name: import_zod.z.string(),
36
- version: import_zod.z.string().optional(),
37
- extras: import_zod.z.array(import_zod.z.string()).optional(),
38
- markers: import_zod.z.string().optional(),
39
- url: import_zod.z.string().optional(),
40
- hashes: import_zod.z.array(import_zod.z.string()).optional(),
41
- source: dependencySourceSchema.optional()
42
- });
43
- const hashDigestSchema = import_zod.z.string();
44
- // Annotate the CommonJS export names for ESM import in node:
45
- 0 && (module.exports = {
46
- dependencySourceSchema,
47
- hashDigestSchema,
48
- normalizedRequirementSchema
49
- });
@@ -1,16 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);