[doc,bin] add script to fetch & update most cw dependencies + some cubes stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 22 Sep 2010 17:01:51 +0200
branchstable
changeset 6304 228921b064c3
parent 6303 1aad5389c013
child 6305 3a87eaf226f6
[doc,bin] add script to fetch & update most cw dependencies + some cubes
bin/clone_deps.py
doc/book/en/admin/setup.rst
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/clone_deps.py	Wed Sep 22 17:01:51 2010 +0200
@@ -0,0 +1,115 @@
+#!/usr/bin/python
+import os
+import sys
+from subprocess import call, Popen, PIPE
+try:
+    from mercurial.dispatch import dispatch as hg_call
+except ImportError:
+    print '-' * 20
+    print "mercurial module is not reachable from this Python interpreter"
+    print "trying from command line ..."
+    tryhg = os.system('hg --version')
+    if tryhg:
+        print 'mercurial seems to unavailable, please install it'
+        raise
+    print 'found it, ok'
+    print '-' * 20
+    def hg_call(args):
+        call(['hg'] + args)
+from urllib import urlopen
+from os import path as osp, pardir
+from os.path import normpath, join, dirname
+
+BASE_URL = 'http://www.logilab.org/hg/'
+
+to_clone = ['fyzz', 'yams', 'rql',
+            'logilab/common', 'logilab/constraint', 'logilab/database',
+            'logilab/devtools', 'logilab/mtconverter',
+            'cubes/blog', 'cubes/calendar', 'cubes/card', 'cubes/comment',
+            'cubes/datafeed', 'cubes/email', 'cubes/file', 'cubes/folder',
+            'cubes/forgotpwd', 'cubes/keyword', 'cubes/link',
+            'cubes/mailinglist', 'cubes/nosylist', 'cubes/person',
+            'cubes/preview', 'cubes/registration', 'cubes/rememberme',
+            'cubes/tag', 'cubes/vcsfile', 'cubes/zone']
+
+# a couple of functions to be used to explore available
+# repositories and cubes
+def list_repos(repos_root):
+    assert repos_root.startswith('http://')
+    hgwebdir_repos = (repo.strip()
+                      for repo in urlopen(repos_root + '?style=raw').readlines()
+                      if repo.strip())
+    prefix = osp.commonprefix(hgwebdir_repos)
+    return (repo[len(prefix):].strip('/')
+            for repo in hgwebdir_repos)
+
+def list_all_cubes(base_url=BASE_URL):
+    all_repos = list_repos(base_url)
+    #search for cubes
+    for repo in all_repos:
+        if repo.startswith('cubes'):
+            to_clone.append(repo)
+
+def get_latest_debian_tag(path):
+    proc = Popen(['hg', '-R', path, 'tags'], stdout=PIPE)
+    out, _err = proc.communicate()
+    for line in out.splitlines():
+        if 'debian-version' in line:
+            return line.split()[0]
+
+def main():
+    if len(sys.argv) == 1:
+        base_url = BASE_URL
+    elif len(sys.argv) == 2:
+        base_url = sys.argv[1]
+    else:
+        print >> sys.stderr, 'usage %s [base_url]' %  sys.argv[0]
+        sys.exit(1)
+    print len(to_clone), 'repositories will be cloned'
+    base_dir = normpath(join(dirname(__file__), pardir, pardir))
+    os.chdir(base_dir)
+    not_updated = []
+    for repo in to_clone:
+        url = base_url + repo
+        if '/' not in repo:
+            target_path = repo
+        else:
+            assert repo.count('/') == 1, repo
+            directory, repo = repo.split('/')
+            if not osp.isdir(directory):
+                os.mkdir(directory)
+                open(join(directory, '__init__.py'), 'w').close()
+            target_path = osp.join(directory, repo)
+        if osp.exists(target_path):
+            print target_path, 'seems already cloned. Skipping it.'
+        else:
+            hg_call(['clone', '-U', url, target_path])
+            tag = get_latest_debian_tag(target_path)
+            if tag:
+                print 'updating to', tag
+                hg_call(['update', '-R', target_path, tag])
+            else:
+                not_updated.append(target_path)
+    print """
+CubicWeb dependencies and standard set of cubes have been fetched and
+update to the latest stable version.
+
+You should ensure your PYTHONPATH contains `%(basedir)s`.
+You might want to read the environment configuration section of the documentation
+at http://docs.cubicweb.org/admin/setup.html#environment-configuration
+
+You can find more cubes at http://www.cubicweb.org.
+Clone them from `%(baseurl)scubes/` into the `%(basedir)s%(sep)scubes%(sep)s` directory.
+
+To get started you may read http://docs.cubicweb.org/tutorials/base/index.html.
+""" % {'basedir': os.getcwd(), 'baseurl': base_url, 'sep': os.sep}
+    if not_updated:
+        print >> sys.stderr, 'WARNING: The following repositories were not updated (no debian tag found):'
+        for path in not_updated:
+            print >> sys.stderr, '\t-', path
+
+if __name__ == '__main__':
+    main()
+
+
+
--- a/doc/book/en/admin/setup.rst	Wed Sep 22 14:03:24 2010 +0200
+++ b/doc/book/en/admin/setup.rst	Wed Sep 22 17:01:51 2010 +0200
@@ -90,20 +90,29 @@
 Install from version control system
 ```````````````````````````````````
 
-You can keep up to date with on-going development by using Mercurial and its
-forest extension::
+You can keep up to date with on-going development by using Mercurial::
 
-  hg fclone http://www.logilab.org/hg/forests/cubicweb
+  hg clone http://www.logilab.org/hg/forests/cubicweb
 
 See :ref:`MercurialPresentation` for more details about Mercurial.
 
+A practical way to get many of CubicWeb's dependencies and a nice set
+of base cubes is to run the `clone_deps.py` script located in
+`cubicweb/bin/`::
+
+  python cubicweb/bin/clone_deps.py
+
+(Windows users should replace slashes with antislashes).
+
+This script will clone a set of mercurial repositories into in the
+directory containing the CubicWeb repository, and update them to the
+latest published version tag (if any).
+
 When cloning a repository, you might be set in a development branch
 (the 'default' branch). You should check that the branches of the
 repositories are set to 'stable' (using `hg up stable` for each one)
 if you do not intend to develop the framework itself.
 
-Do not forget to update the forest itself (using `cd path/to/forest ; hg up`).
-
 Make sure you also have all the :ref:`InstallDependencies`.
 
 
@@ -182,8 +191,7 @@
   http://www.graphviz.org/Download_windows.php
 
 Simplejson is needed when installing with Python 2.5, but included in the
-standard library for Python >= 2.6. It will be provided within the forest, but a
-win32 compiled version will run much faster::
+standard library for Python >= 2.6. Get it from there::
 
   http://www.osuch.org/python-simplejson%3Awin32
 
@@ -211,33 +219,10 @@
 Getting the sources
 ~~~~~~~~~~~~~~~~~~~
 
-You can either download the latest release (see :ref:`SourceInstallation`) or
-get the development version using Mercurial (see
-:ref:`MercurialInstallation` and below).
-
-To enable the Mercurial forest extension on Windows, edit the file::
-
-  C:\Program Files\TortoiseHg\Mercurial.ini
-
-In the [extensions] section, add the following line::
-
-  forest=C:\Program Files\TortoiseHg\ext\forest\forest.py
-
-Now, you need to clone the cubicweb repository. We assume that you use
-Eclipse. From the IDE, choose File -> Import. In the box, select `Mercurial/Clone
-repository using MercurialEclipse`.
-
-In the import main panel you just have to:
-
-* fill the URL field with http://www.logilab.org/hg/forests/cubicwin32
-
-* check the 'Repository is a forest' box.
-
-Then, click on 'Finish'. It might take some time to get it all. Note that the
-`cubicwin32` forest contains additional python packages such as yapps, vobject,
-simplejson and twisted-web2 which are not provided with Python(x,y). This is
-provided for convenience, as we do not ensure the up-to-dateness of these
-packages, especially with respect to security fixes.
+You can either download the latest release (see
+:ref:`SourceInstallation`) or get the development version using
+Mercurial (see :ref:`MercurialInstallation` and below), which is more
+convenient.
 
 Environment variables
 ~~~~~~~~~~~~~~~~~~~~~
@@ -274,7 +259,7 @@
 C:\\etc\\cubicweb.d.
 
 For a cube 'my_instance', you will then find
-C:\\etc\\cubicweb.d\\my_instance\\win32svc.py that has to be used as follows::
+C:\\etc\\cubicweb.d\\my_instance\\win32svc.py that has to be used thusly::
 
   win32svc install
 
@@ -303,17 +288,14 @@
 Databases configuration
 -----------------------
 
-Each instance can be configured with its own database connection information,
-that will be stored in the instance's :file:`sources` file. The database to use
-will be chosen when creating the instance. Currently cubicweb has been tested
-using Postgresql (recommended), MySQL, SQLServer and SQLite.
+Whatever the backend used, database connection information are stored in the
+instance's :file:`sources` file. Currently cubicweb has been tested using
+Postgresql (recommended), MySQL, SQLServer and SQLite.
 
 Other possible sources of data include CubicWeb, Subversion, LDAP and Mercurial,
-but at least one relational database is required for CubicWeb to work. You do
-not need to install a backend that you do not intend to use for one of your
-instances. SQLite is not fit for production use, but it works well for testing
-and ships with Python, which saves installation time when you want to get
-started quickly.
+but at least one relational database is required for CubicWeb to work. SQLite is
+not fit for production use, but it works for testing and ships with Python,
+which saves installation time when you want to get started quickly.
 
 .. _PostgresqlConfiguration: