#from __future__ import with_statement try: from paver.virtual import bootstrap from paver.misctasks import * except : # minilib does not support bootstrap pass #from paver.path25 import pushd from ConfigParser import ConfigParser from paver import svn from paver.doctools import html from paver.easy import path, sh, info from paver.easy import task, options, Bunch from paver.easy import call_task from paver.setuputils import setup from paver.tasks import help, needs from setuptools import find_packages import os import re import shutil version = '0.0' setup(name='GeoExtSite', version=version, description="GeoExt Website Builder", long_description=""" Tools for serving and building the GeoExt Website """, classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers keywords='', author='whit', author_email='whit@opengeo.org', url='http://www.geoext.org', license='MIT', packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), include_package_data=True, zip_safe=False, dependency_links=["http://svn.repoze.org/repoze.trac/trunk#egg=repoze.trac"], install_requires=["sphinx>=0.6.1", "PasteDeploy", "Paste", "PasteScript", "JSTools>=0.1.2", "repoze.trac" ], entry_points=""" """ ) curdir = os.path.abspath(os.curdir) options( virtualenv=Bunch(script_name="setup_website", packages_to_install=['pastescript'], paver_command_line="after_bootstrap" ), sphinx=Bunch(docroot="src/docsrc", builddir=path(curdir) / "built") ) @task def auto(): cp = ConfigParser() cp.read("website-conf.cfg") options(config=cp, core_url=cp.get("urls", "core")) @task @needs(['setuptool.command.develop', "build_docs"]) def build_all(): info("Not yet implemented") @task @needs(['setuptool.command.develop']) def after_bootstrap(): """ Setup website """ ## load_easypth() ## call_task("pavement.auto") ## call_task("pavement.parse_docs") ## call_task("pavement.build_docs") ## info("Now run: paster serve etc/dev.ini port=8080") @task def install_zine(): env = os.environ.get("VIRTUAL_ENV") if env is None: raise "Use $VIRTUAL_ENV." else: env = path(env) zinedir = path(curdir) / "build" / "zine" if not zinedir.exists(): # pip??? sh("%s/easy_install Werkzeug Jinja2 MySQL-python SQLAlchemy simplejson pytz Babel Cython lxml html5lib" %(env / "bin")) sh("hg clone http://dev.pocoo.org/hg/zine-main %s" %zinedir) sh("cd %s; ./configure --prefix=%s && make install" %(zinedir, env)) else: sh("cd %s; hg pull" %zinedir) @task def export_src(options): path("src").rmtree() if not "release" in options: release = "dev" else: release = options.release svn.export("%s/geoext/%s" %(options.core_url, options.config.get("releases", release)), "src/geoext") svn.export("%s/geoext-docsrc/%s" %(options.core_url, options.config.get("releases", release)), "src/docsrc") def find_path(file_list, regex): paths = [p for p in file_list if regex.findall(p)] if len(paths): return path(paths[0]) def load_easypth(): # could be smarter import sys easy_regex = re.compile(r'/easy-install.pth') st_regex = re.compile(r'/setuptools-.*\.egg') st_path = find_path(sys.path, st_regex) fn = path(st_path).dirname().listdir() epath = find_path(fn, easy_regex) paths = epath.open().readlines()[1:-1] curdir = path(__file__).dirname().abspath() epath.dirname().chdir() for p in paths: sys.path.append(str(path(p.strip()).abspath())) curdir.chdir() @task def parse_examples(): if not path("src/geoext").exists(): call_task("export_src") exdir = path("src/geoext/examples") js = [p for p in exdir.listdir() if p.endswith(".js")] odir = path("src/geoext/examples/tmp") odir.mkdir() out = odir / "examples.js" h = out.open("w") h.write("".join([f.open().read() for f in js])) h.close() @task @needs(['pavement.parse_examples']) def parse_docs(): from jstools.jst import DocParser parser = DocParser.from_fn("jst.cfg") parser.run() @task @needs(['pavement.parse_docs', 'paver.doctools.html']) def build_docs(): # will need to get smarter with new releases destdir = path('www') destdir.rmtree() builtdocs = options.builddir / "html" builtdocs.move(destdir) options.builddir.rmtree() @task @needs(['export_src', 'pavement.build_docs']) def dist(options): if not "release" in options: release = "dev" else: release = options.release version = options.config.get("releases", release).replace('tags/release-', '') build_dir = path("src/geoext/build") path.chdir(build_dir) sh("make release VERSION=%s" %version) path.chdir(path(curdir)); dist = build_dir.files("*.zip") for f in dist: f.copy(path(curdir)) path.chdir(build_dir) sh("make clean VERSION=%s" %version)