forked from intel/AI-Playground
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide scripts, that simply setup a python env This env may be used for developers (on windows machines) Overall flow remains equal, but try to make things a little more obvious my adding named parameters of scripts.
- Loading branch information
1 parent
a482a71
commit 44490bd
Showing
16 changed files
with
282 additions
and
359 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Usage: node pack-offline.js <npm_package_res_dir> <platform> | ||
// | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const AdmZip = require('adm-zip'); | ||
const childProcess = require('child_process'); | ||
|
||
const argv = require('minimist')(process.argv.slice(2)); | ||
const envDirArg = argv.env_dir | ||
const platformArg = argv.platform | ||
|
||
if (!envDirArg || !platformArg) { | ||
console.error('Usage: node install-full-python-env.js --env_dir=$DIR ---platform=arc|ultra|ultra2\n'); | ||
process.exit(1); | ||
} | ||
|
||
const envDir = existingFileOrExit(path.resolve(envDirArg)); | ||
const platform = platformArg; | ||
|
||
function existingFileOrExit(filePath) { | ||
if (!fs.existsSync(filePath)) { | ||
console.error('Resource not found:', filePath); | ||
process.exit(1); | ||
} | ||
return filePath | ||
} | ||
|
||
|
||
function installPip(pythonExe, getPipFilePath) { | ||
const runGetPip = childProcess.spawnSync(pythonExe, [getPipFilePath]); | ||
console.log(runGetPip.stdout.toString()); | ||
//console.error(runGetPip.stderr.toString()); | ||
if (runGetPip.status!== 0) { | ||
console.error('Failed to install requirements'); | ||
process.exit(1); | ||
} | ||
console.log('Successfully installed pip'); | ||
} | ||
|
||
function runPipInstall(pythonExe, requirementsFilePath) { | ||
console.log(`installing python dependencies from ${requirementsFilePath}`); | ||
const pipInstall = childProcess.spawnSync(pythonExe, ['-m', 'pip', 'install', '-r', requirementsFilePath]); | ||
console.log(pipInstall.stdout.toString()); | ||
console.error(pipInstall.stderr.toString()); | ||
if (pipInstall.status!== 0) { | ||
console.error('Failed to install requirements'); | ||
process.exit(1); | ||
} | ||
console.log(`Installed dependencies from ${requirementsFilePath} successfully`); | ||
} | ||
|
||
function copyToTargetDir(sourceDir, targetDir) { | ||
fs.cpSync(sourceDir, targetDir, { recursive: true }); | ||
console.log(`copied resources to ${targetDir}`) | ||
} | ||
|
||
|
||
function main() { | ||
const targetDir = path.join(envDir, '..', `env-full-${platform}`); | ||
copyToTargetDir(envDir, targetDir) | ||
|
||
const pythonExe = existingFileOrExit(path.join(targetDir, 'python.exe')); | ||
const getPipFile = existingFileOrExit(path.join(targetDir, 'get-pip.py')); | ||
|
||
const platformSpecificRequirementsTxt = existingFileOrExit(path.join(__dirname, '..', '..','..', 'service', `requirements-${platform}.txt`)); | ||
const requirementsTxt = existingFileOrExit(path.join(__dirname, '..', '..', '..', 'service', `requirements.txt`)); | ||
|
||
installPip(pythonExe, getPipFile) | ||
runPipInstall(pythonExe, platformSpecificRequirementsTxt) | ||
runPipInstall(pythonExe, requirementsTxt) | ||
} | ||
|
||
main(); |
Oops, something went wrong.