mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
poetry: Set up environment for each project individually
This commit is contained in:
parent
f35052820f
commit
727a4d2ef2
2 changed files with 32 additions and 28 deletions
25
dist/setup/index.js
vendored
25
dist/setup/index.js
vendored
|
@ -66108,10 +66108,18 @@ class PoetryCache extends cache_distributor_1.default {
|
||||||
// Same virtualenvs path may appear for different projects, hence we use a Set
|
// Same virtualenvs path may appear for different projects, hence we use a Set
|
||||||
const paths = new Set();
|
const paths = new Set();
|
||||||
const globber = yield glob.create(this.patterns);
|
const globber = yield glob.create(this.patterns);
|
||||||
|
const pythonLocation = yield io.which('python');
|
||||||
|
if (pythonLocation) {
|
||||||
|
core.debug(`pythonLocation is ${pythonLocation}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
utils_1.logWarning('python binaries were not found in PATH');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
for (var _b = __asyncValues(globber.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
|
for (var _b = __asyncValues(globber.globGenerator()), _c; _c = yield _b.next(), !_c.done;) {
|
||||||
const file = _c.value;
|
const file = _c.value;
|
||||||
const basedir = path.dirname(file);
|
const basedir = path.dirname(file);
|
||||||
|
core.debug(`Processing Poetry project at ${basedir}`);
|
||||||
const poetryConfig = yield this.getPoetryConfiguration(basedir);
|
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);
|
||||||
|
@ -66119,6 +66127,12 @@ class PoetryCache extends cache_distributor_1.default {
|
||||||
if (poetryConfig['virtualenvs.in-project'] === true) {
|
if (poetryConfig['virtualenvs.in-project'] === true) {
|
||||||
paths.add(path.join(basedir, '.venv'));
|
paths.add(path.join(basedir, '.venv'));
|
||||||
}
|
}
|
||||||
|
if (pythonLocation) {
|
||||||
|
const { exitCode, stderr } = yield exec.getExecOutput('poetry', ['env', 'use', pythonLocation], { ignoreReturnCode: true, cwd: basedir });
|
||||||
|
if (exitCode) {
|
||||||
|
utils_1.logWarning(stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
@ -66128,17 +66142,6 @@ class PoetryCache extends cache_distributor_1.default {
|
||||||
}
|
}
|
||||||
finally { if (e_1) throw e_1.error; }
|
finally { if (e_1) throw e_1.error; }
|
||||||
}
|
}
|
||||||
const pythonLocation = yield io.which('python');
|
|
||||||
if (pythonLocation) {
|
|
||||||
core.debug(`pythonLocation is ${pythonLocation}`);
|
|
||||||
const { exitCode, stderr } = yield exec.getExecOutput(`poetry env use ${pythonLocation}`, undefined, { ignoreReturnCode: true });
|
|
||||||
if (exitCode) {
|
|
||||||
utils_1.logWarning(stderr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
utils_1.logWarning('python binaries were not found in PATH');
|
|
||||||
}
|
|
||||||
return [...paths];
|
return [...paths];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,17 @@ class PoetryCache extends CacheDistributor {
|
||||||
const paths = new Set<string>();
|
const paths = new Set<string>();
|
||||||
const globber = await glob.create(this.patterns);
|
const globber = await glob.create(this.patterns);
|
||||||
|
|
||||||
|
const pythonLocation = await io.which('python');
|
||||||
|
if (pythonLocation) {
|
||||||
|
core.debug(`pythonLocation is ${pythonLocation}`);
|
||||||
|
} else {
|
||||||
|
logWarning('python binaries were not found in PATH');
|
||||||
|
}
|
||||||
|
|
||||||
for await (const file of globber.globGenerator()) {
|
for await (const file of globber.globGenerator()) {
|
||||||
const basedir = path.dirname(file);
|
const basedir = path.dirname(file);
|
||||||
|
core.debug(`Processing Poetry project at ${basedir}`);
|
||||||
|
|
||||||
const poetryConfig = await this.getPoetryConfiguration(basedir);
|
const poetryConfig = await this.getPoetryConfiguration(basedir);
|
||||||
|
|
||||||
const cacheDir = poetryConfig['cache-dir'];
|
const cacheDir = poetryConfig['cache-dir'];
|
||||||
|
@ -35,26 +44,18 @@ class PoetryCache extends CacheDistributor {
|
||||||
if (poetryConfig['virtualenvs.in-project'] === true) {
|
if (poetryConfig['virtualenvs.in-project'] === true) {
|
||||||
paths.add(path.join(basedir, '.venv'));
|
paths.add(path.join(basedir, '.venv'));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const pythonLocation = await io.which('python');
|
|
||||||
|
|
||||||
if (pythonLocation) {
|
if (pythonLocation) {
|
||||||
core.debug(`pythonLocation is ${pythonLocation}`);
|
const {exitCode, stderr} = await exec.getExecOutput(
|
||||||
const {
|
'poetry',
|
||||||
exitCode,
|
['env', 'use', pythonLocation],
|
||||||
stderr
|
{ignoreReturnCode: true, cwd: basedir}
|
||||||
} = await exec.getExecOutput(
|
|
||||||
`poetry env use ${pythonLocation}`,
|
|
||||||
undefined,
|
|
||||||
{ignoreReturnCode: true}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
logWarning(stderr);
|
logWarning(stderr);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
logWarning('python binaries were not found in PATH');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...paths];
|
return [...paths];
|
||||||
|
|
Loading…
Add table
Reference in a new issue