mirror of
https://github.com/actions/setup-python.git
synced 2025-04-21 22:38:43 +00:00
resolve conflicts
This commit is contained in:
parent
de4dd601ce
commit
2718326b8a
3 changed files with 53 additions and 15 deletions
|
@ -176,7 +176,7 @@ describe('Finder tests', () => {
|
|||
|
||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||
await finder.useCpythonVersion('1.2', 'x64', false, true);
|
||||
await finder.useCpythonVersion('1.2', 'x64', true, true);
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith("Resolved as '1.2.3'");
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
|
|
66
dist/setup/index.js
vendored
66
dist/setup/index.js
vendored
|
@ -64662,19 +64662,34 @@ const utils_1 = __nccwpck_require__(1314);
|
|||
const semver = __importStar(__nccwpck_require__(1383));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
function findPyPyVersion(versionSpec, architecture, updateEnvironment) {
|
||||
function findPyPyVersion(versionSpec, architecture, updateEnvironment, checkLatest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let resolvedPyPyVersion = '';
|
||||
let resolvedPythonVersion = '';
|
||||
let installDir;
|
||||
let releases;
|
||||
const pypyVersionSpec = parsePyPyVersion(versionSpec);
|
||||
if (checkLatest) {
|
||||
releases = yield pypyInstall.getAvailablePyPyVersions();
|
||||
if (releases && releases.length > 0) {
|
||||
const releaseData = pypyInstall.findRelease(releases, pypyVersionSpec.pythonVersion, pypyVersionSpec.pypyVersion, architecture);
|
||||
if (releaseData) {
|
||||
core.info(`Resolved as PyPy ${releaseData.resolvedPyPyVersion} with Python (${releaseData.resolvedPythonVersion})`);
|
||||
pypyVersionSpec.pythonVersion = releaseData.resolvedPythonVersion;
|
||||
pypyVersionSpec.pypyVersion = releaseData.resolvedPyPyVersion;
|
||||
}
|
||||
else {
|
||||
core.info(`Failed to resolve PyPy ${pypyVersionSpec.pypyVersion} with Python (${pypyVersionSpec.pythonVersion}) from manifest`);
|
||||
}
|
||||
}
|
||||
}
|
||||
({ installDir, resolvedPythonVersion, resolvedPyPyVersion } = findPyPyToolCache(pypyVersionSpec.pythonVersion, pypyVersionSpec.pypyVersion, architecture));
|
||||
if (!installDir) {
|
||||
({
|
||||
installDir,
|
||||
resolvedPythonVersion,
|
||||
resolvedPyPyVersion
|
||||
} = yield pypyInstall.installPyPy(pypyVersionSpec.pypyVersion, pypyVersionSpec.pythonVersion, architecture));
|
||||
} = yield pypyInstall.installPyPy(pypyVersionSpec.pypyVersion, pypyVersionSpec.pythonVersion, architecture, releases));
|
||||
}
|
||||
const pipDir = utils_1.IS_WINDOWS ? 'Scripts' : 'bin';
|
||||
const _binDir = path.join(installDir, pipDir);
|
||||
|
@ -64824,15 +64839,28 @@ function binDir(installDir) {
|
|||
return path.join(installDir, 'bin');
|
||||
}
|
||||
}
|
||||
function useCpythonVersion(version, architecture, updateEnvironment) {
|
||||
function useCpythonVersion(version, architecture, updateEnvironment, checkLatest) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let manifest = null;
|
||||
const desugaredVersionSpec = desugarDevVersion(version);
|
||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
let semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||
core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
|
||||
if (checkLatest) {
|
||||
manifest = yield installer.getManifest();
|
||||
const resolvedVersion = (_a = (yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest))) === null || _a === void 0 ? void 0 : _a.version;
|
||||
if (resolvedVersion) {
|
||||
semanticVersionSpec = resolvedVersion;
|
||||
core.info(`Resolved as '${semanticVersionSpec}'`);
|
||||
}
|
||||
else {
|
||||
core.info(`Failed to resolve version ${semanticVersionSpec} from manifest`);
|
||||
}
|
||||
}
|
||||
let installDir = tc.find('Python', semanticVersionSpec, architecture);
|
||||
if (!installDir) {
|
||||
core.info(`Version ${semanticVersionSpec} was not found in the local cache`);
|
||||
const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture);
|
||||
const foundRelease = yield installer.findReleaseFromManifest(semanticVersionSpec, architecture, manifest);
|
||||
if (foundRelease && foundRelease.files && foundRelease.files.length > 0) {
|
||||
core.info(`Version ${semanticVersionSpec} is available for downloading`);
|
||||
yield installer.installCpythonFromRelease(foundRelease);
|
||||
|
@ -64951,7 +64979,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.findAssetForMacOrLinux = exports.findAssetForWindows = exports.isArchPresentForMacOrLinux = exports.isArchPresentForWindows = exports.pypyVersionToSemantic = exports.getPyPyBinaryPath = exports.findRelease = exports.installPyPy = void 0;
|
||||
exports.findAssetForMacOrLinux = exports.findAssetForWindows = exports.isArchPresentForMacOrLinux = exports.isArchPresentForWindows = exports.pypyVersionToSemantic = exports.getPyPyBinaryPath = exports.findRelease = exports.getAvailablePyPyVersions = exports.installPyPy = void 0;
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
|
@ -64960,10 +64988,10 @@ const httpm = __importStar(__nccwpck_require__(9925));
|
|||
const exec = __importStar(__nccwpck_require__(1514));
|
||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||
const utils_1 = __nccwpck_require__(1314);
|
||||
function installPyPy(pypyVersion, pythonVersion, architecture) {
|
||||
function installPyPy(pypyVersion, pythonVersion, architecture, releases) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let downloadDir;
|
||||
const releases = yield getAvailablePyPyVersions();
|
||||
releases = releases !== null && releases !== void 0 ? releases : (yield getAvailablePyPyVersions());
|
||||
if (!releases || releases.length === 0) {
|
||||
throw new Error('No release was found in PyPy version.json');
|
||||
}
|
||||
|
@ -65009,6 +65037,7 @@ function getAvailablePyPyVersions() {
|
|||
return response.result;
|
||||
});
|
||||
}
|
||||
exports.getAvailablePyPyVersions = getAvailablePyPyVersions;
|
||||
function createPyPySymlink(pypyBinaryPath, pythonVersion) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const version = semver.coerce(pythonVersion);
|
||||
|
@ -65131,7 +65160,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.installCpythonFromRelease = exports.findReleaseFromManifest = exports.MANIFEST_URL = void 0;
|
||||
exports.installCpythonFromRelease = exports.getManifest = exports.findReleaseFromManifest = exports.MANIFEST_URL = void 0;
|
||||
const path = __importStar(__nccwpck_require__(1017));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const tc = __importStar(__nccwpck_require__(7784));
|
||||
|
@ -65143,13 +65172,21 @@ const MANIFEST_REPO_OWNER = 'actions';
|
|||
const MANIFEST_REPO_NAME = 'python-versions';
|
||||
const MANIFEST_REPO_BRANCH = 'main';
|
||||
exports.MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
|
||||
function findReleaseFromManifest(semanticVersionSpec, architecture) {
|
||||
function findReleaseFromManifest(semanticVersionSpec, architecture, manifest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const manifest = yield tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
|
||||
return yield tc.findFromManifest(semanticVersionSpec, false, manifest, architecture);
|
||||
if (!manifest) {
|
||||
manifest = yield getManifest();
|
||||
}
|
||||
const foundRelease = yield tc.findFromManifest(semanticVersionSpec, false, manifest, architecture);
|
||||
return foundRelease;
|
||||
});
|
||||
}
|
||||
exports.findReleaseFromManifest = findReleaseFromManifest;
|
||||
function getManifest() {
|
||||
core.debug(`Getting manifest from ${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}@${MANIFEST_REPO_BRANCH}`);
|
||||
return tc.getManifestFromRepo(MANIFEST_REPO_OWNER, MANIFEST_REPO_NAME, AUTH, MANIFEST_REPO_BRANCH);
|
||||
}
|
||||
exports.getManifest = getManifest;
|
||||
function installPython(workingDirectory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const options = {
|
||||
|
@ -65290,17 +65327,18 @@ function run() {
|
|||
core.debug(`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`);
|
||||
try {
|
||||
const version = resolveVersionInput();
|
||||
const checkLatest = core.getBooleanInput('check-latest');
|
||||
if (version) {
|
||||
let pythonVersion;
|
||||
const arch = core.getInput('architecture') || os.arch();
|
||||
const updateEnvironment = core.getBooleanInput('update-environment');
|
||||
if (isPyPyVersion(version)) {
|
||||
const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment);
|
||||
const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment, checkLatest);
|
||||
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
||||
core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);
|
||||
}
|
||||
else {
|
||||
const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment);
|
||||
const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment, checkLatest);
|
||||
pythonVersion = installed.version;
|
||||
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue