Console script for pyproject2conda (cli)#

Functions:

main(version, ] = False, columns, ] = None)

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

create_list(pyproject_filename, ], verbose, ...)

List available extras.

yaml(pyproject_filename, ], extras, ...)

Create yaml file from dependencies and optional-dependencies.

requirements(pyproject_filename, ], extras, ...)

Create requirements.txt for pip dependencies.

project(pyproject_filename, ], envs, ...)

Create multiple environment files from pyproject.toml specification.

conda_requirements(pyproject_filename, ], ...)

Create requirement files for conda and pip.

to_json(pyproject_filename, ], extras, ...)

Create json representation.

Classes:

Overwrite(*values)

Options for --overwrite

pyproject2conda.cli.main(version: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16ad5590>] = False, columns: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16ad5450>] = None) 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 yaml ...
class pyproject2conda.cli.Overwrite(*values)[source]#

Bases: str, Enum

Options for --overwrite

pyproject2conda.cli.create_list(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x7fbb16bd96d0>], verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = None) None[source]#

List available extras.

pyproject2conda.cli.yaml(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x7fbb16bd96d0>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9810>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9a90>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9d10>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9e50>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x7fbb16bda0d0>] = None, name: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bd9f90>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda850>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda990>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdaad0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda490>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda5d0>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda710>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdac10>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdad50>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x7fbb16bda210>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdae90>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdafd0>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdbc50>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdbd90>] = 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 0x7fbb16bd96d0>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9810>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9a90>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9d10>] = None, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x7fbb16bda0d0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda490>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda710>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdac10>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdad50>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x7fbb16bda210>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdafd0>] = None, allow_empty: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdbc50>] = False, remove_whitespace: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdbd90>] = 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 0x7fbb16bd96d0>], envs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdb110>] = None, template: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb250>] = None, template_python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb390>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdafd0>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdae90>] = None, reqs_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb4d0>] = '.txt', yaml_ext: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb610>] = '.yaml', sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda710>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdac10>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdad50>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x7fbb16bda210>] = Overwrite.force, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = None, dry: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdb750>] = False, pip_only: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda5d0>] = False, user_config: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb890>] = 'infer', allow_empty: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdbc50>] = None, remove_whitespace: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdbd90>] = 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 option groups = .... Boolean options like --sort/--no-sort become sort = true/false in the config file.

pyproject2conda.cli.conda_requirements(pyproject_filename: ~typing.Annotated[~pathlib.Path, <typer.models.OptionInfo object at 0x7fbb16bd96d0>], path_conda: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x7fbb16464f50>] = None, path_pip: ~typing.Annotated[str | None, <typer.models.ArgumentInfo object at 0x7fbb16465bd0>] = None, extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9810>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9a90>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9d10>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda850>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda990>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdaad0>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9e50>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda490>] = False, prefix: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdb9d0>] = None, prepend_channel: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bdbb10>] = False, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda710>] = True, header: ~typing.Annotated[bool | None, <typer.models.OptionInfo object at 0x7fbb16bdac10>] = None, custom_command: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdad50>] = None, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdae90>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdafd0>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = 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 0x7fbb16bd96d0>], extras: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9810>] = None, groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9a90>] = None, extras_or_groups: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9d10>] = None, python_include: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda850>] = None, python_version: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bda990>] = None, python: ~typing.Annotated[str | None, <typer.models.OptionInfo object at 0x7fbb16bdaad0>] = None, channels: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bd9e50>] = None, sort: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda710>] = True, output: ~typing.Annotated[~pathlib.Path | None, <typer.models.OptionInfo object at 0x7fbb16bda0d0>] = None, skip_package: ~typing.Annotated[bool, <typer.models.OptionInfo object at 0x7fbb16bda490>] = False, deps: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdae90>] = None, reqs: ~typing.Annotated[list[str] | None, <typer.models.OptionInfo object at 0x7fbb16bdafd0>] = None, verbose: ~typing.Annotated[int | None, <typer.models.OptionInfo object at 0x7fbb16bda350>] = None, overwrite: ~typing.Annotated[~pyproject2conda.cli.Overwrite, <typer.models.OptionInfo object at 0x7fbb16bda210>] = Overwrite.force) None[source]#

Create json representation.

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