Permalink
Browse files

Initial WIP skeleton

  • Loading branch information...
Almad committed Jul 25, 2010
0 parents commit 2c723d3f4282791e74b363623fb6d88721a7a537
Showing with 320 additions and 0 deletions.
  1. +9 −0 README.rst
  2. +98 −0 fabfile.py
  3. +144 −0 pavement.py
  4. 0 requirements.txt
  5. +6 −0 rpgplanet_meta/__init__.py
  6. +63 −0 setup.py
@@ -0,0 +1,9 @@
+RPG Planet meta package
+========================
+
+Unlike rpgplanet-all, which is merely developer repository for convenience and hacking around true git absence of svn:external, this repository is used as meta package: When on given version, it represents state of all dependend package (= whole rpgplanet family) in a given state (= versions).
+
+Not very important from developer perspective, but used heavily for deployment.
+
+Home of some scripting deployment stuff.
+
@@ -0,0 +1,98 @@
+from fabric.api import *
+
+project_docroots = {
+ "rpgplanet" : "/srv/www/rpgplanet.cz/www_root/www/htdocs",
+ # sub for subdomains
+ "rpghrac" : "/srv/www/rpghrac.cz/www_root/htdocs/sub/",
+}
+
+# this might be read from mypage-all/runcommand.py to have things on one place
+# however, considering deployments of new projects, it might make sense to have
+# devel versions in -all already, but not in deployment files.
+# Anyways, YAGNI, it's no such PITA to script this out. Reconsider when we are
+# going to have more than 10 sites deployed.
+
+env.services = project_docroots.keys()
+
+env.projects = projects = (
+ "rpgcommon",
+) + project_docroots.keys()
+
+libraries = (
+)
+
+env.packages = projects + libraries
+
+def setup():
+ """
+ Setup a fresh virtualenv and install everything we need so it's ready to
+ deploy to
+ """
+ run('mkdir -p $(applicationpath); cd $(applicationpath); virtualenv .; easy_install pip')
+
+def install_requirements():
+ """Install the required packages using pip"""
+ for package in env.packages:
+ run('cd $(applicationpath); pip install -E . -r ./$package/freezed-requirements.txt' % package)
+ run('cd $(applicationpath); cd %s; ./../bin/python setup.py develop' % package)
+
+def deploy_to_server():
+ setup()
+ install_requirements()
+ resymlink_media()
+ migrate_database()
+ resymlink_release()
+ restart_services()
+
+
+def deploy_preproduction(meta_version, dist_dir):
+ """Deploy the latest version of the site to the production server and """
+
+ env.hosts = ['melissar']
+
+ env.release = 'current'
+
+ env.applicationpath = '/srv/applications/w-rpgplanet-cz/rpgplanet/%s' % env.metaversion
+
+ env.meta_version = meta_version
+ env.dist_dir = dist_dir
+
+ deploy_to_server()
+
+
+def deploy(meta_version, dist_dir):
+ """Deploy the latest version of the site to the production server and """
+
+ env.hosts = ['kenshin:2222']
+
+ env.applicationpath = '/srv/applications/w-rpgplanet-cz/rpgplanet/%s' % env.version
+ env.user = 'w-rpgplanet-cz'
+
+ env.meta_version = meta_version
+ env.dist_dir = dist_dir
+
+ deploy_to_server()
+
+def resymlink_media():
+ raise NotImplementedError()
+ for package in env.packages:
+ if package in project_docroots:
+ run('cd %s; ln -sf' % project_docroots[package])
+
+def resymlink_release():
+ """Symlink our current release, uploads and settings file"""
+ raise NotImplementedError()
+# run('cd $(path); rm project; ln -s releases/current project; rm releases/current; ln -s $(release) releases/current')
+# run('cd $(path)/releases/current/; ln -s settings_$(settings).py settings.py', fail='ignore')
+# run('cd $(path)/releases/current/media/; ln -s ../../../shared/uploads/ .', fail='ignore')
+
+def migrate_database():
+ """Run our migrations"""
+ for package in env.packages:
+ run('cd $(applicationpath); cd %s; ./../bin/python manage.py syncdb --noinput --migrate' % package)
+
+def restart_services():
+ """Restart all project lighties"""
+ for service in env.services:
+ sudo('svc -t /etc/service/%s' % service)
+
@@ -0,0 +1,144 @@
+import os
+from os.path import join, pardir, abspath, dirname, split
+import sys
+from tempfile import mkdtemp
+
+from setuptools import find_packages
+
+from paver.easy import *
+from paver.setuputils import setup, Bunch
+
+
+VERSION = (0, 1, 0)
+
+__version__ = VERSION
+__versionstr__ = '.'.join(map(str, VERSION))
+
+setup(
+ name = 'rpgplanet_meta',
+ version = __versionstr__,
+ description = 'RPG Planet meta package',
+ long_description = '\n'.join((
+ 'RPG Planet Meta Package',
+ '',
+ '',
+ )),
+ author = 'Almad',
+ author_email='bugs@almad.net',
+ license = 'BSD',
+ url='http://github.com/rpgplanet/rpgplanet-meta',
+
+ dependencies_git_repositories = [
+ {
+ 'url': 'git://github.com/rpgplanet/rpgcommon.git',
+ 'branch': 'master',
+ 'package_name': 'rpgcommon',
+ },
+ {
+ 'url': 'git://github.com/rpgplanet/rpghrac.git',
+ 'branch': 'master',
+ 'package_name': 'rpghrac',
+ },
+ {
+ 'url': 'git://github.com/rpgplanet/rpgplanet.git',
+ 'branch': 'master',
+ 'package_name': 'rpgplanet',
+ },
+ ],
+
+ packages = find_packages(
+ where = '.',
+ exclude = ('docs', 'tests')
+ ),
+
+ include_package_data = True,
+
+ classifiers = [
+ 'Development Status :: 3 - Alpha',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Framework :: Django',
+ ],
+ setup_requires = [
+ 'setuptools_dummy',
+ ],
+ install_requires = [
+ 'setuptools>=0.6b1',
+ ],
+)
+
+options(
+ citools = Bunch(
+ rootdir = abspath(dirname(__file__))
+ ),
+)
+
+all_root = abspath(join(dirname(__file__), os.pardir))
+
+
+def run_all_command(cmd):
+ sh("%s '%s'" % (
+ abspath(join(all_root, 'bin', 'run.command.py')),
+ cmd
+ ))
+
+try:
+ from citools.pavement import *
+except ImportError:
+ pass
+
+@task
+def install_dependencies():
+ sh('pip install --upgrade -r requirements.txt')
+
+@task
+def bootstrap():
+ options.virtualenv = {'packages_to_install' : ['pip']}
+ call_task('paver.virtual.bootstrap')
+ sh("python bootstrap.py")
+ path('bootstrap.py').remove()
+
+
+ print '*'*80
+ if sys.platform in ('win32', 'winnt'):
+ print "* Before running other commands, You now *must* run %s" % os.path.join("bin", "activate.bat")
+ else:
+ print "* Before running other commands, You now *must* run source %s" % os.path.join("bin", "activate")
+ print '*'*80
+
+@task
+@needs('install_dependencies')
+def prepare():
+ """ Prepare complete environment """
+
+@task
+def prepare_packages():
+ curdir = os.getcwd()
+
+ options.package_dir = dir = mkdtemp(dir=all_root)
+ run_all_command('paver sdist --dist-dir=%s' % dir)
+
+ os.chdir(curdir)
+
+def compute_meta_version():
+ # it should be easy to do it using git clone --reference=dependencies_git_repositories
+ raise NotImplementedError("Need cache in citools or we're f*** up")
+
+@task
+@needs(['compute_meta_version', 'prepare_packages',])
+def deploy_preproduction():
+ sh('fab deploy_preproduction:meta_version=%(metaversion)s,dist_dir=%(distdir)s' % {
+ 'metaversion' : ,
+ 'distdir' : ,
+ })
+
+@task
+@needs(['compute_meta_version', 'prepare_packages',])
+def deploy():
+ sh('fab deploy_preproduction:meta_version=%(metaversion)s,dist_dir=%(distdir)s' % {
+ 'metaversion' : ,
+ 'distdir' : ,
+ })
+
No changes.
@@ -0,0 +1,6 @@
+VERSION = (0, 6, 0, 0)
+
+__version__ = VERSION
+__versionstr__ = '.'.join(map(str, VERSION))
+
+
@@ -0,0 +1,63 @@
+from setuptools import setup, find_packages
+
+
+VERSION = (0, 1, 0)
+
+__version__ = VERSION
+__versionstr__ = '.'.join(map(str, VERSION))
+
+
+setup(
+ name = 'rpgplanet_meta',
+ version = __versionstr__,
+ description = 'RPG Planet meta package',
+ long_description = '\n'.join((
+ 'RPG Planet Meta Package',
+ '',
+ '',
+ )),
+ author = 'Almad',
+ author_email='bugs@almad.net',
+ license = 'BSD',
+ url='http://github.com/rpgplanet/rpgplanet-meta',
+
+ dependencies_git_repositories = [
+ {
+ 'url': 'git://github.com/rpgplanet/rpgcommon.git',
+ 'branch': 'master',
+ 'package_name': 'rpgcommon',
+ },
+ {
+ 'url': 'git://github.com/rpgplanet/rpghrac.git',
+ 'branch': 'master',
+ 'package_name': 'rpghrac',
+ },
+ {
+ 'url': 'git://github.com/rpgplanet/rpgplanet.git',
+ 'branch': 'master',
+ 'package_name': 'rpgplanet',
+ },
+ ],
+
+ packages = find_packages(
+ where = '.',
+ exclude = ('docs', 'tests')
+ ),
+
+ include_package_data = True,
+
+ classifiers = [
+ 'Development Status :: 3 - Alpha',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'Operating System :: OS Independent',
+ 'Programming Language :: Python',
+ 'Framework :: Django',
+ ],
+ setup_requires = [
+ 'setuptools_dummy',
+ ],
+ install_requires = [
+ 'setuptools>=0.6b1',
+ ],
+)

0 comments on commit 2c723d3

Please sign in to comment.