@bjia56/portable-python 0.1.0 → 0.1.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.
- package/README.md +51 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# portable-python
|
|
2
|
+
This project provides self-contained (hence, "portable") Python distributions to a variety of target platforms and architectures. These Python distributions can be downloaded and extracted to anywhere on the filesystem, making installation trivially easy and configurable.
|
|
3
|
+
|
|
4
|
+
## Usage
|
|
5
|
+
|
|
6
|
+
To get started, download archives from [GitHub releases](https://github.com/bjia56/portable-python/releases). Alternatively, use any of the following installers:
|
|
7
|
+
- `npm i @bjia56/portable-python-3.8`
|
|
8
|
+
- `npm i @bjia56/portable-python-3.9`
|
|
9
|
+
- `npm i @bjia56/portable-python-3.10`
|
|
10
|
+
|
|
11
|
+
For example, on Linux via bash:
|
|
12
|
+
```
|
|
13
|
+
$ wget -q https://github.com/bjia56/portable-python/releases/download/v3.9.17-build.4/python-3.9
|
|
14
|
+
.17-linux-x86_64.zip
|
|
15
|
+
$ unzip -qq python-3.9.17-linux-x86_64.zip
|
|
16
|
+
$ ./python-3.9.17-linux-x86_64/bin/python --version
|
|
17
|
+
Python 3.9.17
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or via the node installer:
|
|
21
|
+
```
|
|
22
|
+
$ npm i --silent @bjia56/portable-python-3.9
|
|
23
|
+
$ ./node_modules/@bjia56/portable-python-3.9/python-3.9.17-linux-x86_64/bin/python --version
|
|
24
|
+
Python 3.9.17
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or via node:
|
|
28
|
+
```js
|
|
29
|
+
var pythonExe = require("@bjia56/portable-python-3.9");
|
|
30
|
+
var child_process = require("child_process");
|
|
31
|
+
console.log(child_process.execSync(`${pythonExe} --version`).toString());
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Available distributions
|
|
35
|
+
|
|
36
|
+
Currently, Python 3.9, and 3.10 are built for the following targets:
|
|
37
|
+
- Linux x86_64, i386, aarch64, arm <sup id="a1">[1](#f1)</sup>, riscv64
|
|
38
|
+
- Windows x86_64
|
|
39
|
+
- MacOS x86_64, arm64 <sup id="a2">[2](#f2)</sup>
|
|
40
|
+
|
|
41
|
+
Python 3.8 builds are available, but will no longer be actively updated.
|
|
42
|
+
|
|
43
|
+
<sub><b id="f1">1</b> The arm builds target armv6, specifically the configuration of the Raspberry Pi 1. Current arm builds do not work properly on old glibc, but a recent version of Raspbian like Debian bullseye should provide a new enough glibc to work. [↩](#a1)</sub>
|
|
44
|
+
|
|
45
|
+
<sub><b id="f2">2</b> MacOS distributions are provided as universal2, which will work on both x86_64 and arm64. [↩](#a2)</sub>
|
|
46
|
+
|
|
47
|
+
Download stats: <a href="https://bjia56.github.io/portable-python/">📊</a>
|
|
48
|
+
|
|
49
|
+
## Licensing
|
|
50
|
+
|
|
51
|
+
The build scripts and code in this repository are available under the Apache-2.0 License. Note that compilation of Python involves linking against other libraries, some of which may include different licensing terms. Copies of the licenses from known dependencies are included under the `licenses` directory of each Python distribution.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare class PortablePython {
|
|
2
|
-
installDir: string;
|
|
3
2
|
_version: string;
|
|
4
|
-
|
|
3
|
+
installDir: string;
|
|
4
|
+
constructor(version: string, installDir?: string | null);
|
|
5
5
|
/**
|
|
6
6
|
* Contains the path to the Python executable.
|
|
7
7
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare class PortablePython {
|
|
2
|
-
installDir: string;
|
|
3
2
|
_version: string;
|
|
4
|
-
|
|
3
|
+
installDir: string;
|
|
4
|
+
constructor(version: string, installDir?: string | null);
|
|
5
5
|
/**
|
|
6
6
|
* Contains the path to the Python executable.
|
|
7
7
|
*/
|
package/dist/index.js
CHANGED
|
@@ -109,11 +109,14 @@ function download(url, dest) {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
var PortablePython = class {
|
|
112
|
-
constructor(version, installDir) {
|
|
113
|
-
this.installDir =
|
|
112
|
+
constructor(version, installDir = null) {
|
|
113
|
+
this.installDir = (0, import_path.basename)(__dirname);
|
|
114
114
|
if (!version) {
|
|
115
115
|
throw Error("version must not be empty");
|
|
116
116
|
}
|
|
117
|
+
if (installDir) {
|
|
118
|
+
this.installDir = installDir;
|
|
119
|
+
}
|
|
117
120
|
this._version = pickVersion(version);
|
|
118
121
|
if (!this.releaseTag) {
|
|
119
122
|
throw Error("no releases available for this version");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createWriteStream, existsSync, rm, rmSync, mkdirSync, chmodSync } from \"fs\";\nimport { join } from \"path\";\nimport { platform, arch } from \"os\";\nimport { Readable } from 'stream';\nimport { finished } from 'stream/promises';\nimport { ReadableStream } from 'stream/web';\nimport AdmZip from \"adm-zip\";\n\nconst DL_PLATFORM = (() => {\n if (platform() == \"win32\") {\n return \"windows\";\n }\n return platform();\n})();\n\nconst DL_ARCH = (() => {\n if (DL_PLATFORM == \"darwin\") {\n return \"universal2\";\n }\n\n switch (arch()) {\n case \"ia32\":\n return \"i386\";\n case \"x64\":\n return \"x86_64\";\n case \"arm64\":\n return \"aarch64\";\n }\n\n return arch();\n})();\n\nconst VERSIONS = [\n \"3.10.13\",\n \"3.9.18\",\n \"3.9.17\",\n \"3.8.18\",\n \"3.8.17\",\n];\n\nconst VERSION_BUILDS = new Map<string, string>([\n [\"3.10.13\", \"v3.10.13-build.3\"],\n [\"3.9.18\", \"v3.9.18-beta.4\"],\n [\"3.9.17\", \"v3.9.17-build.4\"],\n [\"3.8.18\", \"v3.8.18-build.0\"],\n [\"3.8.17\", \"v3.8.17-build.3\"],\n]);\n\nfunction pickVersion(version: string) {\n for (let i = 0; i < VERSIONS.length; ++i) {\n // TODO: This doesn't handle semver correctly, e.g. 3.8.17 will match 3.8.1\n if (VERSIONS[i].startsWith(version)) {\n return VERSIONS[i];\n }\n }\n return VERSIONS[0]\n}\n\n// https://stackoverflow.com/a/32134846\nasync function download(url: string, dest: string) {\n const res = await fetch(url);\n const file = createWriteStream(dest);\n await finished(Readable.fromWeb(res.body as ReadableStream).pipe(file));\n}\n\nexport class PortablePython {\n _version: string\n\n constructor(version: string,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createWriteStream, existsSync, rm, rmSync, mkdirSync, chmodSync } from \"fs\";\nimport { join, basename } from \"path\";\nimport { platform, arch } from \"os\";\nimport { Readable } from 'stream';\nimport { finished } from 'stream/promises';\nimport { ReadableStream } from 'stream/web';\nimport AdmZip from \"adm-zip\";\n\nconst DL_PLATFORM = (() => {\n if (platform() == \"win32\") {\n return \"windows\";\n }\n return platform();\n})();\n\nconst DL_ARCH = (() => {\n if (DL_PLATFORM == \"darwin\") {\n return \"universal2\";\n }\n\n switch (arch()) {\n case \"ia32\":\n return \"i386\";\n case \"x64\":\n return \"x86_64\";\n case \"arm64\":\n return \"aarch64\";\n }\n\n return arch();\n})();\n\nconst VERSIONS = [\n \"3.10.13\",\n \"3.9.18\",\n \"3.9.17\",\n \"3.8.18\",\n \"3.8.17\",\n];\n\nconst VERSION_BUILDS = new Map<string, string>([\n [\"3.10.13\", \"v3.10.13-build.3\"],\n [\"3.9.18\", \"v3.9.18-beta.4\"],\n [\"3.9.17\", \"v3.9.17-build.4\"],\n [\"3.8.18\", \"v3.8.18-build.0\"],\n [\"3.8.17\", \"v3.8.17-build.3\"],\n]);\n\nfunction pickVersion(version: string) {\n for (let i = 0; i < VERSIONS.length; ++i) {\n // TODO: This doesn't handle semver correctly, e.g. 3.8.17 will match 3.8.1\n if (VERSIONS[i].startsWith(version)) {\n return VERSIONS[i];\n }\n }\n return VERSIONS[0]\n}\n\n// https://stackoverflow.com/a/32134846\nasync function download(url: string, dest: string) {\n const res = await fetch(url);\n const file = createWriteStream(dest);\n await finished(Readable.fromWeb(res.body as ReadableStream).pipe(file));\n}\n\nexport class PortablePython {\n _version: string\n installDir = basename(__dirname);\n\n constructor(version: string, installDir: string | null = null) {\n if (!version) {\n throw Error(\"version must not be empty\");\n }\n\n if (installDir) {\n this.installDir = installDir;\n }\n\n this._version = pickVersion(version);\n if (!this.releaseTag) {\n throw Error(\"no releases available for this version\");\n }\n }\n\n /**\n * Contains the path to the Python executable.\n */\n get executablePath() {\n return join(this.installDir, this.pythonDistributionName, \"bin\", \"python\" + (platform() === \"win32\" ? \".exe\" : \"\"));\n }\n\n /**\n * Contains the selected Python version.\n */\n get version() {\n return this._version;\n }\n\n /**\n * Contains the release tag that will be downloaded.\n */\n get releaseTag() {\n return VERSION_BUILDS.get(this.version) as string;\n }\n\n /**\n * Contains the full name of the Python distribution.\n */\n get pythonDistributionName() {\n return `python-${this.version}-${DL_PLATFORM}-${DL_ARCH}`;\n }\n\n /**\n * Contains the path to the extracted Python distribution folder.\n */\n get extractPath() {\n return join(this.installDir, this.pythonDistributionName);\n }\n\n /**\n * Checks if the selected Python version has been installed on the host platform.\n * @returns True if the installation exists, false otherwise.\n */\n isInstalled() {\n return existsSync(this.extractPath);\n }\n\n /**\n * Will download the compressed Python installation and extract it to\n * the installation directory.\n */\n async install() {\n if (this.isInstalled()) {\n return;\n }\n\n const url = `https://github.com/bjia56/portable-python/releases/download/${this.releaseTag}/${this.pythonDistributionName}.zip`\n const downloadPath = join(this.installDir, `${this.pythonDistributionName}.zip`);\n\n mkdirSync(this.installDir, { recursive: true });\n\n const installDir = this.installDir;\n await download(url, downloadPath);\n\n const zip = new AdmZip(downloadPath);\n zip.extractAllTo(installDir, true)\n\n rmSync(downloadPath);\n if (!this.isInstalled()) {\n throw Error(\"something went wrong and the installation failed\");\n }\n\n chmodSync(this.executablePath, 0o777);\n }\n\n /**\n * Uninstalls the Python distribution.\n */\n async uninstall() {\n if (!this.isInstalled()) {\n return;\n }\n await new Promise<void>((resolve, reject) => rm(this.extractPath, { force: true, recursive: true }, (e) => {\n if (e) {\n reject(e);\n } else {\n resolve();\n }\n }));\n }\n\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAgF;AAChF,kBAA+B;AAC/B,gBAA+B;AAC/B,oBAAyB;AACzB,sBAAyB;AAEzB,qBAAmB;AAEnB,IAAM,eAAe,MAAM;AACvB,UAAI,oBAAS,KAAK,SAAS;AACvB,WAAO;AAAA,EACX;AACA,aAAO,oBAAS;AACpB,GAAG;AAEH,IAAM,WAAW,MAAM;AACnB,MAAI,eAAe,UAAU;AACzB,WAAO;AAAA,EACX;AAEA,cAAQ,gBAAK,GAAG;AAAA,IAChB,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,IACX,KAAK;AACD,aAAO;AAAA,EACX;AAEA,aAAO,gBAAK;AAChB,GAAG;AAEH,IAAM,WAAW;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAEA,IAAM,iBAAiB,oBAAI,IAAoB;AAAA,EAC3C,CAAC,WAAW,kBAAkB;AAAA,EAC9B,CAAC,UAAU,gBAAgB;AAAA,EAC3B,CAAC,UAAU,iBAAiB;AAAA,EAC5B,CAAC,UAAU,iBAAiB;AAAA,EAC5B,CAAC,UAAU,iBAAiB;AAChC,CAAC;AAED,SAAS,YAAY,SAAiB;AAClC,WAAS,IAAI,GAAG,IAAI,SAAS,QAAQ,EAAE,GAAG;AAEtC,QAAI,SAAS,CAAC,EAAE,WAAW,OAAO,GAAG;AACjC,aAAO,SAAS,CAAC;AAAA,IACrB;AAAA,EACJ;AACA,SAAO,SAAS,CAAC;AACrB;AA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AA+D,KAAK,UAAU,IAAI,KAAK,sBAAsB;AACzH,YAAM,mBAAe,kBAAK,KAAK,YAAY,GAAG,KAAK,sBAAsB,MAAM;AAE/E,+BAAU,KAAK,YAAY,EAAE,WAAW,KAAK,CAAC;AAE9C,YAAM,aAAa,KAAK;AACxB,YAAM,SAAS,KAAK,YAAY;AAEhC,YAAM,MAAM,IAAI,eAAAA,QAAO,YAAY;AACnC,UAAI,aAAa,YAAY,IAAI;AAEjC,4BAAO,YAAY;AACnB,UAAI,CAAC,KAAK,YAAY,GAAG;AACrB,cAAM,MAAM,kDAAkD;AAAA,MAClE;AAEA,+BAAU,KAAK,gBAAgB,GAAK;AAAA,IACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKM,YAAY;AAAA;AACd,UAAI,CAAC,KAAK,YAAY,GAAG;AACrB;AAAA,MACJ;AACA,YAAM,IAAI,QAAc,CAAC,SAAS,eAAW,cAAG,KAAK,aAAa,EAAE,OAAO,MAAM,WAAW,KAAK,GAAG,CAAC,MAAM;AACvG,YAAI,GAAG;AACH,iBAAO,CAAC;AAAA,QACZ,OAAO;AACH,kBAAQ;AAAA,QACZ;AAAA,MACJ,CAAC,CAAC;AAAA,IACN;AAAA;AAEJ;","names":["AdmZip"]}
|
package/dist/index.mjs
CHANGED
|
@@ -21,7 +21,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
23
|
import { createWriteStream, existsSync, rm, rmSync, mkdirSync, chmodSync } from "fs";
|
|
24
|
-
import { join } from "path";
|
|
24
|
+
import { join, basename } from "path";
|
|
25
25
|
import { platform, arch } from "os";
|
|
26
26
|
import { Readable } from "stream";
|
|
27
27
|
import { finished } from "stream/promises";
|
|
@@ -76,11 +76,14 @@ function download(url, dest) {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
var PortablePython = class {
|
|
79
|
-
constructor(version, installDir) {
|
|
80
|
-
this.installDir =
|
|
79
|
+
constructor(version, installDir = null) {
|
|
80
|
+
this.installDir = basename(__dirname);
|
|
81
81
|
if (!version) {
|
|
82
82
|
throw Error("version must not be empty");
|
|
83
83
|
}
|
|
84
|
+
if (installDir) {
|
|
85
|
+
this.installDir = installDir;
|
|
86
|
+
}
|
|
84
87
|
this._version = pickVersion(version);
|
|
85
88
|
if (!this.releaseTag) {
|
|
86
89
|
throw Error("no releases available for this version");
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createWriteStream, existsSync, rm, rmSync, mkdirSync, chmodSync } from \"fs\";\nimport { join } from \"path\";\nimport { platform, arch } from \"os\";\nimport { Readable } from 'stream';\nimport { finished } from 'stream/promises';\nimport { ReadableStream } from 'stream/web';\nimport AdmZip from \"adm-zip\";\n\nconst DL_PLATFORM = (() => {\n if (platform() == \"win32\") {\n return \"windows\";\n }\n return platform();\n})();\n\nconst DL_ARCH = (() => {\n if (DL_PLATFORM == \"darwin\") {\n return \"universal2\";\n }\n\n switch (arch()) {\n case \"ia32\":\n return \"i386\";\n case \"x64\":\n return \"x86_64\";\n case \"arm64\":\n return \"aarch64\";\n }\n\n return arch();\n})();\n\nconst VERSIONS = [\n \"3.10.13\",\n \"3.9.18\",\n \"3.9.17\",\n \"3.8.18\",\n \"3.8.17\",\n];\n\nconst VERSION_BUILDS = new Map<string, string>([\n [\"3.10.13\", \"v3.10.13-build.3\"],\n [\"3.9.18\", \"v3.9.18-beta.4\"],\n [\"3.9.17\", \"v3.9.17-build.4\"],\n [\"3.8.18\", \"v3.8.18-build.0\"],\n [\"3.8.17\", \"v3.8.17-build.3\"],\n]);\n\nfunction pickVersion(version: string) {\n for (let i = 0; i < VERSIONS.length; ++i) {\n // TODO: This doesn't handle semver correctly, e.g. 3.8.17 will match 3.8.1\n if (VERSIONS[i].startsWith(version)) {\n return VERSIONS[i];\n }\n }\n return VERSIONS[0]\n}\n\n// https://stackoverflow.com/a/32134846\nasync function download(url: string, dest: string) {\n const res = await fetch(url);\n const file = createWriteStream(dest);\n await finished(Readable.fromWeb(res.body as ReadableStream).pipe(file));\n}\n\nexport class PortablePython {\n _version: string\n\n constructor(version: string,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createWriteStream, existsSync, rm, rmSync, mkdirSync, chmodSync } from \"fs\";\nimport { join, basename } from \"path\";\nimport { platform, arch } from \"os\";\nimport { Readable } from 'stream';\nimport { finished } from 'stream/promises';\nimport { ReadableStream } from 'stream/web';\nimport AdmZip from \"adm-zip\";\n\nconst DL_PLATFORM = (() => {\n if (platform() == \"win32\") {\n return \"windows\";\n }\n return platform();\n})();\n\nconst DL_ARCH = (() => {\n if (DL_PLATFORM == \"darwin\") {\n return \"universal2\";\n }\n\n switch (arch()) {\n case \"ia32\":\n return \"i386\";\n case \"x64\":\n return \"x86_64\";\n case \"arm64\":\n return \"aarch64\";\n }\n\n return arch();\n})();\n\nconst VERSIONS = [\n \"3.10.13\",\n \"3.9.18\",\n \"3.9.17\",\n \"3.8.18\",\n \"3.8.17\",\n];\n\nconst VERSION_BUILDS = new Map<string, string>([\n [\"3.10.13\", \"v3.10.13-build.3\"],\n [\"3.9.18\", \"v3.9.18-beta.4\"],\n [\"3.9.17\", \"v3.9.17-build.4\"],\n [\"3.8.18\", \"v3.8.18-build.0\"],\n [\"3.8.17\", \"v3.8.17-build.3\"],\n]);\n\nfunction pickVersion(version: string) {\n for (let i = 0; i < VERSIONS.length; ++i) {\n // TODO: This doesn't handle semver correctly, e.g. 3.8.17 will match 3.8.1\n if (VERSIONS[i].startsWith(version)) {\n return VERSIONS[i];\n }\n }\n return VERSIONS[0]\n}\n\n// https://stackoverflow.com/a/32134846\nasync function download(url: string, dest: string) {\n const res = await fetch(url);\n const file = createWriteStream(dest);\n await finished(Readable.fromWeb(res.body as ReadableStream).pipe(file));\n}\n\nexport class PortablePython {\n _version: string\n installDir = basename(__dirname);\n\n constructor(version: string, installDir: string | null = null) {\n if (!version) {\n throw Error(\"version must not be empty\");\n }\n\n if (installDir) {\n this.installDir = installDir;\n }\n\n this._version = pickVersion(version);\n if (!this.releaseTag) {\n throw Error(\"no releases available for this version\");\n }\n }\n\n /**\n * Contains the path to the Python executable.\n */\n get executablePath() {\n return join(this.installDir, this.pythonDistributionName, \"bin\", \"python\" + (platform() === \"win32\" ? \".exe\" : \"\"));\n }\n\n /**\n * Contains the selected Python version.\n */\n get version() {\n return this._version;\n }\n\n /**\n * Contains the release tag that will be downloaded.\n */\n get releaseTag() {\n return VERSION_BUILDS.get(this.version) as string;\n }\n\n /**\n * Contains the full name of the Python distribution.\n */\n get pythonDistributionName() {\n return `python-${this.version}-${DL_PLATFORM}-${DL_ARCH}`;\n }\n\n /**\n * Contains the path to the extracted Python distribution folder.\n */\n get extractPath() {\n return join(this.installDir, this.pythonDistributionName);\n }\n\n /**\n * Checks if the selected Python version has been installed on the host platform.\n * @returns True if the installation exists, false otherwise.\n */\n isInstalled() {\n return existsSync(this.extractPath);\n }\n\n /**\n * Will download the compressed Python installation and extract it to\n * the installation directory.\n */\n async install() {\n if (this.isInstalled()) {\n return;\n }\n\n const url = `https://github.com/bjia56/portable-python/releases/download/${this.releaseTag}/${this.pythonDistributionName}.zip`\n const downloadPath = join(this.installDir, `${this.pythonDistributionName}.zip`);\n\n mkdirSync(this.installDir, { recursive: true });\n\n const installDir = this.installDir;\n await download(url, downloadPath);\n\n const zip = new AdmZip(downloadPath);\n zip.extractAllTo(installDir, true)\n\n rmSync(downloadPath);\n if (!this.isInstalled()) {\n throw Error(\"something went wrong and the installation failed\");\n }\n\n chmodSync(this.executablePath, 0o777);\n }\n\n /**\n * Uninstalls the Python distribution.\n */\n async uninstall() {\n if (!this.isInstalled()) {\n return;\n }\n await new Promise<void>((resolve, reject) => rm(this.extractPath, { force: true, recursive: true }, (e) => {\n if (e) {\n reject(e);\n } else {\n resolve();\n }\n }));\n }\n\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAA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C,UAAI,aAAa,YAAY,IAAI;AAEjC,aAAO,YAAY;AACnB,UAAI,CAAC,KAAK,YAAY,GAAG;AACrB,cAAM,MAAM,kDAAkD;AAAA,MAClE;AAEA,gBAAU,KAAK,gBAAgB,GAAK;AAAA,IACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAKM,YAAY;AAAA;AACd,UAAI,CAAC,KAAK,YAAY,GAAG;AACrB;AAAA,MACJ;AACA,YAAM,IAAI,QAAc,CAAC,SAAS,WAAW,GAAG,KAAK,aAAa,EAAE,OAAO,MAAM,WAAW,KAAK,GAAG,CAAC,MAAM;AACvG,YAAI,GAAG;AACH,iBAAO,CAAC;AAAA,QACZ,OAAO;AACH,kBAAQ;AAAA,QACZ;AAAA,MACJ,CAAC,CAAC;AAAA,IACN;AAAA;AAEJ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bjia56/portable-python",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Portable Python",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "tsup",
|
|
12
|
+
"build": "cp ../../README.md . && tsup",
|
|
13
13
|
"prepublishOnly": "npm run build",
|
|
14
14
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
15
15
|
},
|