Skip to content

Instantly share code, notes, and snippets.

@bradediger
Created December 12, 2012 19:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradediger/4270727 to your computer and use it in GitHub Desktop.
Save bradediger/4270727 to your computer and use it in GitHub Desktop.
Homebrew formulae for graphite (carbon / whisper)
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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment