Name | conda-lock JSON |
Version |
2.5.7
JSON |
| download |
home_page | None |
Summary | Lockfiles for conda |
upload_time | 2024-04-26 18:39:26 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# conda-lock
[](https://conda.github.io/conda-lock/)
[](https://pypi.org/project/conda-lock/)
[](https://github.com/conda-forge/conda-lock-feedstock)
[](https://results.pre-commit.ci/latest/github/conda/conda-lock/main)
[](https://codecov.io/gh/conda/conda-lock)
Conda lock is a lightweight library that can be used to generate fully reproducible lock files for [conda][conda]
environments.
It does this by performing a conda solve for each platform you desire a lockfile for.
This also has the added benefit of acting as an external pre-solve for conda as the lockfiles it generates
results in the conda solver *not* being invoked when installing the packages from the generated lockfile.
## Why?
Conda [`environment.yml`][envyaml] files are very useful for defining desired environments but there are times when we want to
be able to EXACTLY reproduce an environment by just installing and downloading the packages needed.
This is particularly handy in the context of a gitops style setup where you use conda to provision environments in
various places.
## Installation
Use *one* of the following commands:
```bash
pipx install conda-lock
condax install conda-lock
pip install conda-lock
conda install --channel=conda-forge --name=base conda-lock
mamba install --channel=conda-forge --name=base conda-lock
```
The first two options are recommended since they install conda-lock into an isolated environment. (Otherwise there is a risk of dependency conflicts.)
## Contributing
If you would like to contribute to conda-lock, please refer to the [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up your development environment.
## Basic usage
```bash
# generate a multi-platform lockfile
conda-lock -f environment.yml -p osx-64 -p linux-64
# optionally, update the previous solution, using the latest version of
# pydantic that is compatible with the source specification
conda-lock --update pydantic
# create an environment from the lockfile
conda-lock install [-p {prefix}|-n {name}]
# alternatively, render a single-platform lockfile and use conda command directly
conda-lock render -p linux-64
conda create -n my-locked-env --file conda-linux-64.lock
```
### Pre 1.0 compatible usage (explicit per platform locks)
If you were making use of conda-lock before the 1.0 release that added unified lockfiles
you can still get that behaviour by making use of the `explicit` output kind.
```bash
conda-lock --kind explicit -f environment.yml
```
## Advanced usage
### File naming
By default, `conda-lock` store its output in `conda-lock.yml` in the current
working directory. This file will also be used by default for render, install,
and update operations. You can supply a different filename with e.g.
```bash
conda-lock --lockfile superspecial.conda-lock.yml
```
Rendered `explicit` and `env` lockfiles will be named as `"conda-{platform}.lock"` and `"conda-{platform}.lock.yml` respectively by default.
If you want to override that call conda-lock as follows.
```bash
conda-lock -k explicit --filename-template "specific-{platform}.conda.lock"
```
### Compound specification
Conda-lock will build a spec list from several files if requested.
```bash
conda-lock -f base.yml -f specific.yml -p linux-64 -k explicit --filename-template "specific-{platform}.lock"
````
In this case all dependencies are combined, and the ordered union of all `channels` is used as the final
specification.
This works for all supported file types.
#### channel overrides
You can override the channels that are used by conda-lock in case you need to override the ones specified in
an [environment.yml][envyaml]
```bash
conda-lock -c conda-forge -p linux-64
```
#### platform specification
You may specify the platforms you wish to target by default directly in an [environment.yml][envyaml] using the (nonstandard) `platforms` key:
```yaml
# environment.yml
channels:
- conda-forge
dependencies:
- python=3.9
- pandas
platforms:
- linux-64
- osx-64
- win-64
- osx-arm64 # For Apple Silicon, e.g. M1/M2
- linux-aarch64 # aka arm64, use for Docker on Apple Silicon
- linux-ppc64le
```
If you specify target platforms on the command line with `-p`, these will
override the values in the environment specification. If neither `platforms` nor
`-p` are provided, `conda-lock` will fall back to a default set of platforms.
#### default category
You can may wish to split your dependencies into separate files for better
organization, e.g. a `environment.yml` for production dependencies and a
`dev-environment.yml` for development dependencies. You can assign all the
dependencies parsed from a single file to a category using the (nonstandard)
`category` key.
```yaml
# dev-environment.yml
channels:
- conda-forge
dependencies:
- pytest
- mypy=0.910
category: dev
```
The default category is `main`.
### pip support
`conda-lock` can also lock the `dependencies.pip` section of
[environment.yml][envyaml], using a vendored copy of [Poetry's][poetry] dependency solver.
### private pip repositories
Right now `conda-lock` only supports [legacy](https://warehouse.pypa.io/api-reference/legacy.html) pypi repos with basic auth. Most self-hosted repositories like Nexus, Artifactory etc. use this. You can configure private pip repositories in a similar way to channels, for example:
```yaml
channels:
- conda-forge
pip-repositories:
- http://$PIP_USER:$PIP_PASSWORD@private-pypi.org/api/pypi/simple
dependencies:
- python=3.11
- requests=2.26
- pip:
- fake-private-package==1.0.0
```
See [the related docs for private channels](./docs/authenticated_channels.md#what_gets_stored) to understand the rules regarding environment variable substitution.
Alternatively, you can use the `poetry` configuration file format to configure private PyPi repositories. The configuration file should be named `config.toml` and have the following format:
```toml
[repositories.example]
url = "https://username:password@example.repo/simple"
```
The location of this file can be determined with `python -c 'from conda_lock._vendor.poetry.locations import CONFIG_DIR; print(CONFIG_DIR)'`
Private repositories will be used in addition to `pypi.org`. For projects using `pyproject.toml`, it is possible to [disable `pypi.org` entirely](#disabling-pypiorg).
### --dev-dependencies/--no-dev-dependencies
By default conda-lock will include dev dependencies in the specification of the lock (if the files that the lock
is being built from support them). This can be disabled easily
```bash
conda-lock --no-dev-dependencies -f ./recipe/meta.yaml
```
### --check-input-hash
Under some situation you may want to run conda lock in some kind of automated way (eg as a precommit) and want to not
need to regenerate the lockfiles if the underlying input specification for that particular lock as not changed.
```bash
conda-lock --check-input-hash -p linux-64
```
When the input_hash of the input files, channels match those present in a given lockfile, that lockfile will not be regenerated.
### --strip-auth, --auth and --auth-file
By default `conda-lock` will leave basic auth credentials for private conda channels in the lock file. If you wish to strip authentication from the file, provide the `--strip-auth` argument.
```shell
conda-lock --strip-auth -f environment.yml
```
In order to `conda-lock install` a lock file with its basic auth credentials stripped, you will need to create an authentication file in `.json` format like this:
```json
{
"domain": "username:password"
}
```
If you have multiple channels that require different authentication within the same domain, you can additionally specify the channel like this:
```json
{
"domain.org/channel1": "username1:password1",
"domain.org/channel2": "username2:password2"
}
```
You can provide the authentication either as string through `--auth` or as a filepath through `--auth-file`.
```bash
conda-lock install --auth-file auth.json conda-linux-64.lock
```
### --virtual-package-spec
Conda makes use of [virtual packages](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html) that are available at
runtime to gate dependency on system features. Due to these not generally existing on your local execution platform conda-lock will inject
them into the solution environment with a reasonable guess at what a default system configuration should be.
If you want to override which virtual packages are injected you can create a file like
```yaml
# virtual-packages.yml
subdirs:
linux-64:
packages:
__glibc: "2.17"
__cuda: "11.4"
win-64:
packages:
__cuda: "11.4"
```
conda-lock will automatically use a `virtual-packages.yml` it finds in the the current working directory. Alternatively one can be specified
explicitly via the flag.
```bash
conda lock --virtual-package-spec virtual-packages-cuda.yml -p linux-64
```
#### Input hash stability
Virtual packages take part in the input hash so if you build an environment with a different set of virtual packages the input hash will change.
Additionally the default set of virtual packages may be augmented in future versions of conda-lock. If you desire very stable input hashes
we recommend creating a `virtual-packages.yml` file to lock down the virtual packages considered.
#### ⚠️ in conjunction with micromamba
Micromamba does not presently support some of the overrides to remove all discovered virtual packages, consequently the set of virtual packages
available at solve time may be larger than those specified in your specification.
## Supported file sources
Conda lock supports more than just [environment.yml][envyaml] specifications!
Additionally conda-lock supports [meta.yaml][metayaml] (conda-build)
and `pyproject.toml` (
[flit](https://flit.readthedocs.io/en/latest/), [pdm](https://pdm.fming.dev) and
[poetry](https://python-poetry.org) based). These do come with some gotchas but
are generally good enough for the 90% use-case.
### meta.yaml
Conda-lock will attempt to make an educated guess at the desired environment spec in a meta.yaml. This is
not guaranteed to work for complex recipes with many selectors and outputs. For multi-output recipes, conda-lock
will fuse all the dependencies together. If that doesn't work for your case fall back to specifying the specification
as an [environment.yml][envyaml]
Since a meta.yaml doesn't contain channel information we make use of the following extra key to specify channels
```yaml
# meta.yaml
extra:
channels:
- conda-forge
- defaults
```
### pyproject.toml
Since `pyproject.toml` files are commonly used by python packages it can be desirable to create a lock
file directly from those dependencies to single-source a package's dependencies. This makes use of some
conda-forge infrastructure ([pypi-mapping][mapping]) to do a lookup of the PyPI package name to a corresponding
conda package name (e.g. `docker` -> `docker-py`). In cases where there exists no lookup for the package it assumes that
the PyPI name, and the conda name are the same.
#### Channels
```toml
# pyproject.toml
[tool.conda-lock]
channels = [
'conda-forge', 'defaults'
]
```
#### Platforms
Like in [environment.yml][envyaml], you can specify default platforms to target:
```toml
# pyproject.toml
[tool.conda-lock]
platforms = [
'osx-arm64', 'linux-64'
]
```
#### Extras
If your pyproject.toml file contains optional dependencies/extras these can be referred to by using the `--extras` flag
```toml
# pyproject.toml
[tool.poetry.dependencies]
mandatory = "^1.0"
psycopg2 = { version = "^2.7", optional = true }
mysqlclient = { version = "^1.3", optional = true }
[tool.poetry.extras]
mysql = ["mysqlclient"]
pgsql = ["psycopg2"]
```
These can be referened as follows
```shell
conda-lock --extra mysql --extra pgsql -f pyproject.toml
```
When generating lockfiles that make use of extras it is recommended to make use of `--filename-template` covered [here](#file-naming).
##### Filtering extras
By default conda-lock will attempt to solve for *ALL* extras/categories it discovers in sources. This allows you to render explicit locks with subset of extras, without needing a new solve.
However this does make the assumption that your extras can all be installed in conjunction with each other. If you want extras filtering
to happen at the solve stage use the flag `--filter-extras`
```sh
conda-lock --extra incompatiblea --filter-extras -f pyproject.toml
```
#### Extra conda dependencies
Since in a `pyproject.toml` all the definitions are python dependencies if you need
to specify some non-python dependencies as well this can be accomplished by adding
the following sections to the `pyproject.toml`
```toml
# pyproject.toml
[tool.conda-lock.dependencies]
sqlite = ">=3.34"
```
#### pip dependencies
If a dependency refers directly to a URL rather than a package name and version,
`conda-lock` will assume it is pip-installable, e.g.:
```toml
# pyproject.toml
[tool.poetry.dependencies]
python = "3.9"
pymage = {url = "https://github.com/MickaelRigault/pymage/archive/v1.0.tar.gz#sha256=11e99c4ea06b76ca7fb5b42d1d35d64139a4fa6f7f163a2f0f9cc3ea0b3c55eb"}
```
Similarly, if a dependency is explicitly marked with `source = "pypi"`, it will
be treated as a `pip` dependency, e.g.:
```toml
[tool.poetry.dependencies]
python = "3.9"
ampel-ztf = {version = "^0.8.0-alpha.2", source = "pypi"}
```
A dependency will also be treated as a `pip` dependency if explicitly marked with `source = "pypi"` in the `[tool.conda-lock.dependencies]` section, e.g.:
```toml
[tool.conda-lock.dependencies]
ampel-ztf = {source = "pypi"}
```
##### Defaulting non-conda dependency sources to PyPI
Alternatively, the above behavior is defaulted for all dependencies defined outside of `[tool.conda-lock.dependencies]`, i.e.:
- Default to `pip` dependencies for `[tool.poetry.dependencies]`, `[project.dependencies]`, etc.
- Default to `conda` dependencies for `[tool.conda-lock.dependencies]`
by explicitly providing `default-non-conda-source = "pip"` in the `[tool.conda-lock]` section, e.g.:
```toml
[tool.conda-lock]
default-non-conda-source = "pip"
```
In all cases, the dependencies of `pip`-installable packages will also be
installed with `pip`, unless they were already requested by a `conda`
dependency.
#### Lock only conda-lock dependencies
To lock only dependencies specified under `[tool.conda-lock]` (i.e. skipping all dependencies specified elsewhere), explicitly provide `skip-non-conda-lock = true` in the `[tool.conda-lock]` section, e.g.:
```toml
[tool.conda-lock]
skip-non-conda-lock = true
```
#### Disabling pypi.org
When using private pip repos, it is possible to disable `pypi.org` entirely. This can be useful when using `conda-lock` behind a network proxy that does not allow access to `pypi.org`.
```toml
[tool.conda-lock]
allow-pypi-requests = false
```
## Dockerfile example
In order to use conda-lock in a docker-style context you want to add the lockfile to the
docker container. In order to refresh the lock file just run `conda-lock` again.
Given a file tree like
```text
Dockerfile
environment.yaml
* conda-linux-64.lock
```
You want a dockerfile that is structured something similar to this
```Dockerfile
# Dockerfile
# Build container
FROM continuumio/miniconda:latest as conda
ADD conda-linux-64.lock /locks/conda-linux-64.lock
RUN conda create -p /opt/env --copy --file /locks/conda-linux-64.lock
# Primary container
FROM gcr.io/distroless/base-debian10
COPY --from=conda /opt/env /opt/env
```
[conda]: https://docs.conda.io/projects/conda
[metayaml]: https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html
[mapping]: https://github.com/regro/cf-graph-countyfair/blob/master/mappings/pypi/grayskull_pypi_mapping.yaml
[envyaml]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually
[poetry]: https://python-poetry.org
Raw data
{
"_id": null,
"home_page": null,
"name": "conda-lock",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Marius van Niekerk <marius.v.niekerk@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/1c/71/13d0ad77f549d40be2697270b5b8ec1a0934a5e85e42d453fb8adede7d81/conda_lock-2.5.7.tar.gz",
"platform": null,
"description": "# conda-lock\n\n[](https://conda.github.io/conda-lock/)\n[](https://pypi.org/project/conda-lock/)\n[](https://github.com/conda-forge/conda-lock-feedstock)\n[](https://results.pre-commit.ci/latest/github/conda/conda-lock/main)\n[](https://codecov.io/gh/conda/conda-lock)\n\nConda lock is a lightweight library that can be used to generate fully reproducible lock files for [conda][conda]\nenvironments.\n\nIt does this by performing a conda solve for each platform you desire a lockfile for.\n\nThis also has the added benefit of acting as an external pre-solve for conda as the lockfiles it generates\nresults in the conda solver *not* being invoked when installing the packages from the generated lockfile.\n\n## Why?\n\nConda [`environment.yml`][envyaml] files are very useful for defining desired environments but there are times when we want to\nbe able to EXACTLY reproduce an environment by just installing and downloading the packages needed.\n\nThis is particularly handy in the context of a gitops style setup where you use conda to provision environments in\nvarious places.\n\n## Installation\n\nUse *one* of the following commands:\n\n```bash\npipx install conda-lock\ncondax install conda-lock\npip install conda-lock\nconda install --channel=conda-forge --name=base conda-lock\nmamba install --channel=conda-forge --name=base conda-lock\n```\n\nThe first two options are recommended since they install conda-lock into an isolated environment. (Otherwise there is a risk of dependency conflicts.)\n\n## Contributing\n\nIf you would like to contribute to conda-lock, please refer to the [Contributing Guide](CONTRIBUTING.md) for instructions on how to set up your development environment.\n\n## Basic usage\n\n```bash\n# generate a multi-platform lockfile\nconda-lock -f environment.yml -p osx-64 -p linux-64\n\n# optionally, update the previous solution, using the latest version of\n# pydantic that is compatible with the source specification\nconda-lock --update pydantic\n\n# create an environment from the lockfile\nconda-lock install [-p {prefix}|-n {name}]\n\n# alternatively, render a single-platform lockfile and use conda command directly\nconda-lock render -p linux-64\nconda create -n my-locked-env --file conda-linux-64.lock\n```\n\n### Pre 1.0 compatible usage (explicit per platform locks)\n\nIf you were making use of conda-lock before the 1.0 release that added unified lockfiles\nyou can still get that behaviour by making use of the `explicit` output kind.\n\n```bash\nconda-lock --kind explicit -f environment.yml\n```\n\n## Advanced usage\n\n### File naming\n\nBy default, `conda-lock` store its output in `conda-lock.yml` in the current\nworking directory. This file will also be used by default for render, install,\nand update operations. You can supply a different filename with e.g.\n\n```bash\nconda-lock --lockfile superspecial.conda-lock.yml\n```\n\nRendered `explicit` and `env` lockfiles will be named as `\"conda-{platform}.lock\"` and `\"conda-{platform}.lock.yml` respectively by default.\n\nIf you want to override that call conda-lock as follows.\n\n```bash\nconda-lock -k explicit --filename-template \"specific-{platform}.conda.lock\"\n```\n\n### Compound specification\n\nConda-lock will build a spec list from several files if requested.\n\n```bash\nconda-lock -f base.yml -f specific.yml -p linux-64 -k explicit --filename-template \"specific-{platform}.lock\"\n````\n\nIn this case all dependencies are combined, and the ordered union of all `channels` is used as the final\nspecification.\n\nThis works for all supported file types.\n\n#### channel overrides\n\nYou can override the channels that are used by conda-lock in case you need to override the ones specified in\nan [environment.yml][envyaml]\n\n```bash\nconda-lock -c conda-forge -p linux-64\n```\n\n#### platform specification\n\nYou may specify the platforms you wish to target by default directly in an [environment.yml][envyaml] using the (nonstandard) `platforms` key:\n\n```yaml\n# environment.yml\nchannels:\n - conda-forge\ndependencies:\n - python=3.9\n - pandas\nplatforms:\n - linux-64\n - osx-64\n - win-64\n - osx-arm64 # For Apple Silicon, e.g. M1/M2\n - linux-aarch64 # aka arm64, use for Docker on Apple Silicon\n - linux-ppc64le\n```\n\nIf you specify target platforms on the command line with `-p`, these will\noverride the values in the environment specification. If neither `platforms` nor\n`-p` are provided, `conda-lock` will fall back to a default set of platforms.\n\n#### default category\n\nYou can may wish to split your dependencies into separate files for better\norganization, e.g. a `environment.yml` for production dependencies and a\n`dev-environment.yml` for development dependencies. You can assign all the\ndependencies parsed from a single file to a category using the (nonstandard)\n`category` key.\n\n```yaml\n# dev-environment.yml\nchannels:\n - conda-forge\ndependencies:\n - pytest\n - mypy=0.910\ncategory: dev\n```\n\nThe default category is `main`.\n\n### pip support\n\n`conda-lock` can also lock the `dependencies.pip` section of\n[environment.yml][envyaml], using a vendored copy of [Poetry's][poetry] dependency solver.\n\n### private pip repositories\n\nRight now `conda-lock` only supports [legacy](https://warehouse.pypa.io/api-reference/legacy.html) pypi repos with basic auth. Most self-hosted repositories like Nexus, Artifactory etc. use this. You can configure private pip repositories in a similar way to channels, for example:\n\n```yaml\nchannels:\n - conda-forge\npip-repositories:\n - http://$PIP_USER:$PIP_PASSWORD@private-pypi.org/api/pypi/simple\ndependencies:\n - python=3.11\n - requests=2.26\n - pip:\n - fake-private-package==1.0.0\n```\n\nSee [the related docs for private channels](./docs/authenticated_channels.md#what_gets_stored) to understand the rules regarding environment variable substitution.\n\nAlternatively, you can use the `poetry` configuration file format to configure private PyPi repositories. The configuration file should be named `config.toml` and have the following format:\n\n```toml\n[repositories.example]\nurl = \"https://username:password@example.repo/simple\"\n```\n\nThe location of this file can be determined with `python -c 'from conda_lock._vendor.poetry.locations import CONFIG_DIR; print(CONFIG_DIR)'`\n\nPrivate repositories will be used in addition to `pypi.org`. For projects using `pyproject.toml`, it is possible to [disable `pypi.org` entirely](#disabling-pypiorg).\n\n### --dev-dependencies/--no-dev-dependencies\n\nBy default conda-lock will include dev dependencies in the specification of the lock (if the files that the lock\nis being built from support them). This can be disabled easily\n\n```bash\nconda-lock --no-dev-dependencies -f ./recipe/meta.yaml\n```\n\n### --check-input-hash\n\nUnder some situation you may want to run conda lock in some kind of automated way (eg as a precommit) and want to not\nneed to regenerate the lockfiles if the underlying input specification for that particular lock as not changed.\n\n```bash\nconda-lock --check-input-hash -p linux-64\n```\n\nWhen the input_hash of the input files, channels match those present in a given lockfile, that lockfile will not be regenerated.\n\n### --strip-auth, --auth and --auth-file\n\nBy default `conda-lock` will leave basic auth credentials for private conda channels in the lock file. If you wish to strip authentication from the file, provide the `--strip-auth` argument.\n\n```shell\nconda-lock --strip-auth -f environment.yml\n```\n\nIn order to `conda-lock install` a lock file with its basic auth credentials stripped, you will need to create an authentication file in `.json` format like this:\n\n```json\n{\n \"domain\": \"username:password\"\n}\n```\n\nIf you have multiple channels that require different authentication within the same domain, you can additionally specify the channel like this:\n\n```json\n{\n \"domain.org/channel1\": \"username1:password1\",\n \"domain.org/channel2\": \"username2:password2\"\n}\n```\n\nYou can provide the authentication either as string through `--auth` or as a filepath through `--auth-file`.\n\n```bash\nconda-lock install --auth-file auth.json conda-linux-64.lock\n```\n\n### --virtual-package-spec\n\nConda makes use of [virtual packages](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html) that are available at\nruntime to gate dependency on system features. Due to these not generally existing on your local execution platform conda-lock will inject\nthem into the solution environment with a reasonable guess at what a default system configuration should be.\n\nIf you want to override which virtual packages are injected you can create a file like\n\n```yaml\n# virtual-packages.yml\nsubdirs:\n linux-64:\n packages:\n __glibc: \"2.17\"\n __cuda: \"11.4\"\n win-64:\n packages:\n __cuda: \"11.4\"\n```\n\nconda-lock will automatically use a `virtual-packages.yml` it finds in the the current working directory. Alternatively one can be specified\nexplicitly via the flag.\n\n```bash\nconda lock --virtual-package-spec virtual-packages-cuda.yml -p linux-64\n```\n\n#### Input hash stability\n\nVirtual packages take part in the input hash so if you build an environment with a different set of virtual packages the input hash will change.\nAdditionally the default set of virtual packages may be augmented in future versions of conda-lock. If you desire very stable input hashes\nwe recommend creating a `virtual-packages.yml` file to lock down the virtual packages considered.\n\n#### \u26a0\ufe0f in conjunction with micromamba\n\nMicromamba does not presently support some of the overrides to remove all discovered virtual packages, consequently the set of virtual packages\navailable at solve time may be larger than those specified in your specification.\n\n## Supported file sources\n\nConda lock supports more than just [environment.yml][envyaml] specifications!\n\nAdditionally conda-lock supports [meta.yaml][metayaml] (conda-build)\nand `pyproject.toml` (\n[flit](https://flit.readthedocs.io/en/latest/), [pdm](https://pdm.fming.dev) and\n[poetry](https://python-poetry.org) based). These do come with some gotchas but\nare generally good enough for the 90% use-case.\n\n### meta.yaml\n\nConda-lock will attempt to make an educated guess at the desired environment spec in a meta.yaml. This is\nnot guaranteed to work for complex recipes with many selectors and outputs. For multi-output recipes, conda-lock\nwill fuse all the dependencies together. If that doesn't work for your case fall back to specifying the specification\nas an [environment.yml][envyaml]\n\nSince a meta.yaml doesn't contain channel information we make use of the following extra key to specify channels\n\n```yaml\n# meta.yaml\n\nextra:\n channels:\n - conda-forge\n - defaults\n```\n\n### pyproject.toml\n\nSince `pyproject.toml` files are commonly used by python packages it can be desirable to create a lock\nfile directly from those dependencies to single-source a package's dependencies. This makes use of some\nconda-forge infrastructure ([pypi-mapping][mapping]) to do a lookup of the PyPI package name to a corresponding\nconda package name (e.g. `docker` -> `docker-py`). In cases where there exists no lookup for the package it assumes that\nthe PyPI name, and the conda name are the same.\n\n#### Channels\n\n```toml\n# pyproject.toml\n\n[tool.conda-lock]\nchannels = [\n 'conda-forge', 'defaults'\n]\n```\n\n#### Platforms\n\nLike in [environment.yml][envyaml], you can specify default platforms to target:\n\n```toml\n# pyproject.toml\n\n[tool.conda-lock]\nplatforms = [\n 'osx-arm64', 'linux-64'\n]\n```\n\n#### Extras\n\nIf your pyproject.toml file contains optional dependencies/extras these can be referred to by using the `--extras` flag\n\n```toml\n# pyproject.toml\n\n[tool.poetry.dependencies]\nmandatory = \"^1.0\"\npsycopg2 = { version = \"^2.7\", optional = true }\nmysqlclient = { version = \"^1.3\", optional = true }\n\n[tool.poetry.extras]\nmysql = [\"mysqlclient\"]\npgsql = [\"psycopg2\"]\n\n```\n\nThese can be referened as follows\n\n```shell\nconda-lock --extra mysql --extra pgsql -f pyproject.toml\n```\n\nWhen generating lockfiles that make use of extras it is recommended to make use of `--filename-template` covered [here](#file-naming).\n\n##### Filtering extras\n\n By default conda-lock will attempt to solve for *ALL* extras/categories it discovers in sources. This allows you to render explicit locks with subset of extras, without needing a new solve.\n\nHowever this does make the assumption that your extras can all be installed in conjunction with each other. If you want extras filtering\nto happen at the solve stage use the flag `--filter-extras`\n\n```sh\nconda-lock --extra incompatiblea --filter-extras -f pyproject.toml\n```\n\n#### Extra conda dependencies\n\nSince in a `pyproject.toml` all the definitions are python dependencies if you need\nto specify some non-python dependencies as well this can be accomplished by adding\nthe following sections to the `pyproject.toml`\n\n```toml\n# pyproject.toml\n\n[tool.conda-lock.dependencies]\nsqlite = \">=3.34\"\n```\n\n#### pip dependencies\n\nIf a dependency refers directly to a URL rather than a package name and version,\n`conda-lock` will assume it is pip-installable, e.g.:\n\n```toml\n# pyproject.toml\n[tool.poetry.dependencies]\npython = \"3.9\"\npymage = {url = \"https://github.com/MickaelRigault/pymage/archive/v1.0.tar.gz#sha256=11e99c4ea06b76ca7fb5b42d1d35d64139a4fa6f7f163a2f0f9cc3ea0b3c55eb\"}\n```\n\nSimilarly, if a dependency is explicitly marked with `source = \"pypi\"`, it will\nbe treated as a `pip` dependency, e.g.:\n\n```toml\n[tool.poetry.dependencies]\npython = \"3.9\"\nampel-ztf = {version = \"^0.8.0-alpha.2\", source = \"pypi\"}\n```\n\nA dependency will also be treated as a `pip` dependency if explicitly marked with `source = \"pypi\"` in the `[tool.conda-lock.dependencies]` section, e.g.:\n\n```toml\n[tool.conda-lock.dependencies]\nampel-ztf = {source = \"pypi\"}\n```\n\n##### Defaulting non-conda dependency sources to PyPI\n\nAlternatively, the above behavior is defaulted for all dependencies defined outside of `[tool.conda-lock.dependencies]`, i.e.:\n\n- Default to `pip` dependencies for `[tool.poetry.dependencies]`, `[project.dependencies]`, etc.\n- Default to `conda` dependencies for `[tool.conda-lock.dependencies]`\n\nby explicitly providing `default-non-conda-source = \"pip\"` in the `[tool.conda-lock]` section, e.g.:\n\n```toml\n[tool.conda-lock]\ndefault-non-conda-source = \"pip\"\n```\n\nIn all cases, the dependencies of `pip`-installable packages will also be\ninstalled with `pip`, unless they were already requested by a `conda`\ndependency.\n\n#### Lock only conda-lock dependencies\n\nTo lock only dependencies specified under `[tool.conda-lock]` (i.e. skipping all dependencies specified elsewhere), explicitly provide `skip-non-conda-lock = true` in the `[tool.conda-lock]` section, e.g.:\n\n```toml\n[tool.conda-lock]\nskip-non-conda-lock = true\n```\n\n#### Disabling pypi.org\n\nWhen using private pip repos, it is possible to disable `pypi.org` entirely. This can be useful when using `conda-lock` behind a network proxy that does not allow access to `pypi.org`.\n\n```toml\n[tool.conda-lock]\nallow-pypi-requests = false\n```\n\n## Dockerfile example\n\nIn order to use conda-lock in a docker-style context you want to add the lockfile to the\ndocker container. In order to refresh the lock file just run `conda-lock` again.\n\nGiven a file tree like\n\n```text\n Dockerfile\n environment.yaml\n* conda-linux-64.lock\n```\n\nYou want a dockerfile that is structured something similar to this\n\n```Dockerfile\n# Dockerfile\n\n# Build container\nFROM continuumio/miniconda:latest as conda\n\nADD conda-linux-64.lock /locks/conda-linux-64.lock\nRUN conda create -p /opt/env --copy --file /locks/conda-linux-64.lock\n\n# Primary container\n\nFROM gcr.io/distroless/base-debian10\n\nCOPY --from=conda /opt/env /opt/env\n```\n\n[conda]: https://docs.conda.io/projects/conda\n[metayaml]: https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html\n[mapping]: https://github.com/regro/cf-graph-countyfair/blob/master/mappings/pypi/grayskull_pypi_mapping.yaml\n[envyaml]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#create-env-file-manually\n[poetry]: https://python-poetry.org\n",
"bugtrack_url": null,
"license": null,
"summary": "Lockfiles for conda",
"version": "2.5.7",
"project_urls": {
"Anaconda.org": "https://anaconda.org/conda-forge/conda-lock",
"Conda-Forge Feedstock": "https://github.com/conda-forge/conda-lock-feedstock",
"Documentation": "https://conda.github.io/conda-lock/",
"Homepage": "https://github.com/conda/conda-lock",
"Issue Tracker": "https://github.com/conda/conda-lock/issues",
"Repository": "https://github.com/conda/conda-lock"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "318928167e281f6111f1b27da6e71596eef42029c950b4eeaf1b0c3f21953af4",
"md5": "fe219b3c5b7095b37d8264413428032c",
"sha256": "fed99fe8fe82a7c6e7962e5aec4643f5c673cb405f20a807312cb42807c8ba6e"
},
"downloads": -1,
"filename": "conda_lock-2.5.7-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fe219b3c5b7095b37d8264413428032c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1275744,
"upload_time": "2024-04-26T18:39:23",
"upload_time_iso_8601": "2024-04-26T18:39:23.728656Z",
"url": "https://files.pythonhosted.org/packages/31/89/28167e281f6111f1b27da6e71596eef42029c950b4eeaf1b0c3f21953af4/conda_lock-2.5.7-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1c7113d0ad77f549d40be2697270b5b8ec1a0934a5e85e42d453fb8adede7d81",
"md5": "70c9e68b61f00c6b194d18c2d85a81e6",
"sha256": "dd85c762adbf6e235fe365630723b4ace2d7e760ccadba262263390390c49a06"
},
"downloads": -1,
"filename": "conda_lock-2.5.7.tar.gz",
"has_sig": false,
"md5_digest": "70c9e68b61f00c6b194d18c2d85a81e6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 1188069,
"upload_time": "2024-04-26T18:39:26",
"upload_time_iso_8601": "2024-04-26T18:39:26.122856Z",
"url": "https://files.pythonhosted.org/packages/1c/71/13d0ad77f549d40be2697270b5b8ec1a0934a5e85e42d453fb8adede7d81/conda_lock-2.5.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-26 18:39:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "conda-forge",
"github_project": "conda-lock-feedstock",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"circle": true,
"lcname": "conda-lock"
}