Skip to content

Commit

Permalink
Enable custom installs of brew bottles for difficult to build Linux p…
Browse files Browse the repository at this point in the history
…ackages. Add cmake to avoid Python dependency with Sphinx
  • Loading branch information
chapmanb committed Sep 19, 2014
1 parent 879deba commit abaad77
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cloudbio/custom/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ def _remote_fetch(env, url, out_file=None, allow_fail=False, fix_fn=None, samedi
if out_file is None:
out_file = os.path.basename(url)
if not env.safe_exists(out_file):
orig_dir = env.safe_run_output("pwd").strip()
if samedir and os.path.isabs(out_file):
orig_dir = os.path.dirname(out_file)
out_file = os.path.basename(out_file)
else:
orig_dir = env.safe_run_output("pwd").strip()
temp_ext = "/%s" % uuid.uuid3(uuid.NAMESPACE_URL,
str("file://%s/%s/%s" %
(env.host, socket.gethostname(), out_file)))
Expand All @@ -188,6 +192,8 @@ def _remote_fetch(env, url, out_file=None, allow_fail=False, fix_fn=None, samedi
out_file = None
else:
raise IOError("Failure to retrieve remote file")
if samedir:
out_file = os.path.join(orig_dir, out_file)
return out_file

def _fetch_and_unpack(url, need_dir=True, dir_name=None, revision=None,
Expand Down
25 changes: 24 additions & 1 deletion cloudbio/package/brew.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
from distutils.version import LooseVersion
import os

from cloudbio.custom import system
from cloudbio.custom import system, shared
from cloudbio.flavor.config import get_config_file
from cloudbio.fabutils import quiet, find_cmd
from cloudbio.package.shared import _yaml_to_packages

from fabric.api import cd, settings

BOTTLE_URL = "https://s3.amazonaws.com/cloudbiolinux/brew_bottles/{pkg}-{version}.x86_64-linux.bottle.tar.gz"

def install_packages(env, to_install=None, packages=None):
"""Install packages using the home brew package manager.
Expand Down Expand Up @@ -194,13 +196,34 @@ def _get_pkg_version_args(pkg_str):
name, version = parts
return name, version, args

def _install_bottle(env, brew_cmd, pkg, ipkgs):
"""Install Linux bottles for brew packages that can be tricky to build.
"""
if env.distribution == "macosx": # Only Linux bottles, build away on Mac
return
pkg_version = _latest_pkg_version(env, brew_cmd, pkg)
install_version = ipkgs["current"].get(pkg)
if pkg_version == install_version: # Up to date
return
url = BOTTLE_URL.format(pkg=pkg, version=pkg_version)
brew_cachedir = env.safe_run_output("%s --cache" % brew_cmd)
brew_cellar = os.path.join(env.safe_run_output("%s --prefix" % brew_cmd), "Cellar")
bottle_file = shared._remote_fetch(env, url, out_file=os.path.join(brew_cachedir, os.path.basename(url)),
allow_fail=True, samedir=True)
if bottle_file:
with cd(brew_cellar):
env.safe_run("tar -xf %s" % bottle_file)
env.safe_run("%s link --overwrite %s" % (brew_cmd, pkg))

def _install_brew_baseline(env, brew_cmd, ipkgs, packages):
"""Install baseline brew components not handled by dependency system.
- Installation of required Perl libraries.
- Ensures installed samtools does not overlap with bcftools
- Upgrades any package dependencies
"""
for dep in ["cmake"]:
_install_bottle(env, brew_cmd, dep, ipkgs)
for dep in ["expat"]:
_install_pkg_latest(env, dep, [], brew_cmd, ipkgs)
# if installing samtools, avoid bcftools conflicts
Expand Down

0 comments on commit abaad77

Please sign in to comment.