Package: conda-minify
Conda MinifyA 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 anenvironment.yamlfile 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 numbersOccassionally 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 versionsOften environment specs were just exported "as-is", without thought to which packages were actually neededWhat does Conda Minify do?Conda Minify provides a simple way to produce an Conda specification YAML file with only the minimum requirements needed toapproximatelyreproduce 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.InstallationThese are the recommended methods for installation.  It is worth noting that Conda Minify can be runwithoutinstallation as a script module using the same CLI commands; please see theUsage section.Via Condaconda install conda-minify -c jamespreedVia PIPpip install conda-minifyUsageConda Minify has two primary method for reducing environment requirements:minifyandrelax.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 InterfaceAfter 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 forminifyandrelaxCLI via PythonConda 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 APITo run this programmatically the Python API provides a relatively easy method.fromconda_minifyimportCondaEnvironment# create a CondaEnvironment object for the myenv environment.cenv=CondaEnvironment(name='myenv')# build the dependency graphcenv.build_graph()# write out the minified version to a filecenv.minify_requirements(export_path='myenv.yaml',include=['python'],# include python so we can set the versionhow='minor'# relax version requirements to minor releases)# OR export the relaxed requirementscenv.relax_requirements(export_path='myenv.yaml',how='none',# add no versionspin=['pandas'],# except pin the version of pandas i.e. 0.25.3override={'python':'minor'}# and use the minor version of python i.e. 3.7.*)