Command line interface#

pyproject2conda#

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 ...
pyproject2conda [OPTIONS] COMMAND [ARGS]...

Options

-v, --version#
Default:

False

--columns <columns>#

Column width in terminal. Set COLUMNS environment variable to this value

--install-completion#

Install completion for the current shell.

--show-completion#

Show completion for the current shell, to copy it or customize the installation.

Environment variables

P2C_COLUMNS

Provide a default for --columns

list#

List available extras.

pyproject2conda list [OPTIONS]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

yaml#

Create yaml file from dependencies and optional-dependencies.

pyproject2conda yaml [OPTIONS]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

-e, --extra <extras>#

Include dependencies from extra <extra> from project.optional-dependencies table of pyproject.toml. Can specify multiple times for multiple extras. Use name extras for specifying in pyproject.toml

-g, --group <groups>#

Include dependencies from group <group> from dependency-groups table of pyproject.toml. Can specify multiple times for multiple groups. Use name groups for specifying in pyproject.toml

--extra-or-group <extras_or_groups>#

Include dependencies from extra or group of pyproject.toml. Extras are checked first, followed by groups. The first instance of extra-or-group found is used. That is, if both extras and groups contain extra-or-group, the extra will be used. Use name extras-or-groups for specifying in pyproject.toml

-c, --channel <channels>#

Conda channel. Can specify. Overrides [tool.pyproject2conda.channels]

-o, --output <output>#

File to output results

-n, --name <name>#

Name of conda env

--python-include <python_include>#

If value passed, use this value (exactly) in the output. So, for example, pass --python-include "python=3.8". Special case is the value "infer". This infers the value of python from pyproject.toml

--python-version <python_version>#

Python version to check python_version <=> {python_version} lines against. That is, this version is used to limit packages in resulting output. For example, if have a line like a-package; python_version < '3.9', Using --python-version 3.10 will not include a-package, while --python-version 3.8 will include a-package.

-p, --python <python>#

python version. passing --python {version} is equivalent to passing --python-version={version} --python-include=python{version}. if passed, this overrides values of passed via --python-version and --python-include. pass --python="default" to include the python version (major.minor only) from, in order, .python-version-default or .python-version``file in the current directory. pass ``"lowest" or "highest" to include the lowest or highest python version, respectively, from pyproject.toml:project.classifiers table. in project mode, you can pass multiple python version in pyproject.toml with, e.g., python = ["3.8", "3.9", ....], or using python = "all", to include all python versions extracted from pyproject.toml:project.classifiers table.

--skip-package#

Default is to include package dependencies from project.dependencies table of pyproject.toml. Passing --skip-package (or skip_package = true in tool.pyproject2conda.envs... table of pyproject.toml) will exclude the package dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

False

--pip-only#

Treat all requirements as pip requirements. Use option pip_only in pyproject.toml

Default:

False

--sort, --no-sort#

Default is to sort the dependencies (excluding --python-include). Pass --no-sort to instead place dependencies in order they are gathered. Use option sort = true/false in pyproject.toml

Default:

True

--header, --no-header#

If True (–header) include header line in output. Default is to include the header for output to a file, and not to include header when writing to stdout.

--custom-command <custom_command>#

Custom command to place in header. Implies --header.

-w, --overwrite <overwrite>#

What to do if output file exists. (check): Create if missing. If output exists and passed --filename is newer, recreate output, else skip. (skip): If output exists, skip. (force): force: force recreate output.

Default:

<Overwrite.force: 'force'>

Options:

check | skip | force

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

-d, --deps <deps>#

Additional conda dependencies.

-r, --reqs <reqs>#

Additional pip requirements. For example, pass -r '-e .' to included editable version of current package in requirements file.

--allow-empty, --no-allow-empty#

What to do if there are no package requirements for an environment. The default (--no-allow-empty) is to raise an error if the specification leads to no requirements. Passing --allow-empty will lead to a message being printed, but no environment file being created.

Default:

False

--remove-whitespace, --no-remove-whitespace#

What to do with whitespace in a dependency. Passing --remove-whitespace will remove whitespace in a given dependency. For example, the dependency package >= 1.0 will be converted to package>=1.0. Pass --no-remove-whitespace to keep the the whitespace in the output.

Default:

True

requirements#

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

pyproject2conda requirements [OPTIONS]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

-e, --extra <extras>#

Include dependencies from extra <extra> from project.optional-dependencies table of pyproject.toml. Can specify multiple times for multiple extras. Use name extras for specifying in pyproject.toml

-g, --group <groups>#

Include dependencies from group <group> from dependency-groups table of pyproject.toml. Can specify multiple times for multiple groups. Use name groups for specifying in pyproject.toml

--extra-or-group <extras_or_groups>#

Include dependencies from extra or group of pyproject.toml. Extras are checked first, followed by groups. The first instance of extra-or-group found is used. That is, if both extras and groups contain extra-or-group, the extra will be used. Use name extras-or-groups for specifying in pyproject.toml

-o, --output <output>#

File to output results

--skip-package#

