Package: tg_bootstrap
ContentsStatus and LicenseWhat It DoesUsageGenerating ScriptsCreating a New ProjectInstalling From Generated ScriptsTo A Development SystemTo A Release SystemReducing DependenciesChanges & Newssvn trunk0.4Status and Licensetg_bootstrapis simple glue code betweenvirtualenvandTurboGears.It is written by Arlo Belshee.  It is licensed under anMIT-style permissive license.You can install it witheasy_install tg_bootstrap, or from thesubversion repositorywitheasy_installtg_bootstrap==dev.What It Doestg_bootstrapis a tool to create a TurboGears application in an
isolated Python environment with a minimal number of system dependencies.tg_bootstrapachieves the following:Create a one-click development config script.Create a one-click release deployment script.Remove your TurboGears-builtsetup.py’s dependency on TurboGears.These install scripts will set up your app on any machine (Linux, Mac, or Windows). The
machine need only have a bare Python install (you will also need command-line svn
on the path for your development machine). Your app will be completely
isolated from any other Python install on your development machine. It will not
share any packages either from or to your global system Python or any other Python
install.Both scripts will upgrade a previous version of your app if you install over the top of it.
The release script installs your app as an egg. The development script checks out
the source and install from there.TurboGears generates asetup.pyfor your app when you create it. Unfortunately, thissetup.pyimports a module (finddata.py) from TurboGears itself. Thus, even though
yoursetup.pyscript indicates that TurboGears is a dependency, it cannot be used
to install TurboGears on a machine that doesn’t already have TurboGears.To get around this problem, I have packaged TurboGears’finddata.pyin this bootstrapper.
This way, you need only havetg_bootstrapinstalled to run yoursetup.py. All the real
dependencies - the ones that version frequently - can be controlled by each app’ssetup.py.I will occasionally update thefinddata.pythat I include withtg_bootstrap. However, it
doesn’t need to support everything that the main TurboGearsfinddata.pysupports. After all,
you just use thisfinddata.pyfor long enough to install TurboGears on a new development machine.
After that, including during egg-based release installs, yoursetup.pyuses TurboGears’
then-currentfinddata.py.UsageGenerating ScriptsAssume you were a company with two different TurboGears applications. Here is a script
which will generate 4 scripts: release and development install scripts for each product:from tg_bootstrap import bootstrap

bootstrap.create_scripts(
  src_repository='http://svn.example.com/app1/trunk',
  proj='someapp',
  release_version='2.3.1b3')

bootstrap.create_scripts(
  src_repository='http://svn.example.com/otherapp/trunk',
  proj='otherapp',
  release_version='0.2.1')Creating a New ProjectTo create a brand-new TurboGears project without mucking up your system Python (by, say,
installing TurboGears into it), do the following:If necessary, create a subversion repository for your project(s).Add an empty directory for your new project’s source.Create a temporary virtualenv to work in. To do this by hand,Downloadvirtualenv.py.Using your system python, runpython virtualenv.py /tmp/sandbox/for/nowActivate that virtualenv. See thevirtualenv documentationfor
platform-specific instructions.In the virtualenv, runeasy_install tg_bootstrapandeasy_install TurboGears.Note to Vista users: easy_install is not yet aware of the Vista security model. Thus,
it creates an easy_install.exe application that doesn’t work on Vista! As a workaround,
you can use easy_install-script.py, run via virtualenv’s python. Take care, as Python’s
installer has associated .py files with your system python install. So if you have
activated a virtualenv, theneasy_install-script.pyfoowill install foo to your
system Python, whilepythoneasy_install-script.pyfoowill install it to your
virtualenv.In the active temporary virtualenv, check out your project’s empty directory.Use tg-admin in the virtualenv to create your project as normal.Update your project’s setup.py to usetg_bootstrap’sfinddata.py(see below).Commit your project.If you haven’t already, add another directory to your repository to contain your bootstrapping scripts.Extend your installer script generator to contain the command for your new app. Generate
and commit your install scripts.From any Python (system or virtualenv), run your development install script:pythonprojname-develop.py/sandbox/for/development/of/new/app.Delete the temporary bootstrapping virtualenv, and begin working as normal in your development
sandbox.Installing From Generated ScriptsTo A Development SystemTo start developing an existing project on a new machine, you need only:Make sure Python is installed on your machine.Make sure command-line svn is installed and on your path.Runpythonsomeproj-develop.py/sandbox/path/for/appThe script will create a virtualenv at/sandbox/path/for/app. Inside the virtualenv,
it will check out your project’s source to/sandbox/path/for/app/src. It will then
perform a development install of your project, including all dependencies, into that
virtualenv.If your project adds dependencies or you which to freshen your dependencies to
the latest version, just run your app’ssetup.pyscript from within the
virtualenv:python setup.py developTo A Release SystemTo package and deploy a project release, you need only:Package your application as an egg.Either upload your egg to pypi or copy it to your deployment / test server.Update the release number in your script generation script and regenerate your scripts.Make sure Python is installed on your target server.Runpythonsomeproj-release.py/deployment/path/for/appThe release script will create a virtualenv at/sandbox/path/for/app. It will install
your egg, and all its dependencies, into that virtualenv. At that point, you need only
do whatever your system requires to make your app live.Thevirtualenv documentationdescribes how
to configure common systems to run an app from a virtualenv. It includes descriptions
of shared persistent server mechanisms such as mod_python.Note:virtualenv.pysupports the--no-site-packagesoption. It defaults to
including your system Python’s site packages in your virtualenv. However, keeping dependencies
clean makes upgrades easier. Thus, install scripts generated withtg_bootstraphave the reverse default, and a--with-global-site-packagesoverride option.
If you usetg_bootstrapand don’t provide a command-line option, then your virtualenv
will start clean and blank; it will not have access to your machine’s system python libraries.The generated scripts accept all ofvirtualenv.py’s other options, unchanged.Reducing DependenciesTo use this, simply change the line of yoursetup.pywhich reads:from turbogears.finddata import find_package_datato read:try:
       from turbogears.finddata import find_package_data
except ImportError:
       from tg_bootstrap.finddata import find_package_dataThe rest ofsetup.pyis unchanged.Changes & Newssvn trunkNothing yet0.4DocumentationInitial version. Supports creating new projects without system dependencies.