fix: check for pip existence outside the try/catch loop

This commit is contained in:
Amin Yahyaabadi 2023-09-07 11:04:26 -07:00
parent 3fa4b5925a
commit af4a6f813e
7 changed files with 17 additions and 17 deletions

View File

@ -1244,7 +1244,7 @@ t.push((0,iP.join)(r,"Scripts"),(0,iP.join)(r,"Scripts","bin"),(0,iP.join)(r,"bi
function(e,t){let r=e[0],n=Object.keys(t).map(e=>parseInt(e,10)).sort((e,t)=>t-e)// sort in descending order
.find(e=>r>=e);return void 0===n?"":t[n];}(r,o6[e]):sd(t)&&e in o4?o4[e]:"true"===t?"":t??"";}function sd(e){return"true"===e||void 0===e;}var z=V("7Lz0k"),sp={};async function sf(){var e,t;if("linux"!==process.platform)return[];let r=await(e="lsb_release",t=["-a"],new Promise((r,n)=>{$.execFile(e,t,{encoding:"utf8",shell:!1},(i,o,s)=>{if(i){if("errno"in i&&"ENOENT"===i.code){r(null);// When lsb_release is not found
return;}n(Error(`Could not execute \`${e} ${t.join(" ")}\`: ${i} (stderr=${s})`));return;}r(o);});}));if(null===r)return[];let n=/^Distributor ID:\s*(.+)$/,i=/^Description:\s*Ubuntu\s+(\d+)\.(\d+)(?:\.(\d+))?/,o=/^Release:\s*(\d+)\.(\d+)(?:\.(\d+))?$/,s=null,a=null,l=!1;for(let e of r.split("\n")){let t=e.match(n);if(null!==t){let e=t[1];if("Ubuntu"!==e)return[];l=!0;}let r=e.match(i);r&&(s=r);let c=e.match(o);if(c&&(a=c),l&&s&&a)break;}if(!l)return[];for(let e of[s,a])if(e){let t=[e[1],e[2]];return e[3]&&t.push(e[3]),t.map(e=>parseInt(e,10));}return[];}async function sh(){try{if(!iq())return null;{try{null===/*@__PURE__*/G(nQ).sync("lsb_release",{nothrow:!0})&&(await ix([{name:"lsb-release"}]));}catch{return sg();}let e=await(0,sp.getUbuntuVersion)();if(0===e.length)return sg();return e;}}catch(e){return(0,z.warning)(e.toString()),null;}}Object.defineProperty(sp,"__esModule",{value:!0}),sp.getUbuntuVersion=void 0,sp.getUbuntuVersion=sf;const sm=oV(sh);/** Detect Ubuntu version using os.version() for Ubuntu based distros */function sg(){// #46~22.04.1-Ubuntu SMP ...
let e=G(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sv(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${r??""} via ${c}`);try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[],a=await sb(e,t);if(a)nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});else if((await s$(t))===null)throw Error(`Failed to install ${t}.`);}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}let u=await sc(e),d=await sS(u,t);return await nq(d),{binDir:d};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o5(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oV(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nF.pathExists)((0,iP.join)(e,(0,iP.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/G(nQ).sync((0,iP.addExeExt)(t),{nothrow:!0});return null!==i?(0,iP.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iF())return iK(`python-${e}`);if(iG())return iB([{name:`python3-${e}`}]);if(iq())return ix([{name:`python3-${e}`}]);}return null;}async function sO(e,t,r){switch(process.platform){case"win32":{await iM("cppcheck",e);let t=await s_();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iF())return iK("cppcheck",e);if(iG())return iB([{name:"ccache",version:e}]);if(iq())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function s_(){let e="C:/Program Files/Cppcheck";return await nq(e),e;}var iP=V("eq4yW"),z=V("7Lz0k");async function sC(e,t,r){switch(process.platform){case"win32":return await iM("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iF())return iK("graphviz",e);if(iG())return iB([{name:"graphviz",version:e}]);if(iq())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nq(e),{binDir:e};}throw Error("Unsupported platform");}var nF=V("bOuKS");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
let e=G(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sv(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${r??""} via ${c}`);let u=await sb(e,t);if(u)try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[];nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}else if((await s$(t))===null)throw Error(`Failed to install ${t} as it was not found via ${c} or the system package manager`);let d=await sc(e),p=await sS(d,t);return await nq(p),{binDir:p};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o5(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oV(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nF.pathExists)((0,iP.join)(e,(0,iP.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/G(nQ).sync((0,iP.addExeExt)(t),{nothrow:!0});return null!==i?(0,iP.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iF())return iK(`python-${e}`);if(iG())return iB([{name:`python3-${e}`}]);if(iq())return ix([{name:`python3-${e}`}]);}return null;}async function sO(e,t,r){switch(process.platform){case"win32":{await iM("cppcheck",e);let t=await s_();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iF())return iK("cppcheck",e);if(iG())return iB([{name:"ccache",version:e}]);if(iq())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function s_(){let e="C:/Program Files/Cppcheck";return await nq(e),e;}var iP=V("eq4yW"),z=V("7Lz0k");async function sC(e,t,r){switch(process.platform){case"win32":return await iM("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iF())return iK("graphviz",e);if(iG())return iB([{name:"graphviz",version:e}]);if(iq())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nq(e),{binDir:e};}throw Error("Unsupported platform");}var nF=V("bOuKS");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
function sT(e,t,r){switch(t){case"linux":{let t=`doxygen-${e}`;return{binRelativeDir:"bin/",binFileName:(0,iP.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:iJ.extractTar,url:`https://www.doxygen.nl/files/${t}.linux.bin.tar.gz`};}case"win32":{let t=`doxygen-${e}`;return{binRelativeDir:"",binFileName:(0,iP.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:ok,url:`https://www.doxygen.nl/files/${t}.windows.x64.bin.zip`};}default:throw Error(`Unsupported platform '${t}'`);}}async function sR(e,t,r){switch(process.platform){case"win32":{// try to download the package 4 times with 2 seconds delay
await/*@__PURE__*/G(o_)(()=>iM("doxygen.install",e),{name:"doxygen.install",max:4,backoffBase:2e3,report:e=>(0,z.info)(e)});let t=await sP();return await sC(su("graphviz",void 0),"",r),{binDir:t};}case"darwin":{let e=await iD("doxygen",void 0);return await sC(su("graphviz",void 0),"",r),e;}case"linux":{let n;if(""===e||iF()||iG()){if(iF())n=await iK("doxygen",e);else if(iG())return iB([{name:"doxygen",version:e}]);else if(iq())n=await ix([{name:"doxygen",version:e}]);else throw Error("Unsupported linux distributions");}else if(iq())try{// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
n=await oR("doxygen",e,sT,t,r),await ix([{name:"libclang-cpp9"}]);}catch(e){(0,z.notice)(`Failed to download doxygen binary. ${e}. Falling back to apt-get.`),n=await ix([{name:"doxygen"}]);}else throw Error("Unsupported linux distributions");return await sC(su("graphviz",void 0,await sm()),"",r),n;}default:throw Error("Unsupported platform");}}async function sP(){if("win32"===process.platform){for(let e of["C:/ProgramData/chocolatey/bin","C:/Program Files/doxygen/bin","C:/Program Files (x86)/doxygen"])if(await(0,nF.pathExists)((0,iP.join)(e,"doxygen.exe")))return(// eslint-disable-next-line no-await-in-loop

File diff suppressed because one or more lines are too long

View File

@ -1244,7 +1244,7 @@ t.push((0,iA.join)(r,"Scripts"),(0,iA.join)(r,"Scripts","bin"),(0,iA.join)(r,"bi
function(e,t){let r=e[0],n=Object.keys(t).map(e=>parseInt(e,10)).sort((e,t)=>t-e)// sort in descending order
.find(e=>r>=e);return void 0===n?"":t[n];}(r,o6[e]):sd(t)&&e in o4?o4[e]:"true"===t?"":null!=t?t:"";}function sd(e){return"true"===e||void 0===e;}var W=V("hHq4F"),sp={};async function sf(){var e,t;if("linux"!==process.platform)return[];let r=await(e="lsb_release",t=["-a"],new Promise((r,n)=>{$.execFile(e,t,{encoding:"utf8",shell:!1},(i,o,s)=>{if(i){if("errno"in i&&"ENOENT"===i.code){r(null);// When lsb_release is not found
return;}n(Error(`Could not execute \`${e} ${t.join(" ")}\`: ${i} (stderr=${s})`));return;}r(o);});}));if(null===r)return[];let n=/^Distributor ID:\s*(.+)$/,i=/^Description:\s*Ubuntu\s+(\d+)\.(\d+)(?:\.(\d+))?/,o=/^Release:\s*(\d+)\.(\d+)(?:\.(\d+))?$/,s=null,a=null,l=!1;for(let e of r.split("\n")){let t=e.match(n);if(null!==t){let e=t[1];if("Ubuntu"!==e)return[];l=!0;}let r=e.match(i);r&&(s=r);let c=e.match(o);if(c&&(a=c),l&&s&&a)break;}if(!l)return[];for(let e of[s,a])if(e){let t=[e[1],e[2]];return e[3]&&t.push(e[3]),t.map(e=>parseInt(e,10));}return[];}async function sh(){try{if(!iq())return null;{try{null===/*@__PURE__*/G(nJ).sync("lsb_release",{nothrow:!0})&&(await ix([{name:"lsb-release"}]));}catch{return sv();}let e=await(0,sp.getUbuntuVersion)();if(0===e.length)return sv();return e;}}catch(e){return(0,W.warning)(e.toString()),null;}}Object.defineProperty(sp,"__esModule",{value:!0}),sp.getUbuntuVersion=void 0,sp.getUbuntuVersion=sf;const sm=oV(sh);/** Detect Ubuntu version using os.version() for Ubuntu based distros */function sv(){// #46~22.04.1-Ubuntu SMP ...
let e=G(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sg(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${null!=r?r:""} via ${c}`);try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[],a=await sb(e,t);if(a)nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});else if((await s$(t))===null)throw Error(`Failed to install ${t}.`);}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}let u=await sc(e),d=await sS(u,t);return await nq(d),{binDir:d};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o8(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oV(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nM.pathExists)((0,iA.join)(e,(0,iA.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/G(nJ).sync((0,iA.addExeExt)(t),{nothrow:!0});return null!==i?(0,iA.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iM())return iX(`python-${e}`);if(iG())return iB([{name:`python3-${e}`}]);if(iq())return ix([{name:`python3-${e}`}]);}return null;}async function sO(e,t,r){switch(process.platform){case"win32":{await iF("cppcheck",e);let t=await s_();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iM())return iX("cppcheck",e);if(iG())return iB([{name:"ccache",version:e}]);if(iq())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function s_(){let e="C:/Program Files/Cppcheck";return await nq(e),e;}var iA=V("A8hFE"),W=V("hHq4F");async function sC(e,t,r){switch(process.platform){case"win32":return await iF("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iM())return iX("graphviz",e);if(iG())return iB([{name:"graphviz",version:e}]);if(iq())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nq(e),{binDir:e};}throw Error("Unsupported platform");}var nM=V("3WkGD");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
let e=G(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sg(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${null!=r?r:""} via ${c}`);let u=await sb(e,t);if(u)try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[];nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}else if((await s$(t))===null)throw Error(`Failed to install ${t} as it was not found via ${c} or the system package manager`);let d=await sc(e),p=await sS(d,t);return await nq(p),{binDir:p};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o8(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oV(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nM.pathExists)((0,iA.join)(e,(0,iA.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/G(nJ).sync((0,iA.addExeExt)(t),{nothrow:!0});return null!==i?(0,iA.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iM())return iX(`python-${e}`);if(iG())return iB([{name:`python3-${e}`}]);if(iq())return ix([{name:`python3-${e}`}]);}return null;}async function sO(e,t,r){switch(process.platform){case"win32":{await iF("cppcheck",e);let t=await s_();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iM())return iX("cppcheck",e);if(iG())return iB([{name:"ccache",version:e}]);if(iq())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function s_(){let e="C:/Program Files/Cppcheck";return await nq(e),e;}var iA=V("A8hFE"),W=V("hHq4F");async function sC(e,t,r){switch(process.platform){case"win32":return await iF("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iM())return iX("graphviz",e);if(iG())return iB([{name:"graphviz",version:e}]);if(iq())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nq(e),{binDir:e};}throw Error("Unsupported platform");}var nM=V("3WkGD");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
function sT(e,t,r){switch(t){case"linux":{let t=`doxygen-${e}`;return{binRelativeDir:"bin/",binFileName:(0,iA.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:iQ.extractTar,url:`https://www.doxygen.nl/files/${t}.linux.bin.tar.gz`};}case"win32":{let t=`doxygen-${e}`;return{binRelativeDir:"",binFileName:(0,iA.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:ok,url:`https://www.doxygen.nl/files/${t}.windows.x64.bin.zip`};}default:throw Error(`Unsupported platform '${t}'`);}}async function sR(e,t,r){switch(process.platform){case"win32":{// try to download the package 4 times with 2 seconds delay
await/*@__PURE__*/G(o_)(()=>iF("doxygen.install",e),{name:"doxygen.install",max:4,backoffBase:2e3,report:e=>(0,W.info)(e)});let t=await sA();return await sC(su("graphviz",void 0),"",r),{binDir:t};}case"darwin":{let e=await iD("doxygen",void 0);return await sC(su("graphviz",void 0),"",r),e;}case"linux":{let n;if(""===e||iM()||iG()){if(iM())n=await iX("doxygen",e);else if(iG())return iB([{name:"doxygen",version:e}]);else if(iq())n=await ix([{name:"doxygen",version:e}]);else throw Error("Unsupported linux distributions");}else if(iq())try{// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
n=await oR("doxygen",e,sT,t,r),await ix([{name:"libclang-cpp9"}]);}catch(e){(0,W.notice)(`Failed to download doxygen binary. ${e}. Falling back to apt-get.`),n=await ix([{name:"doxygen"}]);}else throw Error("Unsupported linux distributions");return await sC(su("graphviz",void 0,await sm()),"",r),n;}default:throw Error("Unsupported platform");}}async function sA(){if("win32"===process.platform){for(let e of["C:/ProgramData/chocolatey/bin","C:/Program Files/doxygen/bin","C:/Program Files (x86)/doxygen"])if(await(0,nM.pathExists)((0,iA.join)(e,"doxygen.exe")))return(// eslint-disable-next-line no-await-in-loop

File diff suppressed because one or more lines are too long

View File

@ -1244,7 +1244,7 @@ t.push((0,iP.join)(r,"Scripts"),(0,iP.join)(r,"Scripts","bin"),(0,iP.join)(r,"bi
function(e,t){let r=e[0],n=Object.keys(t).map(e=>parseInt(e,10)).sort((e,t)=>t-e)// sort in descending order
.find(e=>r>=e);return void 0===n?"":t[n];}(r,o6[e]):sd(t)&&e in o4?o4[e]:"true"===t?"":t??"";}function sd(e){return"true"===e||void 0===e;}var K=q("ER74K"),sp={};async function sf(){var e,t;if("linux"!==process.platform)return[];let r=await(e="lsb_release",t=["-a"],new Promise((r,n)=>{$.execFile(e,t,{encoding:"utf8",shell:!1},(i,o,s)=>{if(i){if("errno"in i&&"ENOENT"===i.code){r(null);// When lsb_release is not found
return;}n(Error(`Could not execute \`${e} ${t.join(" ")}\`: ${i} (stderr=${s})`));return;}r(o);});}));if(null===r)return[];let n=/^Distributor ID:\s*(.+)$/,i=/^Description:\s*Ubuntu\s+(\d+)\.(\d+)(?:\.(\d+))?/,o=/^Release:\s*(\d+)\.(\d+)(?:\.(\d+))?$/,s=null,a=null,l=!1;for(let e of r.split("\n")){let t=e.match(n);if(null!==t){let e=t[1];if("Ubuntu"!==e)return[];l=!0;}let r=e.match(i);r&&(s=r);let c=e.match(o);if(c&&(a=c),l&&s&&a)break;}if(!l)return[];for(let e of[s,a])if(e){let t=[e[1],e[2]];return e[3]&&t.push(e[3]),t.map(e=>parseInt(e,10));}return[];}async function sh(){try{if(!iV())return null;{try{null===/*@__PURE__*/B(nQ).sync("lsb_release",{nothrow:!0})&&(await ix([{name:"lsb-release"}]));}catch{return sg();}let e=await(0,sp.getUbuntuVersion)();if(0===e.length)return sg();return e;}}catch(e){return(0,K.warning)(e.toString()),null;}}Object.defineProperty(sp,"__esModule",{value:!0}),sp.getUbuntuVersion=void 0,sp.getUbuntuVersion=sf;const sm=oq(sh);/** Detect Ubuntu version using os.version() for Ubuntu based distros */function sg(){// #46~22.04.1-Ubuntu SMP ...
let e=B(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sv(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${r??""} via ${c}`);try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[],a=await sb(e,t);if(a)nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});else if((await s$(t))===null)throw Error(`Failed to install ${t}.`);}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}let u=await sc(e),d=await sS(u,t);return await nV(d),{binDir:d};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o5(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oq(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nF.pathExists)((0,iP.join)(e,(0,iP.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/B(nQ).sync((0,iP.addExeExt)(t),{nothrow:!0});return null!==i?(0,iP.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iF())return iz(`python-${e}`);if(iB())return iG([{name:`python3-${e}`}]);if(iV())return ix([{name:`python3-${e}`}]);}return null;}async function s_(e,t,r){switch(process.platform){case"win32":{await iM("cppcheck",e);let t=await sO();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iF())return iz("cppcheck",e);if(iB())return iG([{name:"ccache",version:e}]);if(iV())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sO(){let e="C:/Program Files/Cppcheck";return await nV(e),e;}var iP=q("ceI0e"),K=q("ER74K");async function sC(e,t,r){switch(process.platform){case"win32":return await iM("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iF())return iz("graphviz",e);if(iB())return iG([{name:"graphviz",version:e}]);if(iV())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nV(e),{binDir:e};}throw Error("Unsupported platform");}var nF=q("dOmbL");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
let e=B(f).version(),t=e.split("."),r=parseInt(t[0].replace("#",""),10),n=parseInt(t[1].replace("~",""),10),i=parseInt(t[2].split("-")[0],10);return[r,n,i];}async function sv(e,t,r={}){return sy(await sE(),e,t,r);}async function sy(e,t,r,n={}){let{usePipx:i=!0,user:o=!0,upgrade:s=!1,isLibrary:a=!1}=n,l=i&&!a&&(await sw(e)),c=l?"pipx":"pip";(0,ry.info)(`Installing ${t} ${r??""} via ${c}`);let u=await sb(e,t);if(u)try{let n=void 0!==r&&""!==r?`${t}==${r}`:t,i=!l&&o?["--user"]:[];nT(e,["-m",c,...(s?l?["upgrade"]:["install","--upgrade"]:["install"]),...i,n],{stdio:"inherit"});}catch(e){if((0,ry.info)(`Failed to install ${t} via ${c}: ${e}.`),(await s$(t))===null)throw Error(`Failed to install ${t} via ${c}: ${e}.`);}else if((await s$(t))===null)throw Error(`Failed to install ${t} as it was not found via ${c} or the system package manager`);let d=await sc(e),p=await sS(d,t);return await nV(p),{binDir:p};}async function sw(e){return 0===(await nI(e,["-m","pipx","--help"],{stdio:"ignore",reject:!1})).exitCode;}async function sx(){let e=(await o5(su("python",void 0,await sm()),"",process.arch)).bin;if(void 0===e)throw Error("Python binary was not found");return e;}const sE=oq(sx);async function sb(e,t){let r=await nI(e,["-m","pip","show",t],{stdio:"ignore",reject:!1});return 0===r.exitCode;}async function sS(e,t){let r=await Promise.all(e.map(e=>(0,nF.pathExists)((0,iP.join)(e,(0,iP.addExeExt)(t))))),n=r.findIndex(e=>e);if(-1!==n){let t=e[n];return t;}let i=/*@__PURE__*/B(nQ).sync((0,iP.addExeExt)(t),{nothrow:!0});return null!==i?(0,iP.dirname)(i):e[e.length-1];}function s$(e){if("linux"===process.platform){if((0,ry.info)(`Installing ${e} via the system package manager`),iF())return iz(`python-${e}`);if(iB())return iG([{name:`python3-${e}`}]);if(iV())return ix([{name:`python3-${e}`}]);}return null;}async function s_(e,t,r){switch(process.platform){case"win32":{await iM("cppcheck",e);let t=await sO();return{binDir:t};}case"darwin":return iD("cppcheck",e);case"linux":if(iF())return iz("cppcheck",e);if(iB())return iG([{name:"ccache",version:e}]);if(iV())return ix([{name:"cppcheck",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sO(){let e="C:/Program Files/Cppcheck";return await nV(e),e;}var iP=q("ceI0e"),K=q("ER74K");async function sC(e,t,r){switch(process.platform){case"win32":return await iM("graphviz",e),sI();case"darwin":return iD("graphviz",e);case"linux":if(iF())return iz("graphviz",e);if(iB())return iG([{name:"graphviz",version:e}]);if(iV())return ix([{name:"graphviz",version:e}]);throw Error("Unsupported linux distribution");default:throw Error("Unsupported platform");}}async function sI(){if("win32"===process.platform){let e="C:/Program Files/Graphviz/bin";return await nV(e),{binDir:e};}throw Error("Unsupported platform");}var nF=q("dOmbL");/** Get the platform data for cmake */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
function sT(e,t,r){switch(t){case"linux":{let t=`doxygen-${e}`;return{binRelativeDir:"bin/",binFileName:(0,iP.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:iJ.extractTar,url:`https://www.doxygen.nl/files/${t}.linux.bin.tar.gz`};}case"win32":{let t=`doxygen-${e}`;return{binRelativeDir:"",binFileName:(0,iP.addExeExt)("doxygen"),extractedFolderName:t,extractFunction:ok,url:`https://www.doxygen.nl/files/${t}.windows.x64.bin.zip`};}default:throw Error(`Unsupported platform '${t}'`);}}async function sR(e,t,r){switch(process.platform){case"win32":{// try to download the package 4 times with 2 seconds delay
await/*@__PURE__*/B(oO)(()=>iM("doxygen.install",e),{name:"doxygen.install",max:4,backoffBase:2e3,report:e=>(0,K.info)(e)});let t=await sP();return await sC(su("graphviz",void 0),"",r),{binDir:t};}case"darwin":{let e=await iD("doxygen",void 0);return await sC(su("graphviz",void 0),"",r),e;}case"linux":{let n;if(""===e||iF()||iB()){if(iF())n=await iz("doxygen",e);else if(iB())return iG([{name:"doxygen",version:e}]);else if(iV())n=await ix([{name:"doxygen",version:e}]);else throw Error("Unsupported linux distributions");}else if(iV())try{// doxygen on stable Ubuntu repositories is very old. So, we use get the binary from the website itself
n=await oR("doxygen",e,sT,t,r),await ix([{name:"libclang-cpp9"}]);}catch(e){(0,K.notice)(`Failed to download doxygen binary. ${e}. Falling back to apt-get.`),n=await ix([{name:"doxygen"}]);}else throw Error("Unsupported linux distributions");return await sC(su("graphviz",void 0,await sm()),"",r),n;}default:throw Error("Unsupported platform");}}async function sP(){if("win32"===process.platform){for(let e of["C:/ProgramData/chocolatey/bin","C:/Program Files/doxygen/bin","C:/Program Files (x86)/doxygen"])if(await(0,nF.pathExists)((0,iP.join)(e,"doxygen.exe")))return(// eslint-disable-next-line no-await-in-loop

File diff suppressed because one or more lines are too long

View File

@ -49,25 +49,25 @@ export async function setupPipPackWithPython(
info(`Installing ${name} ${version ?? ""} via ${pip}`)
try {
const nameAndVersion = version !== undefined && version !== "" ? `${name}==${version}` : name
const upgradeFlag = upgrade ? (isPipx ? ["upgrade"] : ["install", "--upgrade"]) : ["install"]
const userFlag = !isPipx && user ? ["--user"] : []
const hasPackage = await pipHasPackage(givenPython, name)
if (hasPackage) {
try {
const nameAndVersion = version !== undefined && version !== "" ? `${name}==${version}` : name
const upgradeFlag = upgrade ? (isPipx ? ["upgrade"] : ["install", "--upgrade"]) : ["install"]
const userFlag = !isPipx && user ? ["--user"] : []
const hasPackage = await pipHasPackage(givenPython, name)
if (hasPackage) {
execaSync(givenPython, ["-m", pip, ...upgradeFlag, ...userFlag, nameAndVersion], {
stdio: "inherit",
})
} else {
} catch (err) {
info(`Failed to install ${name} via ${pip}: ${err}.`)
if ((await setupPipPackSystem(name)) === null) {
throw new Error(`Failed to install ${name}.`)
throw new Error(`Failed to install ${name} via ${pip}: ${err}.`)
}
}
} catch (err) {
info(`Failed to install ${name} via ${pip}: ${err}.`)
} else {
if ((await setupPipPackSystem(name)) === null) {
throw new Error(`Failed to install ${name} via ${pip}: ${err}.`)
throw new Error(`Failed to install ${name} as it was not found via ${pip} or the system package manager`)
}
}