Console script for pyproject2conda (cli
)#
Classes:
|
Provide aliasing for commands |
|
Options for |
Functions:
|
Extract conda |
|
List available extras. |
|
Create yaml file from dependencies and optional-dependencies. |
|
Create requirements.txt for pip dependencies. |
|
Create multiple environment files from |
|
Create requirement files for conda and pip. |
|
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 returnsNone
.list_commands
(ctx)Returns a list of subcommand names.
- get_command(ctx: click.Context, cmd_name: str) click.Command | None [source]#
Given a context and a command name, this returns a
Command
object if it exists or returnsNone
.
- pyproject2conda.cli.main(version: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168ce0d0>] = False, columns: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168ce490>] = None) None [source]#
Extract conda
environment.yaml
and piprequirement.txt
files frompyproject.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 yaml ...
- pyproject2conda.cli.create_list(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = None) None [source]#
List available extras.
- pyproject2conda.cli.yaml(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0690>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0910>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0b90>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0cd0>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x1168a0f50>] = None, name: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a0e10>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a16d0>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1810>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1950>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1310>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1450>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1590>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a1a90>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1bd0>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x1168a1090>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1d10>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1e50>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a2ad0>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a2c10>] = True) None [source]#
Create yaml file from dependencies and optional-dependencies.
- pyproject2conda.cli.requirements(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0690>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0910>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0b90>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x1168a0f50>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1310>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1590>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a1a90>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1bd0>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x1168a1090>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1e50>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a2ad0>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a2c10>] = False) None [source]#
Create requirements.txt for pip dependencies. Note that all requirements are normalized using
packaging.requirements.Requirement
- pyproject2conda.cli.project(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], envs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1f90>] = None, template: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a20d0>] = None, template_python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a2210>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1e50>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1d10>] = None, reqs_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a2350>] = '.txt', yaml_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a2490>] = '.yaml', sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1590>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a1a90>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1bd0>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x1168a1090>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = None, dry: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a25d0>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1450>] = False, user_config: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a2710>] = 'infer', allow_empty: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a2ad0>] = None, remove_whitespace: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a2c10>] = None) None [source]#
Create multiple environment files from
pyproject.toml
specification.Note that if you specify options in
pyproject.toml
, the name is usually the same as the command line option. For cases where the option can take multiple values, the config file option will be plural. For example, the command line option--group
becomes the config file optiongroups = ...
. Boolean options like--sort/--no-sort
becomesort = true/false
in the config file.
- pyproject2conda.cli.conda_requirements(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], path_conda: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x1168ccf50>] = None, path_pip: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x1168cce10>] = None, extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0690>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0910>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0b90>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a16d0>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1810>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1950>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0cd0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1310>] = False, prefix: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a2850>] = None, prepend_channel: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a2990>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1590>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x1168a1a90>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1bd0>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1d10>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1e50>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = 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(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x1168a0550>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0690>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0910>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0b90>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a16d0>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1810>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x1168a1950>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a0cd0>] = None, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1590>] = True, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x1168a0f50>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x1168a1310>] = False, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1d10>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x1168a1e50>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x1168a11d0>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x1168a1090>] = Overwrite.force) None [source]#
Create json representation.
Keys are: “dependencies”: conda dependencies. “pip”: pip dependencies. “channels”: conda channels.