Tuesday, May 31, 2016

simple tutorial for (mini)conda's offline package installation



The newest openssl for python & related packages such as pycrypto & cryptography is necessary for newer HTTPS or HTTP/2 operations (and also cx_Oracle for us). 

But compile them manually without altering system's defaults is very tricky. So we consider to use some package manager which compile and manage those binary package for us. 

Conda is a good choice for our purpose, but conda defaults to online package install, here's a simple tutorial for conda's offline package installation.

  1. basic install
    • wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
    • bash Miniconda2-latest-Linux-x86_64.sh -b # for silent install
    • # a root environment is built, with
      • conda=4.0.5=py27_0
      • conda-env=2.4.5=py27_0
      • openssl=1.0.2g=0
      • pip=8.1.1=py27_1
      • pycosat=0.6.1=py27_0
      • pycrypto=2.6.1=py27_0
      • python=2.7.11=0
      • pyyaml=3.11=py27_1
      • readline=6.2=2
      • requests=2.9.1=py27_0
      • setuptools=20.3=py27_0
      • sqlite=3.9.2=0
      • tk=8.5.18=0
      • wheel=0.29.0=py27_0
      • yaml=0.1.6=0
      • zlib=1.2.8=0
    • # we don't touch the root environment, except for some basic packages, for us: zeromq
    • export PATH=$PATH:/root/miniconda/bin
  2. create new virtual environment
    • conda create -n newenv --clone root --unknown --offline
    • # here's trick: only using --offline will cause index not available: 
      • KeyError: 'wheel-0.29.0-py27_0.tar.bz2'
    • # but --unknown will ignore the package is not installed by dependencies.
    • # use --use-index-cache is same as --offline here
    • # see: How can I install a conda environment when offline?
  3. install some package offline
    • conda doesn't provide pip --download command, so we do it manually.
    • discover package dependencies
      • # on some server with internet
      • conda install some_pkgs  # then cancel
      • # remember package dependencies
    • download packages... by hand
      • # we can find the repo here
        • http://repo.continuum.io/pkgs/
        • http://repo.continuum.io/pkgs/free/  # mainly
    • # for example: zeromq
      • wget https://repo.continuum.io/pkgs/free/linux-64/zeromq-4.1.4-0.tar.bz2
      • wget https://repo.continuum.io/pkgs/free/linux-64/libsodium-1.0.10-0.tar.bz2
      • wget https://repo.continuum.io/pkgs/free/linux-64/conda-4.0.7-py27_0.tar.bz2
    • # for example: cx_Oracle
      • wget https://repo.continuum.io/pkgs/free/linux-64/oracle-instantclient-11.2.0.4.0-0.tar.bz2
      • wget https://repo.continuum.io/pkgs/free/linux-64/cx_oracle-5.1.2-py27_0.tar.bz2
    • install them offine
      • conda install xxxx.tar.bz2
  4. we are done!
  5. P.S if we want packages been cloned automatically from root, we should do the steps on root environment.
    • for us, it's zeromq only

No comments:

Post a Comment