Bootstrap a TurboGears app in a VirtualEnv
It is written by Arlo Belshee. It is licensed under an MIT-style permissive license.
You can install it with easy_install tg_bootstrap, or from the subversion repository with easy_install tg_bootstrap==dev.
tg_bootstrap is a tool to create a TurboGears application in an isolated Python environment with a minimal number of system dependencies.
tg_bootstrap achieves the following:
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 a setup.py for your app when you create it. Unfortunately, this setup.py imports a module (finddata.py) from TurboGears itself. Thus, even though your setup.py script 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.py in this bootstrapper. This way, you need only have tg_bootstrap installed to run your setup.py. All the real dependencies - the ones that version frequently - can be controlled by each app’s setup.py.
I will occasionally update the finddata.py that I include with tg_bootstrap. However, it doesn’t need to support everything that the main TurboGears finddata.py supports. After all, you just use this finddata.py for long enough to install TurboGears on a new development machine. After that, including during egg-based release installs, your setup.py uses TurboGears’ then-current finddata.py.
Assume 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')
To create a brand-new TurboGears project without mucking up your system Python (by, say, installing TurboGears into it), do the following:
To start developing an existing project on a new machine, you need only:
The 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’s setup.py script from within the virtualenv:
python setup.py develop
To package and deploy a project release, you need only:
The 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.
The virtualenv documentation describes 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.py supports the --no-site-packages option. It defaults to including your system Python’s site packages in your virtualenv. However, keeping dependencies clean makes upgrades easier. Thus, install scripts generated with tg_bootstrap have the reverse default, and a --with-global-site-packages override option. If you use tg_bootstrap and 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 of virtualenv.py’s other options, unchanged.
To use this, simply change the line of your setup.py which reads:
from turbogears.finddata import find_package_data
try: from turbogears.finddata import find_package_data except ImportError: from tg_bootstrap.finddata import find_package_data
The rest of setup.py is unchanged.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|tg_bootstrap-0.4.0-py2.5.egg (16.9 kB) Copy SHA256 Checksum SHA256||2.5||Egg||Jan 12, 2008|
|tg_bootstrap-0.4.0.zip (16.2 kB) Copy SHA256 Checksum SHA256||–||Source||Jan 12, 2008|