Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PythonGenerator

A Dockerfile generator for Python packages

Hierarchy

Index

Constructors

constructor

  • new PythonGenerator(urlFetcher: UrlFetcher, pkg: SoftwarePackage, folder?: undefined | string, pythonMajorVersion?: number): PythonGenerator

Properties

Optional baseImage

baseImage: undefined | string

Manually define the image to inherit FROM

folder

folder: string

The directory to scan for relevant files

package

package: SoftwarePackage

The package that this generator generates a Dockerfile for

Private Readonly pythonMajorVersion

pythonMajorVersion: number

The Python Major version, i.e. 2 or 3

Private Readonly systemPackageLookup

systemPackageLookup: PythonSystemPackageLookup

An instance of PythonSystemPackageLookup with which to look up system dependencies of Python packages

Protected Readonly urlFetcher

urlFetcher: UrlFetcher

The instance of IUrlFetcher to fetch URLs

Methods

applies

  • applies(): boolean

aptKeysCommand

  • aptKeysCommand(sysVersion: string): string | undefined
  • A Bash command to run to install required apt keys

    Parameters

    • sysVersion: string

      The Ubuntu system version being used

    Returns string | undefined

aptPackages

  • aptPackages(sysVersion: string): Array<string>

aptRepos

  • aptRepos(sysVersion: string): Array<string>
  • A list of any required apt repositories

    Parameters

    • sysVersion: string

      The Ubuntu system version being used

    Returns Array<string>

baseIdentifier

  • baseIdentifier(): string

baseName

  • baseName(): string

baseVersion

  • baseVersion(): string

baseVersionName

  • baseVersionName(baseIdentifier: string): string

envVars

  • envVars(sysVersion: string): Array<[string, string]>
  • A list of environment variables to set in the image as name, value pairs

    Parameters

    • sysVersion: string

      The Ubuntu system version being used

    Returns Array<[string, string]>

exists

  • exists(subpath: string): boolean
  • Does a path exist within the project folder?

    Parameters

    • subpath: string

      The path within the folder

    Returns boolean

fetch

  • fetch(url: string, options?: any): Promise<any>
  • Fetch content from a URL

    Parameters

    • url: string

      The URL to fetch

    • Default value options: any = { responseType: 'json' }

      Request options

    Returns Promise<any>

filterPackages

  • filterPackages(runtimePlatform: string): Array<SoftwarePackage>

generate

  • generate(comments?: boolean, stencila?: boolean): string
  • Generate a Dockerfile for a SoftwareEnvironment instance

    Parameters

    • Default value comments: boolean = true

      Should a comments be added to the Dockerfile?

    • Default value stencila: boolean = false

      Should relevant Stencila language packages be installed in the image?

    Returns string

generateRequirementsContent

  • generateRequirementsContent(): string
  • Build the contents of a requirements.txt file by joining the Python package name to its version specifier.

    Returns string

glob

  • glob(pattern: string | Array<string>): Array<string>
  • Get a list of paths that match a pattern in the project folder.

    Parameters

    • pattern: string | Array<string>

      The glob pattern

    Returns Array<string>

installCommand

  • installCommand(sysVersion: string): string | undefined

installFiles

  • installFiles(sysVersion: string): Array<[string, string]>
  • 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.

    Parameters

    • sysVersion: string

    Returns Array<[string, string]>

projectFiles

  • projectFiles(): Array<[string, string]>

pythonVersionSuffix

  • pythonVersionSuffix(): string
  • 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}.

    Returns string

read

  • read(subpath: string): string
  • Read a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    Returns string

runCommand

  • runCommand(): string | undefined

stencilaInstall

  • stencilaInstall(sysVersion: string): string | undefined

write

  • write(subpath: string, content: string): void
  • Write to a file within the project folder

    Parameters

    • subpath: string

      The path within the folder

    • content: string

      The content to write to the file

    Returns void

Generated using TypeDoc