https://github.com/conda/conda-lock
Lightweight lockfile for conda environments
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
3 of 78 committers (3.8%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.2%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Lightweight lockfile for conda environments
Basic Info
- Host: GitHub
- Owner: conda
- License: other
- Language: Python
- Default Branch: main
- Homepage: https://conda.github.io/conda-lock/
- Size: 10.9 MB
Statistics
- Stars: 529
- Watchers: 10
- Forks: 110
- Open Issues: 167
- Releases: 63
Topics
Metadata Files
README.md
conda-lock
Conda lock is a lightweight library that can be used to generate fully reproducible lock files for 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 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 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 ```
Note: If there is an existing lockfile, it is used as constraint when regenerating the lockfile. This can be useful for adding new packages while keeping everything else locked.
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
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 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, using a vendored copy of Poetry's dependency solver.
private pip repositories
Right now conda-lock only supports legacy 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 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)'
By default, private repositories will be used in addition to pypi.org, but it is also possible to disable pypi.org entirely.
--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 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" _archspec: "1 haswell" win-64: packages: _cuda: "11.4" __archspec: "1 haswell" ```
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 specifications!
Additionally conda-lock supports meta.yaml (conda-build)
and pyproject.toml (
flit, pdm and
poetry 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
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) 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, 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.
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
pipdependencies for[tool.poetry.dependencies],[project.dependencies], etc. - Default to
condadependencies 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.
You can do this in pyproject.toml:
toml
[tool.conda-lock]
allow-pypi-requests = false
Or in environment.yml:
yaml
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/miniconda3: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 ```
Owner
- Name: conda
- Login: conda
- Kind: organization
- Website: https://conda.org
- Twitter: condaproject
- Repositories: 29
- Profile: https://github.com/conda
conda is system-level, binary package and environment manager running on all major operating systems and platforms.
GitHub Events
Total
- Create event: 28
- Release event: 10
- Issues event: 46
- Watch event: 37
- Delete event: 22
- Issue comment event: 244
- Push event: 242
- Pull request review comment event: 40
- Pull request review event: 58
- Pull request event: 121
- Fork event: 9
Last Year
- Create event: 28
- Release event: 10
- Issues event: 46
- Watch event: 37
- Delete event: 22
- Issue comment event: 244
- Push event: 242
- Pull request review comment event: 40
- Pull request review event: 58
- Pull request event: 121
- Fork event: 9
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Ben Mares | s****1@t****m | 484 |
| Marius van Niekerk | m****k@g****m | 274 |
| Jakob van Santen | j****n@g****m | 66 |
| Filipe Fernandes | o****f@g****m | 48 |
| Jan-Benedikt Jagusch | j****h@g****m | 41 |
| Nathan Roach | n****h@g****m | 39 |
| Romain Cledat | r****t@n****m | 38 |
| pre-commit-ci[bot] | 6****] | 37 |
| renovate[bot] | 2****] | 37 |
| Priyanka Sengupta | p****a@f****m | 33 |
| Srinivas Lade | s****1@g****m | 32 |
| Jack Smith | j****h@g****m | 22 |
| Matt Fisher | m****7@g****m | 16 |
| Marcelo Duarte Trevisani | m****i | 15 |
| Nicholas Bollweg | n****g@g****m | 14 |
| Nathan Roach | n****h@m****m | 12 |
| Min RK | b****k@g****m | 11 |
| Eric Dill | e****l@p****e | 10 |
| Riccardo Porreca | r****a@m****m | 9 |
| Salman Anwer | S****r@p****m | 9 |
| Jannis Leidel | j****s@l****o | 8 |
| Matthew Wardrop | m****p@g****m | 8 |
| Stephan Finkensieper | s****r@d****e | 7 |
| Conda Bot | 1****t | 7 |
| Bas Nijholt | b****s@n****t | 7 |
| Daniel Bast | 2****t | 6 |
| Jonas Haag | j****s@l****g | 6 |
| Roland Schwan | r****n@m****m | 5 |
| Loïc Estève | l****e@y****m | 5 |
| Michael Garner | m****r@s****m | 4 |
| and 48 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 168
- Total pull requests: 512
- Average time to close issues: 3 months
- Average time to close pull requests: 29 days
- Total issue authors: 95
- Total pull request authors: 54
- Average comments per issue: 3.36
- Average comments per pull request: 2.37
- Merged pull requests: 386
- Bot issues: 2
- Bot pull requests: 143
Past Year
- Issues: 33
- Pull requests: 218
- Average time to close issues: 15 days
- Average time to close pull requests: 13 days
- Issue authors: 23
- Pull request authors: 15
- Average comments per issue: 1.06
- Average comments per pull request: 1.51
- Merged pull requests: 167
- Bot issues: 0
- Bot pull requests: 52
Top Authors
Issue Authors
- maresb (30)
- ctcjab (6)
- wholtz (5)
- mjlbach (5)
- lesteve (5)
- srilman (4)
- baszalmstra (4)
- riccardoporreca (3)
- scottyhq (3)
- AlbertDeFusco (3)
- matthewfeickert (3)
- nicoddemus (2)
- FelixSchwarz (2)
- qmarcou (2)
- jab (2)
Pull Request Authors
- maresb (215)
- renovate[bot] (83)
- pre-commit-ci[bot] (48)
- mariusvniekerk (16)
- conda-bot (16)
- romain-intel (14)
- srilman (12)
- github-actions[bot] (12)
- sfinkens (6)
- jacksmith15 (5)
- riccardoporreca (4)
- jezdez (4)
- peterbygrave (4)
- tadeu (4)
- mfisher87 (4)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- homebrew 110 last-month
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 49
(may contain duplicates) - Total versions: 89
proxy.golang.org: github.com/conda/conda-lock
- Documentation: https://pkg.go.dev/github.com/conda/conda-lock#section-documentation
- License: other
-
Latest release: v3.0.4+incompatible
published 8 months ago
Rankings
formulae.brew.sh: conda-lock
Lightweight lockfile for conda environments
- Homepage: https://github.com/conda/conda-lock
- License: MIT
-
Latest release: 3.0.4
published 8 months ago
Rankings
anaconda.org: conda-lock
Conda lock is a lightweight library that can be used to generate fully reproducible lock files for conda environments. It does this by performing multiple solves for conda targeting a set of platforms you desire lockfiles for. This also has the added benefit of acting as an external presolve for conda as the lockfiles it generates results in the conda solver not being invoked when installing the packages from the generated lockfile.
- Homepage: https://github.com/conda/conda-lock
- License: MIT
-
Latest release: 3.0.4
published 6 months ago
Rankings
Dependencies
- requests *
- pytest ~5.1.0 develop
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- actions/checkout v3 composite
- actions/setup-python v4 composite
- peaceiris/actions-gh-pages v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish master composite
- actions/checkout v3 composite
- conda-incubator/setup-miniconda v2 composite
- continuumio/miniconda latest build
- migrate-code *
- pipreqs *
- pkginfo *
- pre-commit *
- pydantic *
- requests *
- toml *
- vendoring *
- GeoAlchemy2 >=0.6.3,<1
- atpublic >=2.3,<4
- black >=22.1.0,<23
- clickhouse-cityhash >=1.0.2,<2
- clickhouse-driver >=0.1,<1
- dask >=2022.9.1
- datafusion >=0.6,<0.8
- db-dtypes >=0.3,<2
- duckdb >=0.3.3,<1
- duckdb-engine >=0.1.8,<1
- fsspec >=2022.1.0
- geopandas >=0.6,<1
- google-cloud-bigquery >=3,<4
- google-cloud-bigquery-storage >=2,<3
- graphviz >=0.16,<1
- impyla >=0.17,<1
- lz4 >=3.1.10,<5
- multipledispatch >=0.6,<1
- numpy >=1,<2
- pandas >=1.2.5,<2
- parsy >=1.3.0,<3
- polars >=0.14.18,<1
- psycopg2 >=2.8.4,<3
- pyarrow >=2,<11
- pydata-google-auth ^1.4.0
- pymssql >=2.2.5,<3
- pymysql >=1,<2
- pyspark >=3,<4
- python ^3.8
- python-dateutil >=2.8.2,<3
- pytz >=2022.7
- regex >=2021.7.6
- requests >=2,<3
- rich >=12.4.4,<14
- shapely >=1.6,<1.8|>=1.9,<3
- snowflake-connector-python >=2.7.10,<3
- snowflake-sqlalchemy >=1.4.1,<2
- sqlalchemy >=1.4,<2
- sqlglot >=10.4.3,<11
- toolz >=0.11,<1
- trino >=0.319,<1
- typing-extensions >=4.3.0,<5
- dask-core
- pip
- python 3.9.*
- flask <2
- pydantic 1.7
- python 3.9.6
- zlib
- requests >=2.13.0
- toml >=0.10
- tomlkit >=0.7
- pytest ~5.1.0 develop
- python ^3.7
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- MIDIFile *
- bokeh
- cartopy
- cython
- dask
- dask-cloudprovider
- datashader
- earthsim
- erddapy
- fsspec
- gcsfs
- geoviews
- h5netcdf
- h5py
- holoviews
- hvplot
- ipykernel
- ipywidgets
- lz4
- metpy
- netcdf4
- numpy
- panel
- python
- python-blosc
- s3fs
- utide
- xarray
- zarr
- zlib
- gdal
- python >=3.7,<3.8
- cuda-python
- cudf
- cudatoolkit >=11,<12
- cudnn >=8,<9
- clang_osx-64
- clang_osx-arm64
- gcc_linux-64 >=6
- python <3.11
- python <3.11
- blas
- numpy
- python
- requests
- python
- requests
- zlib
- python >=3.8,<3.10
- pip
- dask
- pip
- python 3.9.*
- requests 2.26.*
- pip
- python 3.9.*
- pip
- pybedtools
- python 3.9.12.*
- miniwdl 1.2.3.*
- pip
- python 3.9.12.*
- pip
- python 3.10.*
- actions/checkout 3df4ab11eba7bda6032a0b82a6bb43b11571feac composite
- mamba-org/setup-micromamba v1 composite
- peter-evans/create-pull-request v5 composite
- cachecontrol [filecache] >=0.12.9
- cachy >=0.3.0
- click >=8.0
- click-default-group *
- clikit >=0.6.2
- crashtest >=0.3.0
- ensureconda >=1.3
- gitpython >=3.1.30
- html5lib >=1.0
- jinja2 *
- keyring >=21.2.0
- packaging >=20.4
- pkginfo >=1.4
- pydantic >=1.10
- pyyaml >= 5.1
- requests >=2.18
- ruamel.yaml *
- tomli python_version<"3.11"
- tomlkit >=0.7.0
- toolz >=0.12.0,<1.0.0
- typing-extensions *
- urllib3 >=1.26.5,<2.0
- virtualenv >=20.0.26
- pandas ^1.5.0
- requests >=2.13.0
- toml >=0.10
- requests >=2.13.0
- toml >=0.10
- tomlkit >=0.7
- pytest ~5.1.0 develop
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- pytest ~5.1.0 develop
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- pytest ~5.1.0 develop
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- pytest ~5.1.0 develop
- requests ^2.13.0
- toml >=0.10
- tomlkit >=0.7.0,<1.0.0
- pytest ~5.1.0 develop
- pyyaml develop
- requests ^2.13.0
- toml
- tomlkit