# Software installation survival guide Filipe Fernandes Aug 7, 2023 Choose wisely or waste hours that could be used procrastinating! --- ## whoami ![](https://media.tenor.com/CO3r_GG3lccAAAAd/i-fly-the-ship-erica-ortegas.gif) --- ## Summary - We need to install Software, but how? - Software is pain, can we reduce the pain? - It works on my machine and other reproducibility lies - Demonstration --- <!-- 1/4 :: We need to install Software, but how? --> ## So, recently I got this message > "Sometimes I feel like a blind person who knows where the furniture is until someone moves it!" --- ## Questions - Should I install Python/R with Anaconda, miniconda, miniforge, mambaforge, micromamba, pixi, ouroboros? - How about installing packages? conda, mamba, micromamba, pip? - Should I pin packages? - Should I use an environment file? --- ## More Questions - Can I mix conda packages with pip? - Should I use the conda defaults channel? Or conda-forge? - What is the best way to replicate an environment? - How can I install a conda environment on another machine? --- ## Warning!!! ![](https://imgs.xkcd.com/comics/moon.png) If you have a solution that works, ignore this tutorial until the day that solution becomes a problem. --- ## We recommend conda ![](https://hackmd.io/_uploads/Hkx_-XYs2.gif) Which flavor? Doesn't matter much as long as you [enable libmamba](https://www.anaconda.com/blog/a-faster-conda-for-a-growing-community). --- ## Backstreet Boys - Tell Me Why - conda is a language agnostic package manager (think yum, choco, apt, brew, not pip) - It runs on multiple OSes and platforms making instructions easy to port - Publishing your own package is easier than the alternatives thanks to conda-forge --- ## Navigating the installer landscape (some disambiguation first) - AnacondaInc: The company - CondaProject: The OSS community - conda-forge: The scientific focused OSS packaging community --- ## Now, the installer landscape - Anaconda Distribution: Matlab-like Python distribution for scientific Python. &#10060; - Miniconda/miniforge/mambaforge: just the conda package manager, or is it? &#9989; - Micromamba: No, really, now it is just the package manager! &#9989; - pixi &#63; Stay tunned... --- ## And the winner is... Miniforge! - all the **mini**-variants are OK. Avoid distributions due to conflicts and bloating issues - **miniforge** is already configured to use the conda-forge packages (less post install config steps) > micromamba is better but no clear way to get it on Windows --- <!-- 2/4 :: Software is pain, can we reduce the pain? --> ## We know the how, now let's reduce the pain ![](https://hackmd.io/_uploads/SJAy7Qtih.png) --- ## Not the environment you where looking for - Environments are not static, can change with the project: addition of extra packages, updates of existing ones, etc. - Still, they ~~can~~ must be tracked, shared, and easily recreated. --- ## Environments allow for - encapsulation - context separation - reproducibility --- ## Use cases - development/testing environments: used locally by devs or on CIs - kitchen sink environment: like the IOOS environment (more later) - &rarr; project specific environment: what you'll be doing for OHW &larr; --- ## Examples - [environment.yml](https://github.com/oceanhackweek/jupyter-image/blob/main/py-base/environment.yml) - [conda-lock](https://github.com/oceanhackweek/jupyter-image/blob/main/py-base/conda-linux-64.lock) - Or even [requirements.txt files](https://github.com/ioos/erddapy/blob/main/requirements.txt) --- <!-- 3/4 :: It works on my machine and other reproducibility lies. --> ## It works on my machine and other reproducibility lies How portable, maintainable, and reproducible are environments? When should we use a heavy weight solution like Docker? --- ## Some answers - Portability: It turns out it depends on the packages. If they are available on all platforms, the environment is portable. - Maintainability: envs are cheap, so removing and re-creating them is easy and encouraged. Keep your env file tidy though! - Reproducibility: bare bones env files &darr;, lock files &uarr;, (docker &uarr;&uarr;) --- <!-- 4/4 :: Demonstration --> ## Demonstration Let's simulate a scenario where OHW participants need to install packages for project work, track them, share with colleagues, and freeze it for posterity. Open the terminal and pray for the live demo Goddess! --- ## Questions? ![](https://hackmd.io/_uploads/Hk4gIXts2.png) ...and its the docs: [IOOS installer guide](https://ioos.github.io/ioos_code_lab/content/ioos_installation_conda.html), [conda-forge user guide](https://conda-forge.org/docs/user/00_intro.html), [conda docs](https://docs.conda.io/projects/conda/en/stable/user-guide/concepts/index.html), [creating your own package](https://www.pyopensci.org/python-package-guide/package-structure-code/publish-python-package-pypi-conda.html). Feeling adventurous, [try pixi](https://github.com/prefix-dev/pixi). --- ## demo 0 ```shell conda env create --name OHW-proj jupyter numpy matplotlib pandas xarray nbclassic conda activate OHW-proj ``` --- ## demo 1 ```python import xarray as xr url = ( "http://tds.marine.rutgers.edu/thredds/dodsC/roms/doppio/" "2017_da/avg/Averages_Best" ) ds = xr.open_dataset(url) ds ``` --- ## demo 2 ```shell conda install netcdf4 conda install cf_xarray conda env export --from-history > environment.yaml conda env create --file environment.yaml conda-lock --file environment.yaml ``` --- ## demo 3 ```yaml - add pip from git - pip: - git+https://github.com/pydata/xarray.git ```
{"title":"Software installation survival guide","description":"We need to install Software, but how?","contributors":"[{\"id\":\"88a8ebf5-fd29-4e3e-8264-ed4364e8c9cb\",\"add\":8289,\"del\":2620}]"}
    327 views