( versionSpec: string, architecture: string, updateEnvironment: boolean, checkLatest: boolean, allowPreReleases: boolean )
| 7 | import * as tc from '@actions/tool-cache'; |
| 8 | |
| 9 | export async function findGraalPyVersion( |
| 10 | versionSpec: string, |
| 11 | architecture: string, |
| 12 | updateEnvironment: boolean, |
| 13 | checkLatest: boolean, |
| 14 | allowPreReleases: boolean |
| 15 | ): Promise<string> { |
| 16 | let resolvedGraalPyVersion = ''; |
| 17 | let installDir: string | null; |
| 18 | let releases: IGraalPyManifestRelease[] | undefined; |
| 19 | |
| 20 | let graalpyVersionSpec = parseGraalPyVersion(versionSpec); |
| 21 | |
| 22 | if (checkLatest) { |
| 23 | releases = await graalpyInstall.getAvailableGraalPyVersions(); |
| 24 | if (releases && releases.length > 0) { |
| 25 | const releaseData = graalpyInstall.findRelease( |
| 26 | releases, |
| 27 | graalpyVersionSpec, |
| 28 | architecture, |
| 29 | false |
| 30 | ); |
| 31 | |
| 32 | if (releaseData) { |
| 33 | core.info(`Resolved as GraalPy ${releaseData.resolvedGraalPyVersion}`); |
| 34 | graalpyVersionSpec = releaseData.resolvedGraalPyVersion; |
| 35 | } else { |
| 36 | core.info( |
| 37 | `Failed to resolve GraalPy ${graalpyVersionSpec} from manifest` |
| 38 | ); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | ({installDir, resolvedGraalPyVersion} = findGraalPyToolCache( |
| 44 | graalpyVersionSpec, |
| 45 | architecture |
| 46 | )); |
| 47 | |
| 48 | if (!installDir) { |
| 49 | ({installDir, resolvedGraalPyVersion} = await graalpyInstall.installGraalPy( |
| 50 | graalpyVersionSpec, |
| 51 | architecture, |
| 52 | allowPreReleases, |
| 53 | releases |
| 54 | )); |
| 55 | } |
| 56 | |
| 57 | const pipDir = IS_WINDOWS ? 'Scripts' : 'bin'; |
| 58 | const _binDir = path.join(installDir, pipDir); |
| 59 | const binaryExtension = IS_WINDOWS ? '.exe' : ''; |
| 60 | const pythonPath = path.join(_binDir, `python${binaryExtension}`); |
| 61 | const pythonLocation = path.join(installDir, 'bin'); |
| 62 | if (updateEnvironment) { |
| 63 | core.exportVariable('pythonLocation', installDir); |
| 64 | // https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython |
| 65 | core.exportVariable('Python_ROOT_DIR', installDir); |
| 66 | // https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2 |
nothing calls this directly
no test coverage detected