Skip to main content

A simple library to create minified or relaxed versions of Conda environment specs for cross-platform sharing.

Project description

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 using conda create -n myenv pandas, then minify would return only pandas as 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.2 can become scipy=1.3.*, or scipy=1.* or just scipy. 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 the relax methods described above.
  • --how method - which method to use for creating version strings.
  • -f filename - (optional) write the minified spec to filename otherwise prints to screen.
  • Run the tool to see a full list of options for minify and relax

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conda-minify-0.1.2.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

conda_minify-0.1.2-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file conda-minify-0.1.2.tar.gz.

File metadata

  • Download URL: conda-minify-0.1.2.tar.gz
  • Upload date:
  • Size: 13.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for conda-minify-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1de1b33faa0eb05a40b0f4136470397a7db4dbfdd98ad8c441e3b07cce6daa77
MD5 4f2a68fc7685062e112810baf34f1010
BLAKE2b-256 6a6229d08b73acd9c5a7a95fec447a9f705ef75d7e44e7a5f841178ceebd3f8f

See more details on using hashes here.

File details

Details for the file conda_minify-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: conda_minify-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for conda_minify-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 610abc0e42f71a96a9638572d24b7e40f7817c15461a863aaced80f27e791991
MD5 52fba2dd11470c3ad74abf6bc9d633ab
BLAKE2b-256 270300c6e33a659c36ec228762bf92c7cd1cb37aa083d976a7e34acadf179f7d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page