Skip to content

Instantly share code, notes, and snippets.

@bradediger
Created December 12, 2012 19:20
Show Gist options
  • Select an option

  • Save bradediger/4270727 to your computer and use it in GitHub Desktop.

Select an option

Save bradediger/4270727 to your computer and use it in GitHub Desktop.

Revisions

  1. bradediger created this gist Dec 12, 2012.
    75 changes: 75 additions & 0 deletions carbon.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@
    require 'formula'

    class Carbon < Formula
    homepage 'http://graphite.wikidot.com/'
    url 'http://pypi.python.org/packages/source/c/carbon/carbon-0.9.10.tar.gz'
    md5 '1d85d91fe220ec69c0db3037359b691a'

    depends_on 'python'
    depends_on 'twisted' => :python
    depends_on 'whisper'

    # https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
    def install
    # In order to install into the Cellar, the dir must exist and be in the PYTHONPATH.
    temp_site_packages = lib/which_python/'site-packages'
    mkdir_p temp_site_packages
    ENV['PYTHONPATH'] = temp_site_packages

    args = [
    "--no-user-cfg",
    "--verbose",
    "install",
    "--force",
    "--install-scripts=#{bin}",
    "--install-lib=#{temp_site_packages}",
    "--install-data=#{share}",
    "--install-headers=#{include}",
    "--record=installed-files.txt"
    ]

    system "python", "-s", "setup.py", *args

    conf_path.install Dir['conf/*']
    end

    def conf_path
    etc/'carbon'
    end

    def patches
    StringIO.new(<<-END)
    diff --git a/bin/carbon-client.py b/bin/carbon-client.py
    index ed6a7e7..464f375 100755
    --- a/bin/carbon-client.py
    +++ b/bin/carbon-client.py
    @@ -21,7 +21,7 @@ from optparse import OptionParser
    # Figure out where we're installed
    BIN_DIR = dirname(abspath(__file__))
    ROOT_DIR = dirname(BIN_DIR)
    -CONF_DIR = join(ROOT_DIR, 'conf')
    +CONF_DIR = '#{conf_path}'
    default_relayrules = join(CONF_DIR, 'relay-rules.conf')
    # Make sure that carbon's 'lib' dir is in the $PYTHONPATH if we're running from
    diff --git a/lib/carbon/conf.py b/lib/carbon/conf.py
    index 903fc09..3e310dc 100644
    --- a/lib/carbon/conf.py
    +++ b/lib/carbon/conf.py
    @@ -462,7 +462,7 @@ def read_config(program, options, **kwargs):
    # 'GRAPHITE_CONF_DIR' environment variable.
    settings.setdefault("CONF_DIR",
    os.environ.get("GRAPHITE_CONF_DIR",
    - join(graphite_root, "conf")))
    + '#{conf_path}'))
    if options["config"] is None:
    options["config"] = join(settings["CONF_DIR"], "carbon.conf")
    else:
    END
    end

    def which_python
    # Update this once we have something like [this](https://github.com/mxcl/homebrew/issues/11204)
    "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
    end
    end
    36 changes: 36 additions & 0 deletions whisper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    require 'formula'

    class Whisper < Formula
    homepage 'http://graphite.wikidot.com/'
    url 'http://pypi.python.org/packages/source/w/whisper/whisper-0.9.10.tar.gz'
    md5 '218aadafcc0a606f269b1b91b42bde3f'

    depends_on 'python'

    # https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
    def install
    # In order to install into the Cellar, the dir must exist and be in the PYTHONPATH.
    temp_site_packages = lib/which_python/'site-packages'
    mkdir_p temp_site_packages
    ENV['PYTHONPATH'] = temp_site_packages

    args = [
    "--no-user-cfg",
    "--verbose",
    "install",
    "--force",
    "--install-scripts=#{bin}",
    "--install-lib=#{temp_site_packages}",
    "--install-data=#{share}",
    "--install-headers=#{include}",
    "--record=installed-files.txt"
    ]

    system "python", "-s", "setup.py", *args
    end

    def which_python
    # Update this once we have something like [this](https://github.com/mxcl/homebrew/issues/11204)
    "python" + `python -c 'import sys;print(sys.version[:3])'`.strip
    end
    end