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