2021-11-17 10:31:22 +00:00
|
|
|
import PipCache from './pip-cache';
|
|
|
|
import PipenvCache from './pipenv-cache';
|
2021-11-24 15:12:00 +00:00
|
|
|
import PoetryCache from './poetry-cache';
|
2021-11-17 10:31:22 +00:00
|
|
|
|
|
|
|
export enum PackageManagers {
|
|
|
|
Pip = 'pip',
|
2021-11-24 15:12:00 +00:00
|
|
|
Pipenv = 'pipenv',
|
|
|
|
Poetry = 'poetry'
|
2021-11-17 10:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getCacheDistributor(
|
|
|
|
packageManager: string,
|
|
|
|
pythonVersion: string,
|
|
|
|
cacheDependencyPath: string | undefined
|
|
|
|
) {
|
|
|
|
switch (packageManager) {
|
|
|
|
case PackageManagers.Pip:
|
2022-01-31 10:42:08 +00:00
|
|
|
return new PipCache(pythonVersion, cacheDependencyPath);
|
2021-11-17 10:31:22 +00:00
|
|
|
case PackageManagers.Pipenv:
|
|
|
|
return new PipenvCache(pythonVersion, cacheDependencyPath);
|
2021-11-24 15:12:00 +00:00
|
|
|
case PackageManagers.Poetry:
|
|
|
|
return new PoetryCache(pythonVersion, cacheDependencyPath);
|
2021-11-17 10:31:22 +00:00
|
|
|
default:
|
|
|
|
throw new Error(`Caching for '${packageManager}' is not supported`);
|
|
|
|
}
|
|
|
|
}
|