runway.dependency_managers package

Classes for interacting with dependency managers using subprocesses.

class runway.dependency_managers.Pip[source]

Bases: runway.dependency_managers.base_classes.DependencyManager

pip CLI interface.

CONFIG_FILES: Final[Tuple[Literal['requirements.txt']]] = ('requirements.txt',)

Configuration files used by pip.

EXECUTABLE: Final[Literal['pip']] = 'pip'

CLI executable.

property python_version: runway.utils._version.Version

Python version where pip is installed (<major>.<minor> only).

property version: runway.utils._version.Version

pip version.

classmethod dir_is_project(directory: StrPath, **kwargs: Any) bool[source]

Determine if the directory contains a project for this dependency manager.

Parameters

directory – Directory to check.

classmethod generate_install_command(*, cache_dir: Optional[StrPath] = None, no_cache_dir: bool = False, no_deps: bool = False, requirements: StrPath, target: StrPath) List[str][source]

Generate the command that when run will install dependencies.

This method is exposed to easily format the command to be run by with a subprocess or within a Docker container.

Parameters
  • cache_dir – Store the cache data in the provided directory.

  • no_cache_dir – Disable the cache.

  • no_deps – Don’t install package dependencies.

  • requirements – Path to a requirements.txt file.

  • target – Path to a directory where dependencies will be installed.

__init__(context: Union[CfnginContext, RunwayContext], cwd: StrPath) None

Instantiate class.

Parameters
  • context – CFNgin or Runway context object.

  • cwd – Working directory where commands will be run.

__new__(**kwargs)
static convert_to_cli_arg(arg_name: str, *, prefix: str = '--') str

Convert string kwarg name into a CLI argument.

classmethod found_in_path() bool

Determine if executable is found in $PATH.

install(*, cache_dir: Optional[StrPath] = None, extend_args: Optional[List[str]] = None, no_cache_dir: bool = False, no_deps: bool = False, requirements: StrPath, target: StrPath) Path[source]

Install dependencies to a target directory.

Parameters
  • cache_dir – Store the cache data in the provided directory.

  • extend_args – Optional list of extra arguments to pass to pip install. This value will not be parsed or sanitized in any way - it will be used as is. It is the user’s responsibility to ensure that there are no overlapping arguments between this list and the arguments that are automatically generated.

  • no_cache_dir – Disable the cache.

  • no_deps – Don’t install package dependencies.

  • requirements – Path to a requirements.txt file.

  • target – Path to a directory where dependencies will be installed.

Raises

PipInstallFailedError – The subprocess used to run the commend exited with an error.

static list2cmdline(split_command: Iterable[str]) str

Combine a list of strings into a string that can be run as a command.

Handles multi-platform differences.

ctx: Union[CfnginContext, RunwayContext]

CFNgin or Runway context object.

cwd: Path

Working directory where commands will be run.

classmethod generate_command(command: Union[List[str], str], **kwargs: Optional[Union[bool, Iterable[str], str]]) List[str][source]

Generate command to be executed and log it.

Parameters
  • command – Command to run.

  • args – Additional args to pass to the command.

Returns

The full command to be passed into a subprocess.

exception runway.dependency_managers.PipInstallFailedError[source]

Bases: runway.exceptions.RunwayError

Pip install failed.

__init__(*args: Any, **kwargs: Any) None[source]

Instantiate class. All args/kwargs are passed to parent method.

message: str

Error message.

