Skip to content

Commit

Permalink
poetry: Set up environment for each project individually
Browse files Browse the repository at this point in the history
  • Loading branch information
oranav committed Oct 8, 2022
1 parent b1e85b9 commit d3dceab
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/cache-distributions/poetry-cache.ts
Expand Up @@ -20,8 +20,17 @@ class PoetryCache extends CacheDistributor {
const paths = new Set<string>();
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()) {
const basedir = path.dirname(file);
core.debug(`Processing Poetry project at ${basedir}`);

const poetryConfig = await this.getPoetryConfiguration(basedir);

const cacheDir = poetryConfig['cache-dir'];
Expand All @@ -35,26 +44,18 @@ class PoetryCache extends CacheDistributor {
if (poetryConfig['virtualenvs.in-project'] === true) {
paths.add(path.join(basedir, '.venv'));
}
}

const pythonLocation = await io.which('python');

if (pythonLocation) {
core.debug(`pythonLocation is ${pythonLocation}`);
const {
exitCode,
stderr
} = await exec.getExecOutput(
`poetry env use ${pythonLocation}`,
undefined,
{ignoreReturnCode: true}
);
if (pythonLocation) {
const {exitCode, stderr} = await exec.getExecOutput(
'poetry',
['env', 'use', pythonLocation],
{ignoreReturnCode: true, cwd: basedir}
);

if (exitCode) {
logWarning(stderr);
if (exitCode) {
logWarning(stderr);
}
}
} else {
logWarning('python binaries were not found in PATH');
}

return Array.from(paths);
Expand Down

0 comments on commit d3dceab

Please sign in to comment.