import { SoftwarePackage } from '@stencila/schema'; import PackageGenerator from './PackageGenerator'; import IUrlFetcher from './IUrlFetcher'; /** * A Dockerfile generator for Python packages */ export default class PythonGenerator extends PackageGenerator { /** * The Python Major version, i.e. 2 or 3 */ private readonly pythonMajorVersion; /** * An instance of `PythonSystemPackageLookup` with which to look up system dependencies of Python packages */ private readonly systemPackageLookup; constructor(urlFetcher: IUrlFetcher, pkg: SoftwarePackage, folder?: string, pythonMajorVersion?: number); /** * Return the `pythonMajorVersion` (as string) if it is not 2, otherwise return an empty string (if it is 2). This is * for appending to things like pip{3} or python{3}. */ pythonVersionSuffix(): string; /** * Check if this Generator's package applies (if it is Python). */ applies(): boolean; /** * Generate a list of system (apt) packages by looking up with `this.systemPackageLookup`. */ aptPackages(sysVersion: string): Array; /** * Build the contents of a `requirements.txt` file by joining the Python package name to its version specifier. */ generateRequirementsContent(): string; /** * Get the pip command to install the Stencila package */ stencilaInstall(sysVersion: string): string | undefined; /** * Write out the generated requirements content to `GENERATED_REQUIREMENTS_FILE` or none exists, just instruct the * copy of a `requirements.txt` file as part of the Dockerfile. If that does not exist, then no COPY should be done. */ installFiles(sysVersion: string): Array<[string, string]>; /** * Generate the right pip command to install the requirements, appends the correct Python major version to `pip`. */ installCommand(sysVersion: string): string | undefined; /** * The files to copy into the Docker image * * Copies all `*.py` files to the container */ projectFiles(): Array<[string, string]>; /** * The command to execute in a container created from the Docker image * * If there is a top-level `main.py` or `cmd.py` then that will be used, * otherwise, the first `*.R` files by alphabetical order will be used. */ runCommand(): string | undefined; }