@geode/opengeodeweb-microservice 1.0.16 → 1.1.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/generate_pyinstaller.js +88 -0
- package/package.json +25 -24
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { execSync } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const projectPath = process.argv[2];
|
|
8
|
+
console.log("projectPath", projectPath);
|
|
9
|
+
|
|
10
|
+
function pythonCommand() {
|
|
11
|
+
const candidates = ["python3", "python"];
|
|
12
|
+
for (const cmd of candidates) {
|
|
13
|
+
try {
|
|
14
|
+
execSync(`${cmd} --version`, { stdio: "ignore" });
|
|
15
|
+
return cmd;
|
|
16
|
+
} catch {
|
|
17
|
+
// silent fail
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Python not found");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function createVenv() {
|
|
24
|
+
console.log("🔧 Setting up Python virtual environment...");
|
|
25
|
+
const python = pythonCommand();
|
|
26
|
+
console.log(`→ Using Python: ${python}`);
|
|
27
|
+
const venvPath = path.join(projectPath, "venv");
|
|
28
|
+
if (fs.existsSync(venvPath)) {
|
|
29
|
+
console.log(`→ Found existing venv → ${venvPath}`);
|
|
30
|
+
} else {
|
|
31
|
+
console.log(`→ Creating virtual environment → ${venvPath}`);
|
|
32
|
+
try {
|
|
33
|
+
execSync(`${python} -m venv ${venvPath}`, { stdio: "inherit" });
|
|
34
|
+
} catch (err) {
|
|
35
|
+
console.error("Failed to create virtual environment");
|
|
36
|
+
console.error(err.message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (process.platform === "win32") {
|
|
41
|
+
return path.join(venvPath, "Scripts", "python.exe");
|
|
42
|
+
} else {
|
|
43
|
+
return path.join(venvPath, "bin", "python");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function installDependecies(pythonExe) {
|
|
48
|
+
console.log(`→ Installing dependencies ...`);
|
|
49
|
+
const pipCommand = `pip install ${projectPath} pyinstaller`;
|
|
50
|
+
try {
|
|
51
|
+
console.log(`→ Running: ${pythonExe} -m ${pipCommand}`);
|
|
52
|
+
execSync(`${pythonExe} -m ${pipCommand}`, { stdio: "inherit" });
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error("Failed to install requirements");
|
|
55
|
+
console.error(err.message);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
console.log("✅ Python virtual environment setup complete");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function runPyInstaller(pythonExe) {
|
|
62
|
+
console.log(`→ Running PyInstaller ...`);
|
|
63
|
+
const specFiles = fs.readdirSync(projectPath, { withFileTypes: true })
|
|
64
|
+
.filter(file => file.isFile() && file.name.endsWith(".spec"))
|
|
65
|
+
.map(file => path.join(projectPath, file.name));
|
|
66
|
+
if (specFiles.length !== 1) {
|
|
67
|
+
console.error("Expected 1 spec file, found " + specFiles.length);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
const pyinstallerCommand = `PyInstaller ${specFiles[0]} --distpath ${process.cwd()} --clean`;
|
|
71
|
+
try {
|
|
72
|
+
console.log(`→ Running: ${pythonExe} -m ${pyinstallerCommand}`);
|
|
73
|
+
execSync(`${pythonExe} -m ${pyinstallerCommand}`, { stdio: "inherit" });
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error("Failed to run pyinstaller");
|
|
76
|
+
console.error(err.message);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
console.log("✅ PyInstaller complete");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function main() {
|
|
83
|
+
const pythonExe = createVenv();
|
|
84
|
+
installDependecies(pythonExe);
|
|
85
|
+
runPyInstaller(pythonExe);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
main();
|
package/package.json
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geode/opengeodeweb-microservice",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared utilities and schema generator for OpenGeodeWeb ecosystem",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"main": "generate_schemas.js",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"json": "echo \"Error: no test specified\" && exit 0",
|
|
11
|
-
"test": "echo \"Error: no test specified\" && exit 0",
|
|
12
|
-
"build": "echo \"Error: no test specified\" && exit 0"
|
|
13
|
-
},
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"glob": "^11.0.3",
|
|
16
|
-
"quicktype-core": "^23.2.6"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/Geode-solutions/OpenGeodeWeb-Microservice.git"
|
|
5
|
+
"homepage": "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice/issues"
|
|
21
8
|
},
|
|
9
|
+
"license": "MIT",
|
|
22
10
|
"author": {
|
|
23
11
|
"name": "Geode-solutions",
|
|
24
12
|
"email": "contact@geode-solutions.com",
|
|
25
13
|
"url": "https://geode-solutions.com/"
|
|
26
14
|
},
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"url": "https://github.com/Geode-solutions/OpenGeodeWeb-Microservice
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/Geode-solutions/OpenGeodeWeb-Microservice.git"
|
|
30
18
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
"
|
|
19
|
+
"bin": {
|
|
20
|
+
"opengeodeweb-microservice-generate": "./generate_schemas.js",
|
|
21
|
+
"opengeodeweb-microservice-pyinstaller": "./generate_pyinstaller.js"
|
|
34
22
|
},
|
|
35
23
|
"files": [
|
|
36
24
|
"generate_schemas.js"
|
|
37
25
|
],
|
|
38
|
-
"type": "module"
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "generate_schemas.js",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"json": "echo \"Error: no test specified\" && exit 0",
|
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
34
|
+
"build": "echo \"Error: no test specified\" && exit 0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"glob": "11.0.3",
|
|
38
|
+
"quicktype-core": "23.2.6"
|
|
39
|
+
}
|
|
39
40
|
}
|