3
0
Fork 0
mirror of https://gitea.com/actions/setup-python.git synced 2024-11-26 03:59:34 +01:00
This commit is contained in:
Patrick Arminio 2021-11-27 11:33:40 +00:00
parent 7c950ebdca
commit c275cf49c7
No known key found for this signature in database
GPG key ID: 0B13AD30354F6EBE

89
dist/setup/index.js vendored
View file

@ -38756,7 +38756,90 @@ exports.setLogLevel = setLogLevel;
/* 495 */, /* 495 */,
/* 496 */, /* 496 */,
/* 497 */, /* 497 */,
/* 498 */, /* 498 */
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const glob = __importStar(__webpack_require__(281));
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
const exec = __importStar(__webpack_require__(986));
const cache_distributor_1 = __importDefault(__webpack_require__(435));
class PoetryCache extends cache_distributor_1.default {
constructor(pythonVersion, patterns = '**/poetry.lock') {
super('poetry', patterns);
this.pythonVersion = pythonVersion;
this.patterns = patterns;
}
getCacheGlobalDirectories() {
return __awaiter(this, void 0, void 0, function* () {
const poetryConfig = yield this.getPoetryConfiguration();
const cacheDir = poetryConfig['cache-dir'];
const virtualenvsPath = poetryConfig['virtualenvs.path'].replace('{cache-dir}', cacheDir);
const paths = [virtualenvsPath];
if (poetryConfig['virtualenvs.in-project'] === 'true') {
paths.push(path.join(process.cwd(), '.venv'));
}
return paths;
});
}
computeKeys() {
return __awaiter(this, void 0, void 0, function* () {
const hash = yield glob.hashFiles(this.patterns);
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
const restoreKey = undefined;
return {
primaryKey,
restoreKey
};
});
}
getPoetryConfiguration() {
return __awaiter(this, void 0, void 0, function* () {
const { stdout, stderr, exitCode } = yield exec.getExecOutput('poetry', [
'config',
'--list'
]);
if (exitCode && stderr) {
console.log(stdout, stderr, exitCode);
throw new Error(`Could not get cache folder path for poetry package manager`);
}
const lines = stdout.trim().split(os.EOL);
const config = {};
for (let line of lines) {
line = line.replace(/#.*$/, '');
const [key, value] = line.split('=').map(part => part.trim());
config[key] = value;
}
return config;
});
}
}
exports.default = PoetryCache;
/***/ }),
/* 499 */ /* 499 */
/***/ (function(module, __unusedexports, __webpack_require__) { /***/ (function(module, __unusedexports, __webpack_require__) {
@ -44017,10 +44100,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getCacheDistributor = exports.PackageManagers = void 0; exports.getCacheDistributor = exports.PackageManagers = void 0;
const pip_cache_1 = __importDefault(__webpack_require__(394)); const pip_cache_1 = __importDefault(__webpack_require__(394));
const pipenv_cache_1 = __importDefault(__webpack_require__(235)); const pipenv_cache_1 = __importDefault(__webpack_require__(235));
const poetry_cache_1 = __importDefault(__webpack_require__(498));
var PackageManagers; var PackageManagers;
(function (PackageManagers) { (function (PackageManagers) {
PackageManagers["Pip"] = "pip"; PackageManagers["Pip"] = "pip";
PackageManagers["Pipenv"] = "pipenv"; PackageManagers["Pipenv"] = "pipenv";
PackageManagers["Poetry"] = "poetry";
})(PackageManagers = exports.PackageManagers || (exports.PackageManagers = {})); })(PackageManagers = exports.PackageManagers || (exports.PackageManagers = {}));
function getCacheDistributor(packageManager, pythonVersion, cacheDependencyPath) { function getCacheDistributor(packageManager, pythonVersion, cacheDependencyPath) {
switch (packageManager) { switch (packageManager) {
@ -44028,6 +44113,8 @@ function getCacheDistributor(packageManager, pythonVersion, cacheDependencyPath)
return new pip_cache_1.default(pythonVersion, cacheDependencyPath); return new pip_cache_1.default(pythonVersion, cacheDependencyPath);
case PackageManagers.Pipenv: case PackageManagers.Pipenv:
return new pipenv_cache_1.default(pythonVersion, cacheDependencyPath); return new pipenv_cache_1.default(pythonVersion, cacheDependencyPath);
case PackageManagers.Poetry:
return new poetry_cache_1.default(pythonVersion, cacheDependencyPath);
default: default:
throw new Error(`Caching for '${packageManager}' is not supported`); throw new Error(`Caching for '${packageManager}' is not supported`);
} }