@@ -65787,6 +65787,9 @@ class CacheDistributor {
65787
65787
this.cacheDependencyPath = cacheDependencyPath;
65788
65788
this.CACHE_KEY_PREFIX = 'setup-python';
65789
65789
}
65790
+ handleLoadedCache() {
65791
+ return __awaiter(this, void 0, void 0, function* () { });
65792
+ }
65790
65793
restoreCache() {
65791
65794
return __awaiter(this, void 0, void 0, function* () {
65792
65795
const { primaryKey, restoreKey } = yield this.computeKeys();
@@ -65799,6 +65802,7 @@ class CacheDistributor {
65799
65802
core.saveState(State.CACHE_PATHS, cachePath);
65800
65803
core.saveState(State.STATE_CACHE_PRIMARY_KEY, primaryKey);
65801
65804
const matchedKey = yield cache.restoreCache(cachePath, primaryKey, restoreKey);
65805
+ yield this.handleLoadedCache();
65802
65806
this.handleMatchResult(matchedKey, primaryKey);
65803
65807
});
65804
65808
}
@@ -66097,42 +66101,31 @@ const core = __importStar(__nccwpck_require__(2186));
66097
66101
const cache_distributor_1 = __importDefault(__nccwpck_require__(8953));
66098
66102
const utils_1 = __nccwpck_require__(1314);
66099
66103
class PoetryCache extends cache_distributor_1.default {
66100
- constructor(pythonVersion, patterns = '**/poetry.lock') {
66104
+ constructor(pythonVersion, patterns = '**/poetry.lock', poetryProjects = new Set() ) {
66101
66105
super('poetry', patterns);
66102
66106
this.pythonVersion = pythonVersion;
66103
66107
this.patterns = patterns;
66108
+ this.poetryProjects = poetryProjects;
66104
66109
}
66105
66110
getCacheGlobalDirectories() {
66106
66111
var e_1, _a;
66107
66112
return __awaiter(this, void 0, void 0, function* () {
66108
66113
// Same virtualenvs path may appear for different projects, hence we use a Set
66109
66114
const paths = new Set();
66110
66115
const globber = yield glob.create(this.patterns);
66111
- const pythonLocation = yield io.which('python');
66112
- if (pythonLocation) {
66113
- core.debug(`pythonLocation is ${pythonLocation}`);
66114
- }
66115
- else {
66116
- utils_1.logWarning('python binaries were not found in PATH');
66117
- }
66118
66116
try {
66119
66117
for (var _b = __asyncValues(globber.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
66120
66118
const file = _c.value;
66121
66119
const basedir = path.dirname(file);
66122
66120
core.debug(`Processing Poetry project at ${basedir}`);
66121
+ this.poetryProjects.add(basedir);
66123
66122
const poetryConfig = yield this.getPoetryConfiguration(basedir);
66124
66123
const cacheDir = poetryConfig['cache-dir'];
66125
66124
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace('{cache-dir}', cacheDir);
66126
66125
paths.add(virtualenvsPath);
66127
66126
if (poetryConfig['virtualenvs.in-project']) {
66128
66127
paths.add(path.join(basedir, '.venv'));
66129
66128
}
66130
- if (pythonLocation) {
66131
- const { exitCode, stderr } = yield exec.getExecOutput('poetry', ['env', 'use', pythonLocation], { ignoreReturnCode: true, cwd: basedir });
66132
- if (exitCode) {
66133
- utils_1.logWarning(stderr);
66134
- }
66135
- }
66136
66129
}
66137
66130
}
66138
66131
catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -66156,6 +66149,30 @@ class PoetryCache extends cache_distributor_1.default {
66156
66149
};
66157
66150
});
66158
66151
}
66152
+ handleLoadedCache() {
66153
+ const _super = Object.create(null, {
66154
+ handleLoadedCache: { get: () => super.handleLoadedCache }
66155
+ });
66156
+ return __awaiter(this, void 0, void 0, function* () {
66157
+ yield _super.handleLoadedCache.call(this);
66158
+ // After the cache is loaded -- make sure virtualenvs use the correct Python version (the one that we have just installed).
66159
+ // This will handle invalid caches, recreating virtualenvs if necessary.
66160
+ const pythonLocation = yield io.which('python');
66161
+ if (pythonLocation) {
66162
+ core.debug(`pythonLocation is ${pythonLocation}`);
66163
+ }
66164
+ else {
66165
+ utils_1.logWarning('python binaries were not found in PATH');
66166
+ return;
66167
+ }
66168
+ for (const poetryProject of this.poetryProjects) {
66169
+ const { exitCode, stderr } = yield exec.getExecOutput('poetry', ['env', 'use', pythonLocation], { ignoreReturnCode: true, cwd: poetryProject });
66170
+ if (exitCode) {
66171
+ utils_1.logWarning(stderr);
66172
+ }
66173
+ }
66174
+ });
66175
+ }
66159
66176
getPoetryConfiguration(basedir) {
66160
66177
return __awaiter(this, void 0, void 0, function* () {
66161
66178
const { stdout, stderr, exitCode } = yield exec.getExecOutput('poetry', ['config', '--list'], { cwd: basedir });
0 commit comments