@bjia56/portable-python
Advanced tools
Comparing version 0.1.67 to 0.1.68
@@ -1,6 +0,5 @@ | ||
import { IInstaller, IPortablePython, IPortablePythonOptions } from './types'; | ||
import { IInstaller, IPortablePython } from './types'; | ||
export default class CPythonInstaller implements IInstaller { | ||
private parent; | ||
private options; | ||
constructor(parent: IPortablePython, options: IPortablePythonOptions); | ||
constructor(parent: IPortablePython); | ||
get relativeExecutablePath(): string; | ||
@@ -7,0 +6,0 @@ get relativePipPath(): string; |
@@ -33,13 +33,11 @@ "use strict"; | ||
parent; | ||
options; | ||
constructor(parent, options) { | ||
constructor(parent) { | ||
this.parent = parent; | ||
this.options = options; | ||
} | ||
get relativeExecutablePath() { | ||
return (0, path_1.join)(this.pythonDistributionName, "bin", "python" + (this.options.distribution === "cosmo" ? ".com" : | ||
return (0, path_1.join)(this.pythonDistributionName, "bin", "python" + (this.parent.distribution === "cosmo" ? ".com" : | ||
((0, os_1.platform)() === "win32" ? ".exe" : ""))); | ||
} | ||
get relativePipPath() { | ||
if (this.options.distribution != "cosmo" && (0, os_1.platform)() === "win32") { | ||
if (this.parent.distribution != "cosmo" && (0, os_1.platform)() === "win32") { | ||
return (0, path_1.join)(this.pythonDistributionName, "Scripts", `pip${this.parent.major}.exe`); | ||
@@ -57,6 +55,6 @@ } | ||
validateOptions() { | ||
if (this.options.implementation !== "cpython") { | ||
if (this.parent.implementation !== "cpython") { | ||
throw Error("expected cpython implementation"); | ||
} | ||
if (!["auto", "cosmo", "headless", "full"].includes(this.options.distribution)) { | ||
if (!["auto", "cosmo", "headless", "full"].includes(this.parent.distribution)) { | ||
throw Error("invalid distribution"); | ||
@@ -70,3 +68,3 @@ } | ||
await (0, promises_1.chmod)(this.parent.executablePath, 0o777); | ||
if (this.options.distribution != "cosmo" && (0, os_1.platform)() != "win32") { | ||
if (this.parent.distribution != "cosmo" && (0, os_1.platform)() != "win32") { | ||
// node can't create symlinks over existing files, so we create symlinks with temp names, | ||
@@ -73,0 +71,0 @@ // then rename to overwrite existing files |
@@ -1,8 +0,7 @@ | ||
import { IInstaller, IPortablePython, IPortablePythonOptions } from './types'; | ||
import { IInstaller, IPortablePython } from './types'; | ||
export default class GraalPyInstaller implements IInstaller { | ||
private parent; | ||
private options; | ||
private pythonMajor; | ||
private pythonMinor; | ||
constructor(parent: IPortablePython, options: IPortablePythonOptions); | ||
constructor(parent: IPortablePython); | ||
get relativeExecutablePath(): string; | ||
@@ -9,0 +8,0 @@ get relativePipPath(): string; |
@@ -23,8 +23,6 @@ "use strict"; | ||
parent; | ||
options; | ||
pythonMajor = 3; | ||
pythonMinor = 10; | ||
constructor(parent, options) { | ||
constructor(parent) { | ||
this.parent = parent; | ||
this.options = options; | ||
} | ||
@@ -41,9 +39,12 @@ get relativeExecutablePath() { | ||
get pythonDistributionName() { | ||
return `graalpy-community-jvm-${this.parent.version}-${DL_PLATFORM}-${DL_ARCH}`; | ||
if (this.parent.distribution === "auto" || this.parent.distribution === "standard") { | ||
return `graalpy-${this.parent.version}-${DL_PLATFORM}-${DL_ARCH}`; | ||
} | ||
return `graalpy-${this.parent.distribution}-${this.parent.version}-${DL_PLATFORM}-${DL_ARCH}`; | ||
} | ||
validateOptions() { | ||
if (this.options.implementation !== "graalpy") { | ||
if (this.parent.implementation !== "graalpy") { | ||
throw Error("expected graalpy implementation"); | ||
} | ||
if (this.options.distribution !== "auto") { | ||
if (!["auto", "standard", "community", "jvm", "community-jvm"].includes(this.parent.distribution)) { | ||
throw Error("invalid distribution"); | ||
@@ -50,0 +51,0 @@ } |
@@ -16,5 +16,7 @@ "use strict"; | ||
const graalpy_1 = __importDefault(require("./graalpy")); | ||
const pypy_1 = __importDefault(require("./pypy")); | ||
const INSTALLERS = new Map([ | ||
["cpython", cpython_1.default], | ||
["graalpy", graalpy_1.default], | ||
["pypy", pypy_1.default], | ||
]); | ||
@@ -46,6 +48,3 @@ async function download(url, dest) { | ||
const ctor = INSTALLERS.get(this.implementation); | ||
this._installer = new ctor(this, { | ||
implementation: this.implementation, | ||
distribution: this.distribution, | ||
}); | ||
this._installer = new ctor(this); | ||
this._installer.validateOptions(); | ||
@@ -52,0 +51,0 @@ if (installDir) { |
{ | ||
"name": "@bjia56/portable-python", | ||
"version": "0.1.67", | ||
"version": "0.1.68", | ||
"description": "Portable Python", | ||
@@ -42,2 +42,3 @@ "main": "./dist/index.js", | ||
"versions": [ | ||
"3.12.5", | ||
"3.12.4", | ||
@@ -68,3 +69,4 @@ "3.12.3", | ||
"3.12.3": "v3.12.3-build.3", | ||
"3.12.4": "cpython-v3.12.4-build.2" | ||
"3.12.4": "cpython-v3.12.4-build.2", | ||
"3.12.5": "v3.12.5-beta.0" | ||
} | ||
@@ -71,0 +73,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39433
20
543
5