% Collaborative Science with Conda and Binstar
- Cross platform package manager built by Continuum Analytics
- Goes beyond pip (and friends) capability
- Endorsed by Python Packaging Authority (PyPA)
- "collection of software tools to automate the process of installing, upgrading, configuring, and removing software packages" - wikipedia
- In practical terms, "I am a researcher, and I need to import numpy or cartopy. How do I do that?"
- Stackoverflow Q & A: "Differences between distribute, distutils, setuptools and distutils2?"
- "Python packaging/installation has way too many alternatives with no clear guidance from the community." -Sabuncu
- "I love Python, but the state of Python packaging is nothing less than hellish!" -Zearin
- Works well for Python
- Not great if you are linking against C and Fortran libraries (e.g., HDF5)
- Python agnostic package manager
- Cross-platform
- No admin privileges required
- Smart dependency management
- Easy to work w/ different versions of packages (e.g., numpy 1.7 vs. 1.9)
- Free and available at Continuum Analytics
- Binary tarballs containing system-level libraries, Python modules, executable programs
- Examples: numpy, matplotlib, ipython, libnetcdf, etc.
- Can also build packages for distribution via binstar channels
- conda environment is a collection of packages
- Simply a directory on the file system containing conda packages
- Environments nicely compartmentalized
- Easy to set up environments
- Easy to invoke and switch between environments
- conda packages originate from "channels"
- There are default channels for most standard packages
- Add custom channels to find special packages
- You can become your own channel binstar
- Examine channel list in .condarc
- Primary interface for managing Python packages
conda --help
conda [command] --help
- Display information about current conda install
conda info --all
conda info --envs
conda info --system
conda create -n <env> anaconda
- numpy
- pandas
- matplotlib
- lots of stuff
- Create a new conda environment from a list of specified packages
conda create -n <env> python
- Must supply at least one package
- Lots of optional arguments
- More realistic example
conda create -n <env> python=2 numpy matplotlib ipython ipython-notebook netcdf4
- Unix :
source activate <env>
- Windows:
activate <env>
- Install a list of packages into a specified conda environment
conda install -n <env> matplotlib
- Dealing with specific package versions
conda install -n <env> matplotlib=1.2
- List packages in a conda environment
conda list
conda list --export > exported_packages.txt
- share your exported_packages.txt w/ colleague
conda create -n <env> --file exported_packages.txt
- Update conda packages
conda update --all
to update all installed packages in the environment- Conda can self-update
conda update conda
conda update anaconda
- Modify configuration values in .condarc
conda config --add channels rsignell
conda config --get channels --system
- To deactivate the environment
conda remove --all -n <env>
- https://binstar.org
- Package hosting server that works w/ conda
- Often, consuming packages via binstar
- Can also distribute packages via binstar
- Channels are tied to users or organizations
https://binstar.org/unidata
https://binstar.org/risgnell
- Channels can be added to conda configuration (.condarc) so you can find packages of interest
- Command line interface for
binstar
binstar --help
binstar [command] --help
- Search binstar for packages
binstar search proj4
binstar show SciTools/proj4
- Create an account at binstar.org
- Create recipe
- Create package
- Upload to binstar
- Create recipe directory
- Create meta.yaml
- Create build.sh or bld.bat
conda build
package- Upload to binstar
- Best is to follow examples at https://github.com/conda/conda-recipes
`-- pyudl
|-- bld.bat
|-- build.sh
|-- meta.yaml
- Typically a very simple file
- Contains build instructions
- bld.bat
"%PYTHON%" setup.py install
- build.sh
$PYTHON setup.py install
- For something written in C could be a bit more complicated invoking
make
- Human readable data format similar to XML
- Metadata that simply describes the build recipe
- Follow examples at https://github.com/conda/conda-recipes
package:
name: pyudl
version: 0.1
source:
git_url: https://github.com/Unidata/pyudl
git_tag: 0.1
build:
number: 0
requirements:
build:
- python
- setuptools
run:
- python
about:
home: https://github.com/Unidata/pyudl
license: MIT
summary: 'A collection of Python utilities for interacting with Unidata technologies'
- Build from the parent of the recipe directory
conda build <package>
- If successful, will give instructions on how to upload to binstar
binstar login
binstar upload <package>
- Tell colleagues about your channel so that they may use your work