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

Options

-v, --version#
--install-completion#

Install completion for the current shell.

--show-completion#

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

list#

List available extras.

pyproject2conda list [OPTIONS]

Options

-f, --file <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, --file <filename>#

input pyproject.toml file

Default:

pyproject.toml

-e, --extra <extras>#

Extra dependencies. Can specify multiple times for multiple extras.

-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_verion <=> {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.

--base, --no-base#

Default is to include base (project.dependencies) with extras. However, passing –no-base will exclude base dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

True

--sort, --no-sort#

Default is to sort the dependencies (excluding –python-include). Pass –no-sort to instead place dependencies in order they are gathered.

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.

-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.check

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.

--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

requirements#

Create requirements.txt for pip dependencies.

pyproject2conda requirements [OPTIONS]

Options

-f, --file <filename>#

input pyproject.toml file

Default:

pyproject.toml

-e, --extra <extras>#

Extra dependencies. Can specify multiple times for multiple extras.

-o, --output <output>#

File to output results

--base, --no-base#

Default is to include base (project.dependencies) with extras. However, passing –no-base will exclude base dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

True

--sort, --no-sort#

Default is to sort the dependencies (excluding –python-include). Pass –no-sort to instead place dependencies in order they are gathered.

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.

-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.check

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.

--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

project#

Create multiple environment files from pyproject.toml specification.

pyproject2conda project [OPTIONS]

Options

-f, --file <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”

--sort, --no-sort#

Default is to sort the dependencies (excluding –python-include). Pass –no-sort to instead place dependencies in order they are gathered.

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.

-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.check

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

--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.

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

-e, --extra <extras>#

Extra dependencies. Can specify multiple times for multiple extras.

--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_verion <=> {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.

-c, --channel <channels>#

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

-f, --file <filename>#

input pyproject.toml file

Default:

pyproject.toml

--base, --no-base#

Default is to include base (project.dependencies) with extras. However, passing –no-base will exclude base dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

True

--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.

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.

-d, --deps <deps>#

Additional conda dependencies.

-r, --reqs <reqs>#

Additional pip requirements.

-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

-e, --extra <extras>#

Extra dependencies. Can specify multiple times for multiple extras.

--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_verion <=> {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.

-c, --channel <channels>#

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

-f, --file <filename>#

input pyproject.toml file

Default:

pyproject.toml

--sort, --no-sort#

Default is to sort the dependencies (excluding –python-include). Pass –no-sort to instead place dependencies in order they are gathered.

Default:

True

-o, --output <output>#

File to output results

--base, --no-base#

Default is to include base (project.dependencies) with extras. However, passing –no-base will exclude base dependencies. This is useful to define environments that should exclude base dependencies (like build, etc) in pyproject.toml.

Default:

True

-d, --deps <deps>#

Additional conda dependencies.

-r, --reqs <reqs>#

Additional pip requirements.

-v, --verbose#

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