fix: don't override AGENT_TOOLSDIRECTORY if it's not needed

`AGENT_TOOLSDIRECTORY` is always overriden on macOS.
This seems to be needed because CPython < 3.11 x64 builds are not relocatable.
It means this is not needed for PyPy and also not needed when targetting macOS arm64 runners.
This commit is contained in:
mayeut 2022-12-11 17:44:36 +01:00
parent 2c3dd9e7e2
commit 21aa270b17
No known key found for this signature in database
GPG Key ID: 8B03CED67D3ABFBA
2 changed files with 28 additions and 22 deletions

20
dist/setup/index.js vendored
View File

@ -66896,21 +66896,23 @@ function resolveVersionInput() {
function run() { function run() {
var _a; var _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (utils_1.IS_MAC) { try {
const version = resolveVersionInput();
if (version) {
let pythonVersion;
const arch = core.getInput('architecture') || os.arch();
const updateEnvironment = core.getBooleanInput('update-environment');
const checkLatest = core.getBooleanInput('check-latest');
const isPyPy = isPyPyVersion(version);
const forceMacToolsDirectory = utils_1.IS_MAC && !isPyPy && arch === 'x64';
if (forceMacToolsDirectory) {
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
} }
if ((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim()) { if ((_a = process.env.AGENT_TOOLSDIRECTORY) === null || _a === void 0 ? void 0 : _a.trim()) {
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY']; process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
} }
core.debug(`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`); core.debug(`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`);
try { if (isPyPy) {
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, checkLatest); const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment, checkLatest);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`); core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`);

View File

@ -63,7 +63,18 @@ function resolveVersionInput(): string {
} }
async function run() { async function run() {
if (IS_MAC) { try {
const version = resolveVersionInput();
if (version) {
let pythonVersion: string;
const arch: string = core.getInput('architecture') || os.arch();
const updateEnvironment = core.getBooleanInput('update-environment');
const checkLatest = core.getBooleanInput('check-latest');
const isPyPy = isPyPyVersion(version);
const forceMacToolsDirectory = IS_MAC && !isPyPy && arch === 'x64';
if (forceMacToolsDirectory) {
process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache'; process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
} }
@ -74,15 +85,8 @@ async function run() {
core.debug( core.debug(
`Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}` `Python is expected to be installed into ${process.env['RUNNER_TOOL_CACHE']}`
); );
try {
const version = resolveVersionInput();
const checkLatest = core.getBooleanInput('check-latest');
if (version) { if (isPyPy) {
let pythonVersion: string;
const arch: string = core.getInput('architecture') || os.arch();
const updateEnvironment = core.getBooleanInput('update-environment');
if (isPyPyVersion(version)) {
const installed = await finderPyPy.findPyPyVersion( const installed = await finderPyPy.findPyPyVersion(
version, version,
arch, arch,