Skip to content

Commit

Permalink
poetry: Support same virtualenv appearing in multiple projects
Browse files Browse the repository at this point in the history
  • Loading branch information
oranav committed Oct 8, 2022
1 parent 631f1a0 commit 98a834f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/cache-distributions/poetry-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class PoetryCache extends CacheDistributor {
}

protected async getCacheGlobalDirectories() {
const paths = [];
// Same virtualenvs path may appear for different projects, hence we use a Set
const paths = new Set<string>();
const globber = await glob.create(this.patterns);

for await (const file of globber.globGenerator()) {
Expand All @@ -29,10 +30,10 @@ class PoetryCache extends CacheDistributor {
cacheDir
);

paths.push(virtualenvsPath);
paths.add(virtualenvsPath);

if (poetryConfig['virtualenvs.in-project'] === true) {
paths.push(path.join(basedir, '.venv'));
paths.add(path.join(basedir, '.venv'));
}
}

Expand All @@ -56,7 +57,7 @@ class PoetryCache extends CacheDistributor {
logWarning('python binaries were not found in PATH');
}

return paths;
return Array.from(paths);
}

protected async computeKeys() {
Expand Down

0 comments on commit 98a834f

Please sign in to comment.