UNPKG

2.42 kBTypeScriptView Raw
1import { SoftwarePackage } from '@stencila/schema';
2import PackageGenerator from './PackageGenerator';
3import IUrlFetcher from './IUrlFetcher';
4/**
5 * A Dockerfile generator for Python packages
6 */
7export default class PythonGenerator extends PackageGenerator {
8 /**
9 * The Python Major version, i.e. 2 or 3
10 */
11 private readonly pythonMajorVersion;
12 /**
13 * An instance of `PythonSystemPackageLookup` with which to look up system dependencies of Python packages
14 */
15 private readonly systemPackageLookup;
16 constructor(urlFetcher: IUrlFetcher, pkg: SoftwarePackage, folder?: string, pythonMajorVersion?: number);
17 /**
18 * Return the `pythonMajorVersion` (as string) if it is not 2, otherwise return an empty string (if it is 2). This is
19 * for appending to things like pip{3} or python{3}.
20 */
21 pythonVersionSuffix(): string;
22 /**
23 * Check if this Generator's package applies (if it is Python).
24 */
25 applies(): boolean;
26 /**
27 * Generate a list of system (apt) packages by looking up with `this.systemPackageLookup`.
28 */
29 aptPackages(sysVersion: string): Array<string>;
30 /**
31 * Build the contents of a `requirements.txt` file by joining the Python package name to its version specifier.
32 */
33 generateRequirementsContent(): string;
34 /**
35 * Get the pip command to install the Stencila package
36 */
37 stencilaInstall(sysVersion: string): string | undefined;
38 /**
39 * Write out the generated requirements content to `GENERATED_REQUIREMENTS_FILE` or none exists, just instruct the
40 * copy of a `requirements.txt` file as part of the Dockerfile. If that does not exist, then no COPY should be done.
41 */
42 installFiles(sysVersion: string): Array<[string, string]>;
43 /**
44 * Generate the right pip command to install the requirements, appends the correct Python major version to `pip`.
45 */
46 installCommand(sysVersion: string): string | undefined;
47 /**
48 * The files to copy into the Docker image
49 *
50 * Copies all `*.py` files to the container
51 */
52 projectFiles(): Array<[string, string]>;
53 /**
54 * The command to execute in a container created from the Docker image
55 *
56 * If there is a top-level `main.py` or `cmd.py` then that will be used,
57 * otherwise, the first `*.R` files by alphabetical order will be used.
58 */
59 runCommand(): string | undefined;
60}