__new__(**kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class runway.dependency_managers.Pipenv[source]

Bases: runway.dependency_managers.base_classes.DependencyManager

Pipenv dependency manager.

CONFIG_FILES: Final[Tuple[Literal['Pipfile'], Literal['Pipfile.lock']]] = ('Pipfile', 'Pipfile.lock')

Configuration files used by pipenv.

EXECUTABLE: Final[Literal['pipenv']] = 'pipenv'

CLI executable.

property version: runway.utils._version.Version

pipenv version.

__init__(context: Union[CfnginContext, RunwayContext], cwd: StrPath) None

Instantiate class.

Parameters
  • context – CFNgin or Runway context object.

  • cwd – Working directory where commands will be run.

__new__(**kwargs)
static convert_to_cli_arg(arg_name: str, *, prefix: str = '--') str

Convert string kwarg name into a CLI argument.

classmethod dir_is_project(directory: StrPath, **_Pipenv__kwargs: Any) bool[source]

Determine if the directory contains a project for this dependency manager.

Parameters

directory – Directory to check.

classmethod found_in_path() bool

Determine if executable is found in $PATH.

classmethod generate_command(command: Union[List[str], str], **kwargs: Optional[Union[bool, Iterable[str], str]]) List[str]

Generate command to be executed and log it.

Parameters
  • command – Command to run.

  • args – Additional args to pass to the command.

Returns

The full command to be passed into a subprocess.

static list2cmdline(split_command: Iterable[str]) str

Combine a list of strings into a string that can be run as a command.

Handles multi-platform differences.

ctx: Union[CfnginContext, RunwayContext]

CFNgin or Runway context object.

cwd: Path

Working directory where commands will be run.

export(*, dev: bool = False, output: StrPath) Path[source]

Export the lock file to other formats (requirements.txt only).

The underlying command being executed by this method is pipenv lock --requirements.

Parameters
  • dev – Include development dependencies.

  • output – Path to the output file.

exception runway.dependency_managers.PipenvExportFailedError[source]

Bases: runway.exceptions.RunwayError

Pipenv export failed to produce a requirements.txt file.

__init__(*args: Any, **kwargs: Any) None[source]

Instantiate class. All args/kwargs are passed to parent method.

message: str

Error message.

__new__(**kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception runway.dependency_managers.PipenvNotFoundError[source]

Bases: runway.exceptions.RunwayError

Pipenv not installed or found in $PATH.

__init__(*args: Any, **kwargs: Any) None[source]

Instantiate class. All args/kwargs are passed to parent method.

message: str

Error message.

__new__(**kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class runway.dependency_managers.Poetry[source]

Bases: runway.dependency_managers.base_classes.DependencyManager

Poetry dependency manager.

CONFIG_FILES: Final[Tuple[Literal['poetry.lock'], Literal['pyproject.toml']]] = ('poetry.lock', 'pyproject.toml')

Configuration files used by poetry.

EXECUTABLE: Final[Literal['poetry']] = 'poetry'

CLI executable.

property version: runway.utils._version.Version

poetry version.

__init__(context: Union[CfnginContext, RunwayContext], cwd: StrPath) None

Instantiate class.

Parameters
  • context – CFNgin or Runway context object.

  • cwd – Working directory where commands will be run.

__new__(**kwargs)
static convert_to_cli_arg(arg_name: str, *, prefix: str = '--') str

Convert string kwarg name into a CLI argument.

classmethod dir_is_project(directory: StrPath, **_Poetry__kwargs: Any) bool[source]

Determine if the directory contains a project for this dependency manager.

Parameters

directory – Directory to check.

classmethod found_in_path() bool

Determine if executable is found in $PATH.

classmethod generate_command(command: Union[List[str], str], **kwargs: Optional[Union[bool, Iterable[str], str]]) List[str]

Generate command to be executed and log it.

Parameters
  • command – Command to run.

  • args – Additional args to pass to the command.

Returns

The full command to be passed into a subprocess.

static list2cmdline(split_command: Iterable[str]) str

Combine a list of strings into a string that can be run as a command.

Handles multi-platform differences.

ctx: Union[CfnginContext, RunwayContext]

CFNgin or Runway context object.

cwd: Path

Working directory where commands will be run.

export(*, dev: bool = False, extras: Optional[List[str]] = None, output: StrPath, output_format: str = 'requirements.txt', with_credentials: bool = True, without_hashes: bool = True) Path[source]

Export the lock file to other formats.

Parameters
  • dev – Include development dependencies.

  • extras – Extra sets of dependencies to include.

  • output – Path to the output file.

  • output_format – The format to export to.

  • with_credentials – Include credentials for extra indices.

  • without_hashes – Exclude hashes from the exported file.

Returns

Path to the output file.

exception runway.dependency_managers.PoetryExportFailedError[source]

Bases: runway.exceptions.RunwayError

Poetry export failed to produce a requirements.txt file.

__init__(output: str, *args: Any, **kwargs: Any) None[source]

Instantiate class. All args/kwargs are passed to parent method.

Parameters

output – The output from running poetry export.

message: str

Error message.

__new__(**kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception runway.dependency_managers.PoetryNotFoundError[source]

Bases: runway.exceptions.RunwayError

Poetry not installed or found in $PATH.

__init__(*args: Any, **kwargs: Any) None[source]

Instantiate class. All args/kwargs are passed to parent method.

message: str

Error message.

__new__(**kwargs)
add_note()

Exception.add_note(note) – add a note to the exception

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Submodules