Conda Minify
A simple library to create minified or relaxed versions of Conda environment specs for cross-platform sharing.
Why Conda Minify?
It was not an uncommon occurance for me to run into issues when trying to use another team's project. Although projects were well documented and included an environment.yaml file to setup the environment, moving between Windows and Unix made this very difficult. Several factors were in play:
- Conda packages for Unix and Windows can have different build numbers
- Occassionally packages built for one OS have sub-sub versions that are not available (e.g. "0.11.3.1")
- Lower level dependencies often differ between OS versions
- Often environment specs were just exported "as-is", without thought to which packages were actually needed
What does Conda Minify do?
Conda Minify provides a simple way to produce an Conda specification YAML file with only the minimum requirements needed to approximately reproduce the environment. Conda can figure out the rest of the details for the dependencies. For example, if you have an environment with Pandas and Matplotib; sharing the environment really only requires specifying Pandas and Matplotib and their versions.
Installation
These are the recommended methods for installation. It is worth noting that Conda Minify can be run without installation as a script module using the same CLI commands; please see the Usage section .
Via Conda
conda install conda-minify -c jamespreed
Via PIP
pip install conda-minify
Usage
Conda Minify has two primary method for reducing environment requirements: minify and relax.
minify- The primary tool for sharing an environment. This analyzes the dependency graph for the entire environment and only exports requirements for the "top-level" packages. I.e. if you created an environment usingconda create -n myenv pandas, thenminifywould return onlypandasas the spec.relax- An auxilery tool that "loosens" the version requirements. This allows you convert exact versions specifications to only major, minor, or none at all. I.e.scipy=1.3.2can becomescipy=1.3.*, orscipy=1.*or justscipy. Additional options allow pinning and overriding verions.
Command Line Interface
After installation the CLI can be invoked using:
conda-minify [--name env_name] [--relax] [--how method] [-f filename] [options ...]
--name env_name- name of the environment export, if not passed, the current environment is used.--relax- switches to using therelaxmethods described above.--how method- which method to use for creating version strings.-f filename- (optional) write the minified spec tofilenameotherwise prints to screen.- Run the tool to see a full list of options for
minifyandrelax
CLI via Python
Conda Minify is designed to be run as a scripted module in the event that your base Conda installation is locked and prohibits installation of new packages. Or because you don't want to throw new stuff into your clean Anaconda base environment (I understand).
Clone the repo with git (or download the zip and unzip), move to the top folder of the repo, and run with Python:
$> git clone https://github.com/jamespreed/conda-minify.git
$> cd conda-minify
$> pythnon -m conda_minify <name> <minify | relax> [-f filename] [options ...]
Python API
To run this programmatically the Python API provides a relatively easy method.
from conda_minify import CondaEnvironment
# create a CondaEnvironment object for the myenv environment.
cenv = CondaEnvironment(name='myenv')
# build the dependency graph
cenv.build_graph()
# write out the minified version to a file
cenv.minify_requirements(
export_path='myenv.yaml',
include=['python'], # include python so we can set the version
how='minor' # relax version requirements to minor releases
)
# OR export the relaxed requirements
cenv.relax_requirements(
export_path='myenv.yaml',
how='none', # add no versions
pin=['pandas'], # except pin the version of pandas i.e. 0.25.3
override={'python': 'minor'} # and use the minor version of python i.e. 3.7.*
)
Metadata
Release files for conda-minify 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conda-minify-0.1.2.tar.gz | 13.9 kB | Without provenance | Details for conda-minify-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conda_minify-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for conda_minify-0.1.2-py3-none-any.whl |
Total release size: 28.3 kB
Release files / conda-minify-0.1.2.tar.gz
| Download URL | conda-minify-0.1.2.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1de1b33faa0eb05a40b0f4136470397a7db4dbfdd98ad8c441e3b07cce6daa77
|
|
BLAKE2b-256 checksum How to use checksums |
6a6229d08b73acd9c5a7a95fec447a9f705ef75d7e44e7a5f841178ceebd3f8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Release files / conda_minify-0.1.2-py3-none-any.whl
| Download URL | conda_minify-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
610abc0e42f71a96a9638572d24b7e40f7817c15461a863aaced80f27e791991
|
|
BLAKE2b-256 checksum How to use checksums |
270300c6e33a659c36ec228762bf92c7cd1cb37aa083d976a7e34acadf179f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0.post20200106 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for conda-minify 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.