Permalink
Browse files

yay i finally have distutils working decently...

  • Loading branch information...
1 parent fd29e2c commit 12fc9595e1e72a8ecb7531cd380904d4b59ea608 @cdavis cdavis committed Sep 14, 2009
Showing with 44 additions and 298 deletions.
  1. +1 −0 .bzrignore
  2. +4 −0 MANIFEST.in
  3. +1 −4 misc/build_release.sh
  4. +0 −204 misc/install.py
  5. +0 −84 misc/post-install.py
  6. +3 −0 setup.cfg
  7. +35 −0 setup.py
  8. +0 −6 storage/schemas.default
View
@@ -0,0 +1 @@
+MANIFEST
View
@@ -0,0 +1,4 @@
+include INSTALL
+include LICENSE
+recursive-include webapp/graphite/ *.html
+recursive-include webapp/content/ *
View
@@ -10,7 +10,6 @@ fi
if [ ! -f LICENSE ]
then
echo "You must run this script from the top-level directory that contains the LICENSE file."
- echo "For example: misc/build_release.sh \$version"
exit 1
fi
@@ -23,9 +22,7 @@ base_dir="graphite-$version"
echo "Checking out a pristine copy of trunk"
bzr checkout lp:graphite $base_dir
-mv $base_dir/misc/install.py $base_dir
-mv $base_dir/misc/post-install.py $base_dir
-mv $base_dir/misc/generate-apache-config.py $base_dir
+
echo "Compressing"
tar czf ../graphite-${version}.tgz *
View
@@ -1,204 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, pwd, traceback, shutil
-from optparse import OptionParser
-
-def die(msg):
- print msg
- raise SystemExit(1)
-
-option_parser = OptionParser()
-option_parser.add_option('--install-root',default='/usr/local/graphite/',
- help="The base directory of the graphite installation, default: /usr/local/graphite/")
-
-(options,args) = option_parser.parse_args()
-
-install_root = options.install_root
-if not install_root.endswith('/'):
- install_root += '/'
-
-
-# Simple python version test
-major,minor = sys.version_info[:2]
-py_version = sys.version.split()[0]
-if major < 2 or (major == 2 and minor < 4):
- die("You are using python %s, but version 2.4 or greater is required" % py_version)
-if major > 2:
- die("Python 3.x is not supported yet")
-
-# Test for pycairo
-try:
- import cairo
-except:
- die("Unable to import the 'cairo' module, do you have pycairo installed for python %s?" % py_version)
-
-# Test that pycairo has the PNG backend
-try:
- surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 10, 10)
- del surface
-except:
- die("Failed to create an ImageSurface with cairo, you probably need to recompile cairo with PNG support")
-
-# Test for django
-try:
- import django
-except:
- die("Unable to import the 'django' module, do you have Django installed for python %s?" % py_version)
-
-# Verify django version
-if django.VERSION[0] < 1:
- version = '.'.join([str(v) for v in django.VERSION if v is not None])
- die("You have django version %s installed, but version 1.0 or greater is required" % version)
-
-# Test for pyparsing
-try:
- import pyparsing
-except:
- die("Unable to import the 'pyparsing' module, do you have pyparsing installed for python %s?" % py_version)
-
-# Test for mod_python
-try:
- import mod_python
-except:
- print "[WARNING] Unable to import the 'mod_python' module, do you have mod_python installed for python %s?" % py_version
- print "This means you will only be able to run graphite in the development server mode, which is not"
- print "recommended for production use."
-
-# Test for python-memcached
-try:
- import memcache
-except:
- print "[WARNING]"
- print "Unable to import the 'memcache' module, do you have python-memcached installed for python %s?" % py_version
- print "This feature is not required but greatly improves performance.\n"
-
-# Test for sqlite
-try:
- try:
- import sqlite3 #python 2.5+
- except:
- from pysqlite2 import dbapi2 #python 2.4
-except:
- print "[WARNING]"
- print "Unable to import the sqlite module, do you have python-sqlite2 installed for python %s?" % py_version
- print "If you plan on using another database backend that Django supports (such as mysql or postgres)"
- print "then don't worry about this. However if you do not want to setup the database yourself, you will"
- print "need to install sqlite2 and python-sqlite2.\n"
-
-# Test for python-ldap
-try:
- import ldap
-except:
- print "[wARNING]"
- print "Unable to import the 'ldap' module, do you have python-ldap installed for python %s?" % py_version
- print "Without python-ldap, you will not be able to use LDAP authentication in the graphite webapp.\n"
-
-# Prompt before installing
-print "Required dependencies are met, graphite will be installed into:"
-print " %s" % install_root
-
-while True:
- answer = raw_input("\nOk to continue [y/n]?").lower().strip()
- if answer == 'y':
- break
- if answer == 'n':
- raise SystemExit(0)
-
-# Verify permissions
-if not os.path.isdir(install_root):
- try:
- os.makedirs(install_root)
- except OSError, e:
- print "Failed to created install directory \"%s\": %s" % (install_root,e.strerror)
- raise SystemExit(1)
-else:
- if not os.access(install_root,os.R_OK|os.W_OK|os.X_OK):
- print "You do not have permission to install into \"%s\", you should use" % install_root
- print "a --install-root that you own, or run install.py as root."
- raise SystemExit(1)
-
-# Perform the installation
-print 'Copying files...'
-os.system("cp -rvf webapp/ %s" % install_root)
-os.system("cp -rvf storage/ %s" % install_root)
-os.system("cp -rvf carbon/ %s" % install_root)
-
-js_dir = os.path.join(install_root,'webapp','content','js')
-os.system("cp -rvf ext %s" % js_dir)
-
-#Setup local_settings.py
-try:
- local_settings_py = os.path.join(install_root, 'webapp', 'web', 'local_settings.py')
- local_settings_example = os.path.join(install_root, 'webapp', 'web', 'local_settings.py.example')
- if not os.path.isfile(local_settings_py):
- print "Creating an example local_settings.py\n"
- os.system("mv %s %s" % (local_settings_example, local_settings_py))
- else:
- print "local_settings.py exists, leaving untouched\n"
- os.system("rm -f %s" % local_settings_example)
-except:
- print "Error while inspecting local_settings.py (please report this as a bug!)"
- traceback.print_exc()
- print
-
-#Install the carbon init script
-inits_installed = False
-for init_dir in ('/etc/init.d/','/etc/rc.d/init.d/'):
- if os.path.isdir(init_dir) and os.access(init_dir, os.R_OK|os.W_OK|os.X_OK):
- print "Installing init scripts into %s\n" % init_dir
- inits_installed = True
- os.system("cp -f carbon/init-script.sh %s/carbon-agent.sh" % init_dir)
- break
-
-if not inits_installed:
- print "[Warning] Could not install carbon-agent init script, please install \"carbon/init-script.sh\" manually.\n"
-
-#Install the graphite package
-libs_option = ""
-
-if os.geteuid() == 0: #running as root, install to site-packages
- print 'Installing graphite library package to site-packages\n'
- dir = os.getcwd()
- os.chdir('lib/')
- os.system("%s setup.py install" % sys.executable)
- os.chdir(dir)
- try:
- import graphite
- except ImportError:
- traceback.print_exc()
- die("Installation of graphite library package failed")
-else: #non-root installation, prompt for where to install this package
- print 'You are not running the installer as root, so python modules cannot be installed in site-packages\n'
- username = pwd.getpwuid( os.geteuid() ).pw_name
- default_location = os.environ.get('HOME', "/home/%s" % username)
- while True:
- location = raw_input('Where would you like to install the graphite modules and scripts [%s]?' % default_location).strip()
- if not location:
- location = default_location
- libdir = os.path.join(location,'lib','python')
- bindir = os.path.join(location,'bin')
- print "Graphite modules will be installed in: %s" % libdir
- print "Graphite scripts will be installed in: %s" % bindir
- confirmation = raw_input("Is this ok [y/n]?").strip().lower()
- if confirmation == 'y':
- break
-
- dir = os.getcwd()
- os.chdir('lib/')
- os.system("%s setup.py install --home=%s" % (sys.executable, location))
- os.chdir(dir)
- try:
- sys.path.insert(0, libdir)
- try:
- import graphite
- except:
- traceback.print_exc()
- die("Installation of graphite library package failed")
- finally:
- sys.path.pop(0)
- print "Successfully installed graphite package under %s\n" % location
- libs_option = "--libs=%s" % libdir
-
-print "The install process is complete, if this is a first-time installation"
-print "you should run the following command to complete the remaining setup steps:\n"
-print "%s post-install.py --install-root=%s %s" % (sys.executable, install_root, libs_option)
View
@@ -1,84 +0,0 @@
-#!/usr/bin/env python
-
-import sys, os, pwd, traceback
-from optparse import OptionParser
-
-def die(msg):
- print msg
- raise SystemExit(1)
-
-option_parser = OptionParser()
-option_parser.add_option('--install-root',default='/usr/local/graphite/',
- help="The base directory of the graphite installation")
-option_parser.add_option('--libs',default=None,
- help="The directory where the graphite python package is installed (default is system site-packages)")
-
-(options,args) = option_parser.parse_args()
-
-install_root = options.install_root
-if not install_root.endswith('/'):
- install_root += '/'
-
-if not os.path.isdir(install_root):
- die("Graphite does not appear to be installed at %s, do you need to specify a different --install-root?" % install_root)
-
-print '\nUsing graphite install root: %s\n' % install_root
-
-if options.libs:
- libdir = os.path.expanduser(options.libs)
- print 'Adding %s to your PYTHONPATH\n' % libdir
- os.environ['PYTHONPATH'] = libdir + ':' + os.environ.get('PYTHONPATH','')
- libs_option = "--libs=%s" % libdir
-else:
- libs_option = ""
-
-#Find out what user the webapp & carbon will run as
-print "Permissions must be setup such that apache can write to certain files and directories."
-print "If you do not know what user Apache runs as, you can hit Ctrl-C and re-run this script later.\n"
-while True:
- try:
- username = raw_input("What user does Apache run as? ").strip()
- except KeyboardInterrupt:
- print "\nBye."
- sys.exit(0)
- if not username: continue
- try:
- userinfo = pwd.getpwnam(username)
- except:
- print "The user '%s' does not exist" % username
- continue
- break
-
-uid, gid = userinfo.pw_uid, userinfo.pw_gid
-
-#Setup django db
-print "Synchronizing Django database models"
-web_dir = os.path.join(install_root, 'webapp', 'web')
-cwd = os.getcwd()
-os.chdir(web_dir)
-os.system("%s manage.py syncdb" % sys.executable)
-os.chdir(cwd)
-
-#Set filesystem ownerships
-print
-for path in ('storage', 'storage/graphite.db', 'storage/whisper', 'storage/log', 'storage/lists', 'carbon/log', 'carbon/pid'):
- fullpath = os.path.join(install_root, path)
- if os.path.exists(fullpath):
- print "Changing ownership of %s to uid=%d gid=%d" % (fullpath,uid,gid)
- os.chown(fullpath,uid,gid)
-
-#Setup carbon user
-run_as_user = os.path.join(install_root, 'carbon', 'run_as_user')
-print
-print 'Creating file: %s' % run_as_user
-print 'Carbon will run as %s\n' % username
-fh = open(run_as_user,'w')
-fh.write(username)
-fh.close()
-
-#Generate apache config
-command = "./generate-apache-config.py --install-root=%s %s" % (install_root, libs_option)
-print "Running command: %s\n" % command
-os.system(command)
-
-print "\nPost-installation script complete, now modify the generated apache config to your needs then install it and restart apache.\n"
View
@@ -0,0 +1,3 @@
+[install]
+prefix = /opt/graphite
+install-lib = %(prefix)s/webapp
View
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+import os
+from glob import glob
+from distutils.core import setup
+
+
+storage_dirs = [ ('storage/whisper',[]), ('storage/lists',[]), ('storage/log',[]), ('storage/rrd',[]) ]
+
+webapp_content = {}
+
+for root, dirs, files in os.walk('webapp/content'):
+ for filename in files:
+ filepath = os.path.join(root, filename)
+
+ if root not in webapp_content:
+ webapp_content[root] = []
+
+ webapp_content[root].append(filepath)
+
+
+setup(
+ name='graphite',
+ version='0.9.5',
+ url='https://launchpad.net/graphite',
+ author='Chris Davis',
+ author_email='chrismd@gmail.com',
+ license='Apache Software License 2.0',
+ description='Enterprise scalable realtime graphing',
+ package_dir={'' : 'webapp'},
+ packages=['graphite', 'graphite.account', 'graphite.browser', 'graphite.cli', 'graphite.composer', 'graphite.render', 'graphite.whitelist'],
+ package_data={'graphite' : ['templates/*']},
+ scripts=glob('bin/*'),
+ data_files=webapp_content.items() + storage_dirs,
+)
View
@@ -1,6 +0,0 @@
-#[my_schema]
-#priority = 42 #used to determine the order in which schemas are tested to create a new file
- # matching is done highest to lowest.
-#pattern = "^some.*regex$" #if this pattern matches a given metric name, this schema will be used
- #to create the whisper file for that metric.
-#retentions = secondsPerDataPoint:numberOfDataPointsToStore, ... #ex: 60:120 is minutely data kept for two hours

0 comments on commit 12fc959

Please sign in to comment.