Default is to include package dependencies from project.dependencies table of pyproject.toml. Passing --skip-package (or skip_package = true in tool.pyproject2conda.envs... table of pyproject.toml) will exclude the package dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

False

--sort, --no-sort#

Default is to sort the dependencies (excluding --python-include). Pass --no-sort to instead place dependencies in order they are gathered. Use option sort = true/false in pyproject.toml

Default:

True

--header, --no-header#

If True (–header) include header line in output. Default is to include the header for output to a file, and not to include header when writing to stdout.

--custom-command <custom_command>#

Custom command to place in header. Implies --header.

-w, --overwrite <overwrite>#

What to do if output file exists. (check): Create if missing. If output exists and passed --filename is newer, recreate output, else skip. (skip): If output exists, skip. (force): force: force recreate output.

Default:

<Overwrite.force: 'force'>

Options:

check | skip | force

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

-r, --reqs <reqs>#

Additional pip requirements. For example, pass -r '-e .' to included editable version of current package in requirements file.

--allow-empty, --no-allow-empty#

What to do if there are no package requirements for an environment. The default (--no-allow-empty) is to raise an error if the specification leads to no requirements. Passing --allow-empty will lead to a message being printed, but no environment file being created.

Default:

False

--remove-whitespace, --no-remove-whitespace#

What to do with whitespace in a dependency. Passing --remove-whitespace will remove whitespace in a given dependency. For example, the dependency package >= 1.0 will be converted to package>=1.0. Pass --no-remove-whitespace to keep the the whitespace in the output.

Default:

False

project#

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. You can replace dashes with underscores if you wish, but if you do so, replace all dashes with underscores. 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 project [OPTIONS]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

--envs <envs>#

List of environments to build files for. Default to building all environments

--template <template>#

Template for environments that do not have a python version. Defaults to {env}.

--template-python <template_python>#

Template for environments that do have a python version. Defaults to “py{py}-{env}”. For example, with --template-python="py{py}-{env}" and --python=3.8 and environment “dev”, output would be “py38-dev” | * {py} -> “38” | * {py_version} -> “3.8” | * {env} -> “dev”

-r, --reqs <reqs>#

Additional pip requirements. For example, pass -r '-e .' to included editable version of current package in requirements file.

-d, --deps <deps>#

Additional conda dependencies.

--reqs-ext <reqs_ext>#

Extension to use with requirements file output created from template. Defaults to ".txt".

Default:

'.txt'

--yaml-ext <yaml_ext>#

Extension to use with conda environment.yaml file output created from template. Defaults to ".yaml"

Default:

'.yaml'

--sort, --no-sort#

Default is to sort the dependencies (excluding --python-include). Pass --no-sort to instead place dependencies in order they are gathered. Use option sort = true/false in pyproject.toml

Default:

True

--header, --no-header#

If True (–header) include header line in output. Default is to include the header for output to a file, and not to include header when writing to stdout.

--custom-command <custom_command>#

Custom command to place in header. Implies --header.

-w, --overwrite <overwrite>#

What to do if output file exists. (check): Create if missing. If output exists and passed --filename is newer, recreate output, else skip. (skip): If output exists, skip. (force): force: force recreate output.

Default:

<Overwrite.force: 'force'>

Options:

check | skip | force

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

--dry#

If passed, do a dry run

Default:

False

--pip-only#

Treat all requirements as pip requirements. Use option pip_only in pyproject.toml

Default:

False

--user-config <user_config>#

Additional toml file to supply configuration. This can be used to override/add environment files for your own use (apart from project env files). The (default) value infer means to infer the configuration from --filename.

Default:

'infer'

--allow-empty, --no-allow-empty#

What to do if there are no package requirements for an environment. The default (--no-allow-empty) is to raise an error if the specification leads to no requirements. Passing --allow-empty will lead to a message being printed, but no environment file being created.

--remove-whitespace, --no-remove-whitespace#

What to do with whitespace in a dependency. Passing --remove-whitespace will remove whitespace in a given dependency. For example, the dependency package >= 1.0 will be converted to package>=1.0. Pass --no-remove-whitespace to keep the the whitespace in the output.

conda-requirements#

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 conda-requirements [OPTIONS] [PATH_CONDA] [PATH_PIP]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

-e, --extra <extras>#

Include dependencies from extra <extra> from project.optional-dependencies table of pyproject.toml. Can specify multiple times for multiple extras. Use name extras for specifying in pyproject.toml

-g, --group <groups>#

Include dependencies from group <group> from dependency-groups table of pyproject.toml. Can specify multiple times for multiple groups. Use name groups for specifying in pyproject.toml

--extra-or-group <extras_or_groups>#

Include dependencies from extra or group of pyproject.toml. Extras are checked first, followed by groups. The first instance of extra-or-group found is used. That is, if both extras and groups contain extra-or-group, the extra will be used. Use name extras-or-groups for specifying in pyproject.toml

--python-include <python_include>#

If value passed, use this value (exactly) in the output. So, for example, pass --python-include "python=3.8". Special case is the value "infer". This infers the value of python from pyproject.toml

--python-version <python_version>#

Python version to check python_version <=> {python_version} lines against. That is, this version is used to limit packages in resulting output. For example, if have a line like a-package; python_version < '3.9', Using --python-version 3.10 will not include a-package, while --python-version 3.8 will include a-package.

-p, --python <python>#

python version. passing --python {version} is equivalent to passing --python-version={version} --python-include=python{version}. if passed, this overrides values of passed via --python-version and --python-include. pass --python="default" to include the python version (major.minor only) from, in order, .python-version-default or .python-version``file in the current directory. pass ``"lowest" or "highest" to include the lowest or highest python version, respectively, from pyproject.toml:project.classifiers table. in project mode, you can pass multiple python version in pyproject.toml with, e.g., python = ["3.8", "3.9", ....], or using python = "all", to include all python versions extracted from pyproject.toml:project.classifiers table.

-c, --channel <channels>#

Conda channel. Can specify. Overrides [tool.pyproject2conda.channels]

--skip-package#

Default is to include package dependencies from project.dependencies table of pyproject.toml. Passing --skip-package (or skip_package = true in tool.pyproject2conda.envs... table of pyproject.toml) will exclude the package dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

False

--prefix <prefix>#

set conda-output=prefix + ‘conda.txt’, pip-output=prefix + ‘pip.txt’

--prepend-channel#
Default:

False

--sort, --no-sort#

Default is to sort the dependencies (excluding --python-include). Pass --no-sort to instead place dependencies in order they are gathered. Use option sort = true/false in pyproject.toml

Default:

True

--header, --no-header#

If True (–header) include header line in output. Default is to include the header for output to a file, and not to include header when writing to stdout.

--custom-command <custom_command>#

Custom command to place in header. Implies --header.

-d, --deps <deps>#

Additional conda dependencies.

-r, --reqs <reqs>#

Additional pip requirements. For example, pass -r '-e .' to included editable version of current package in requirements file.

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

Arguments

PATH_CONDA#

Optional argument

PATH_PIP#

Optional argument

json#

Create json representation.

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

pyproject2conda json [OPTIONS]

Options

-f, --pyproject-file, --file <pyproject_filename>#

input pyproject.toml file

Default:

'pyproject.toml'

-e, --extra <extras>#

Include dependencies from extra <extra> from project.optional-dependencies table of pyproject.toml. Can specify multiple times for multiple extras. Use name extras for specifying in pyproject.toml

-g, --group <groups>#

Include dependencies from group <group> from dependency-groups table of pyproject.toml. Can specify multiple times for multiple groups. Use name groups for specifying in pyproject.toml

--extra-or-group <extras_or_groups>#

Include dependencies from extra or group of pyproject.toml. Extras are checked first, followed by groups. The first instance of extra-or-group found is used. That is, if both extras and groups contain extra-or-group, the extra will be used. Use name extras-or-groups for specifying in pyproject.toml

--python-include <python_include>#

If value passed, use this value (exactly) in the output. So, for example, pass --python-include "python=3.8". Special case is the value "infer". This infers the value of python from pyproject.toml

--python-version <python_version>#

Python version to check python_version <=> {python_version} lines against. That is, this version is used to limit packages in resulting output. For example, if have a line like a-package; python_version < '3.9', Using --python-version 3.10 will not include a-package, while --python-version 3.8 will include a-package.

-p, --python <python>#

python version. passing --python {version} is equivalent to passing --python-version={version} --python-include=python{version}. if passed, this overrides values of passed via --python-version and --python-include. pass --python="default" to include the python version (major.minor only) from, in order, .python-version-default or .python-version``file in the current directory. pass ``"lowest" or "highest" to include the lowest or highest python version, respectively, from pyproject.toml:project.classifiers table. in project mode, you can pass multiple python version in pyproject.toml with, e.g., python = ["3.8", "3.9", ....], or using python = "all", to include all python versions extracted from pyproject.toml:project.classifiers table.

-c, --channel <channels>#

Conda channel. Can specify. Overrides [tool.pyproject2conda.channels]

--sort, --no-sort#

Default is to sort the dependencies (excluding --python-include). Pass --no-sort to instead place dependencies in order they are gathered. Use option sort = true/false in pyproject.toml

Default:

True

-o, --output <output>#

File to output results

--skip-package#

Default is to include package dependencies from project.dependencies table of pyproject.toml. Passing --skip-package (or skip_package = true in tool.pyproject2conda.envs... table of pyproject.toml) will exclude the package dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

False

-d, --deps <deps>#

Additional conda dependencies.

-r, --reqs <reqs>#

Additional pip requirements. For example, pass -r '-e .' to included editable version of current package in requirements file.

-v, --verbose#

Pass -v/--verbose for verbose output. Pass multiple times to set verbosity level.

-w, --overwrite <overwrite>#

What to do if output file exists. (check): Create if missing. If output exists and passed --filename is newer, recreate output, else skip. (skip): If output exists, skip. (force): force: force recreate output.

Default:

<Overwrite.force: 'force'>

Options:

check | skip | force