-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into doc/#625-edit-description-of-LTTB-decimator
- Loading branch information
Showing
9 changed files
with
114 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
TAIPY_GUI_DIR=<path the taipy package dir parent> | ||
TAIPY_DIR=<path the taipy package dir parent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,73 @@ | ||
require("dotenv").config(); | ||
const { exec, execSync } = require("child_process"); | ||
const { existsSync, writeFileSync, appendFileSync } = require("fs"); | ||
const { sep } = require("path"); | ||
const { sep, resolve } = require("path"); | ||
|
||
const getGuiEnv = () => | ||
execSync(process.platform === "win32" ? 'pip show taipy-gui | findStr "Location:"' : "pip show taipy-gui | grep Location:", { | ||
stdio: ["pipe", "pipe", "pipe"], | ||
}) | ||
.toString() | ||
.trim() | ||
.substring(9) | ||
.trim(); | ||
const getGuiEnv = (log = true) => { | ||
try { | ||
const pipGuiDir = execSync( | ||
process.platform === "win32" | ||
? 'pip show taipy-gui | findStr "Location:"' | ||
: "pip show taipy-gui | grep Location:", | ||
{ | ||
stdio: ["pipe", "pipe", "pipe"], | ||
} | ||
) | ||
.toString() | ||
.trim(); | ||
return pipGuiDir.substring(9).trim(); | ||
} catch (e) { | ||
log && console.info("taipy-gui pip package is not installed."); | ||
const base = existsSync("package.json") ? `..${sep}..` : existsSync("frontend") ? "." : sep; | ||
if (existsSync(resolve(base, "taipy", "gui", "webapp", "package.json"))) { | ||
log && console.info(`Found npm package for taipy-gui in ${resolve(base, "taipy", "gui", "webapp")}`); | ||
return base; | ||
} else { | ||
log && console.warn(`taipy-gui npm package should be built locally in ${resolve(base, "taipy", "gui", "webapp")} first.`); | ||
} | ||
} | ||
return sep; | ||
}; | ||
|
||
let TAIPY_GUI_DIR = process.env.TAIPY_GUI_DIR; | ||
if (!TAIPY_GUI_DIR) { | ||
TAIPY_GUI_DIR = getGuiEnv(); | ||
if (existsSync(".env")) { | ||
appendFileSync(".env", `\nTAIPY_GUI_DIR=${TAIPY_GUI_DIR}`); | ||
} else { | ||
writeFileSync(".env", `TAIPY_GUI_DIR=${TAIPY_GUI_DIR}`); | ||
} | ||
let taipyEnvDir = process.env.TAIPY_DIR; | ||
if (!taipyEnvDir) { | ||
taipyEnvDir = getGuiEnv(); | ||
if (taipyEnvDir != sep) { | ||
if (existsSync(".env")) { | ||
appendFileSync(".env", `\nTAIPY_DIR=${taipyEnvDir}`); | ||
} else { | ||
writeFileSync(".env", `TAIPY_DIR=${taipyEnvDir}`); | ||
} | ||
} | ||
} | ||
|
||
const taipy_webapp_dir = `${TAIPY_GUI_DIR}${sep}taipy${sep}gui${sep}webapp`; | ||
if (!existsSync(taipy_webapp_dir)) { | ||
console.error(`Cannot find the Taipy GUI (${taipy_webapp_dir}) webapp directory.\nMake sure TAIPY_GUI_DIR is set properly as (${getGuiEnv()}).`); | ||
process.exit(1); | ||
const taipyWebappDir = `${taipyEnvDir}${sep}taipy${sep}gui${sep}webapp`; | ||
if (!existsSync(taipyWebappDir)) { | ||
console.error( | ||
`Cannot find the Taipy GUI (${taipyWebappDir}) webapp directory.\nMake sure TAIPY_DIR is set properly as (${getGuiEnv( | ||
false | ||
)}).` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const spinner = "|/-\\"; | ||
let i = 0; | ||
|
||
let spinnerTimer; | ||
|
||
exec(`npm i ${taipy_webapp_dir}`) | ||
.on("spawn", () => { | ||
spinnerTimer = setInterval(() => { | ||
process.stdout.write("Installing the Taipy GUI library... \r" + spinner[i++]); | ||
i = i % spinner.length; | ||
}, 150); | ||
}) | ||
.on("exit", (code, signal) => { | ||
clearInterval(spinnerTimer); | ||
if (code === 0) { | ||
console.log("\nInstallation finished"); | ||
} else { | ||
console.log(`\nInstallation failed (code ${code}, signal ${signal})`); | ||
} | ||
}); | ||
exec(`npm i ${taipyWebappDir}`) | ||
.on("spawn", () => { | ||
spinnerTimer = setInterval(() => { | ||
process.stdout.write("Installing the Taipy GUI library... \r" + spinner[i++]); | ||
i = i % spinner.length; | ||
}, 150); | ||
}) | ||
.on("exit", (code, signal) => { | ||
clearInterval(spinnerTimer); | ||
if (code === 0) { | ||
console.log("\nInstallation finished"); | ||
} else { | ||
console.log(`\nInstallation failed (code ${code}, signal ${signal})`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters