mirror of
https://github.com/actions/setup-python.git
synced 2025-04-20 03:53:30 +00:00
Use correct Poetry config when collecting Poetry projects
When collecting Poetry projects for caching, a '**/poetry.lock' glob is used. However, in order to process the Poetry configuration, the "poetry" command is run from the repo's root directory; this causes Poetry to return an invalid configuration when there is a Poetry project inside an inner directory. Instead of running a single Poetry command, glob for the same pattern, and run a Poetry command for every discovered project.
This commit is contained in:
parent
2c3dd9e7e2
commit
748f3e6907
36
dist/setup/index.js
vendored
36
dist/setup/index.js
vendored
@ -66078,6 +66078,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
||||||
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||||
|
var m = o[Symbol.asyncIterator], i;
|
||||||
|
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
||||||
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
||||||
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
||||||
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
@ -66096,13 +66103,29 @@ class PoetryCache extends cache_distributor_1.default {
|
|||||||
this.patterns = patterns;
|
this.patterns = patterns;
|
||||||
}
|
}
|
||||||
getCacheGlobalDirectories() {
|
getCacheGlobalDirectories() {
|
||||||
|
var e_1, _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const poetryConfig = yield this.getPoetryConfiguration();
|
const paths = [];
|
||||||
|
const globber = yield glob.create(this.patterns);
|
||||||
|
try {
|
||||||
|
for (var _b = __asyncValues(globber.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
|
||||||
|
const file = _c.value;
|
||||||
|
const basedir = path.dirname(file);
|
||||||
|
const poetryConfig = yield this.getPoetryConfiguration(basedir);
|
||||||
const cacheDir = poetryConfig['cache-dir'];
|
const cacheDir = poetryConfig['cache-dir'];
|
||||||
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace('{cache-dir}', cacheDir);
|
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace('{cache-dir}', cacheDir);
|
||||||
const paths = [virtualenvsPath];
|
paths.push(virtualenvsPath);
|
||||||
if (poetryConfig['virtualenvs.in-project'] === true) {
|
if (poetryConfig['virtualenvs.in-project'] === true) {
|
||||||
paths.push(path.join(process.cwd(), '.venv'));
|
paths.push(path.join(basedir, '.venv'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b);
|
||||||
|
}
|
||||||
|
finally { if (e_1) throw e_1.error; }
|
||||||
}
|
}
|
||||||
const pythonLocation = yield io.which('python');
|
const pythonLocation = yield io.which('python');
|
||||||
if (pythonLocation) {
|
if (pythonLocation) {
|
||||||
@ -66129,12 +66152,9 @@ class PoetryCache extends cache_distributor_1.default {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getPoetryConfiguration() {
|
getPoetryConfiguration(basedir) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { stdout, stderr, exitCode } = yield exec.getExecOutput('poetry', [
|
const { stdout, stderr, exitCode } = yield exec.getExecOutput('poetry', ['config', '--list'], { cwd: basedir });
|
||||||
'config',
|
|
||||||
'--list'
|
|
||||||
]);
|
|
||||||
if (exitCode && stderr) {
|
if (exitCode && stderr) {
|
||||||
throw new Error('Could not get cache folder path for poetry package manager');
|
throw new Error('Could not get cache folder path for poetry package manager');
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,12 @@ class PoetryCache extends CacheDistributor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async getCacheGlobalDirectories() {
|
protected async getCacheGlobalDirectories() {
|
||||||
const poetryConfig = await this.getPoetryConfiguration();
|
const paths = [];
|
||||||
|
const globber = await glob.create(this.patterns);
|
||||||
|
|
||||||
|
for await (const file of globber.globGenerator()) {
|
||||||
|
const basedir = path.dirname(file);
|
||||||
|
const poetryConfig = await this.getPoetryConfiguration(basedir);
|
||||||
|
|
||||||
const cacheDir = poetryConfig['cache-dir'];
|
const cacheDir = poetryConfig['cache-dir'];
|
||||||
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace(
|
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace(
|
||||||
@ -24,10 +29,11 @@ class PoetryCache extends CacheDistributor {
|
|||||||
cacheDir
|
cacheDir
|
||||||
);
|
);
|
||||||
|
|
||||||
const paths = [virtualenvsPath];
|
paths.push(virtualenvsPath);
|
||||||
|
|
||||||
if (poetryConfig['virtualenvs.in-project'] === true) {
|
if (poetryConfig['virtualenvs.in-project'] === true) {
|
||||||
paths.push(path.join(process.cwd(), '.venv'));
|
paths.push(path.join(basedir, '.venv'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pythonLocation = await io.which('python');
|
const pythonLocation = await io.which('python');
|
||||||
@ -63,11 +69,12 @@ class PoetryCache extends CacheDistributor {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getPoetryConfiguration() {
|
private async getPoetryConfiguration(basedir: string) {
|
||||||
const {stdout, stderr, exitCode} = await exec.getExecOutput('poetry', [
|
const {stdout, stderr, exitCode} = await exec.getExecOutput(
|
||||||
'config',
|
'poetry',
|
||||||
'--list'
|
['config', '--list'],
|
||||||
]);
|
{cwd: basedir}
|
||||||
|
);
|
||||||
|
|
||||||
if (exitCode && stderr) {
|
if (exitCode && stderr) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
Loading…
Reference in New Issue
Block a user