Console script for pyproject2conda (cli)#

Classes:

AliasedGroup(*[, name, commands, ...])

Provide aliasing for commands

Overwrite(value[, names, module, qualname, ...])

Options for --overwrite

Functions:

version_callback(value)

Versioning call back.

main(version)

Extract conda environment.yaml and pip requirement.txt files from pyproject.toml

create_list(filename, ] = PosixPath, ...)

List available extras.

yaml(filename, ] = PosixPath, extras, ...)

Create yaml file from dependencies and optional-dependencies.

requirements(filename, ] = PosixPath, ...)

Create requirements.txt for pip dependencies.

project(filename, ] = PosixPath, envs, ...)

Create multiple environment files from pyproject.toml specification.

conda_requirements(path_conda, ] = None, ...)

Create requirement files for conda and pip.

to_json(extras, ] = None, groups, ] = None, ...)

Create json representation.

class pyproject2conda.cli.AliasedGroup(*, name: str | None = None, commands: Dict[str, Command] | Sequence[Command] | None = None, rich_markup_mode: Literal['markdown', 'rich', None] = 'rich', rich_help_panel: str | None = None, **attrs: Any) None[source]#

Bases: TyperGroup

Provide aliasing for commands

Methods:

get_command(ctx, cmd_name)

Given a context and a command name, this returns a Command object if it exists or returns None.

list_commands(ctx)

Returns a list of subcommand names.

get_command(ctx: Context, cmd_name: str) Command | None[source]#

Given a context and a command name, this returns a Command object if it exists or returns None.

list_commands(ctx: Context) List[str][source]#

Returns a list of subcommand names. Note that in Click’s Group class, these are sorted. In Typer, we wish to maintain the original order of creation (cf Issue #933)

pyproject2conda.cli.version_callback(value: bool) None[source]#

Versioning call back.

pyproject2conda.cli.main(version: bool = <typer.models.OptionInfo object>) None[source]#

Extract conda environment.yaml and pip requirement.txt files from pyproject.toml

Note that all subcommands can be called with shortest possible match. Also, you can call with any of pyproject2conda, p2c, python -m pyproject2conda. For example,

# these are equivalent
$ pyproject2conda yaml ...
$ p2c y ...
$ python -m pyproject2conda ...
class pyproject2conda.cli.Overwrite(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: str, Enum

Options for –overwrite

pyproject2conda.cli.create_list(filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None) None[source]#

List available extras.

pyproject2conda.cli.yaml(filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), extras: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b890>] = None, groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8ba10>] = None, extras_or_groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b920>] = None, channels: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8bc80>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x111b8bbf0>] = None, name: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111b8bb60>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac110>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac1d0>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac290>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bec0>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bf80>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bac050>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bac380>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac440>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x111b8bda0>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None, deps: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac500>] = None, reqs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac5f0>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacda0>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacdd0>] = True) None[source]#

Create yaml file from dependencies and optional-dependencies.

pyproject2conda.cli.requirements(filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), extras: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b890>] = None, groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8ba10>] = None, extras_or_groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b920>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x111b8bbf0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bec0>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bac050>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bac380>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac440>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x111b8bda0>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None, reqs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac5f0>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacda0>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacdd0>] = False) None[source]#

Create requirements.txt for pip dependencies. Note that all requirements are normalized using packaging.requirements.Requirement

pyproject2conda.cli.project(filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), envs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac6e0>] = None, template: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac7a0>] = None, template_python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac860>] = None, reqs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac5f0>] = None, deps: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac500>] = None, reqs_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac920>] = '.txt', yaml_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac9e0>] = '.yaml', sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bac050>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bac380>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac440>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x111b8bda0>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None, dry: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacaa0>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bf80>] = False, user_config: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bacb60>] = 'infer', allow_empty: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bacda0>] = None, remove_whitespace: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bacdd0>] = None) None[source]#

Create multiple environment files from pyproject.toml specification.

pyproject2conda.cli.conda_requirements(path_conda: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x111bad9d0>] = None, path_pip: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x111bada60>] = None, extras: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b890>] = None, groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8ba10>] = None, extras_or_groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b920>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac110>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac1d0>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac290>] = None, channels: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8bc80>] = None, filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bec0>] = False, prefix: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bacc20>] = None, prepend_channel: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bacce0>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bac050>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x111bac380>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac440>] = None, deps: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac500>] = None, reqs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac5f0>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None) None[source]#

Create requirement files for conda and pip.

These can be install with, for example,

conda install –file {path_conda} pip install -r {path_pip}

pyproject2conda.cli.to_json(extras: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b890>] = None, groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8ba10>] = None, extras_or_groups: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8b920>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac110>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac1d0>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x111bac290>] = None, channels: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111b8bc80>] = None, filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x110909af0>] = PosixPath('pyproject.toml'), sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111bac050>] = True, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x111b8bbf0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x111b8bec0>] = False, deps: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac500>] = None, reqs: ~typing.Annotated[~typing.List[str] | None, <typer.models.OptionInfo object at 0x111bac5f0>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x111b8bce0>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x111b8bda0>] = Overwrite.force) None[source]#

Create json representation.

Keys are: “dependencies”: conda dependencies. “pip”: pip dependencies. “channels”: conda channels.