Skip to main content

Obsolete. Please migrate to absl-py instead.

Project description

Google Application Utilities for Python

This project is a small collection of utilities for building Python
applications. It includes some of the same set of utilities used to build and
run internal Python apps at Google.


* Simple application startup integrated with python-gflags.
* Subcommands for command-line applications.
* Option to drop into pdb on uncaught exceptions.
* Helper functions for dealing with files.
* High-level profiling tools.
* Timezone-aware wrappers for datetime.datetime classes.
* Improved TestCase with the same methods as unittest2, plus helpful flags for
test startup.
* google_test setuptools command for running tests.
* Helper module for creating application stubs.


To install the package, simply run:
python install

Google-Style Tests

Google-style tests (those run with basetest.main()) differ from setuptools-style
tests in that test modules are designed to be run as __main__. Setting up your
project to use Google-style tests is easy:

1. Create one or more test modules named '*' in a directory. Each test
module should have a main block that runs basetest.main():
# In tests/
from google.apputils import basetest

class MyTest(basetest.TestCase):
def testSomething(self):
self.assertTrue('my test')

if __name__ == '__main__':

2. Add a setup requirement on google-apputils and set the test_dir option:
# In
setup_requires = ['google-apputils>=0.2'],
test_dir = 'tests',

3. Run your tests:
python google_test

Google-Style Stub Scripts

Google-style binaries (run with are intended to be executed directly
at the top level, so you should not use a setuptools console_script entry point
to point at your main(). You can use distutils-style scripts if you want.

Another alternative is to use google.apputils.run_script_module, which is a
handy wrapper to execute a module directly as if it were a script:

1. Create a module like '' in your project:
# In my/
from google.apputils import run_script_module

def RunMyScript():
import my.script

def RunMyOtherScript():
import my.other_script

2. Set up entry points in that point to the functions in your stubs
# In
entry_points = {
'console_scripts': [
'my_script = my.stubs:RunMyScript',
'my_other_script = my.stubs.RunMyOtherScript',

There are also useful flags you can pass to your scripts to help you debug your
binaries; run your binary with --helpstub to see the full list.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for google-apputils, version 0.4.2
Filename, size File type Python version Upload date Hashes
Filename, size google_apputils-0.4.2-py2.7.egg (118.3 kB) File type Egg Python version 2.7 Upload date Hashes View
Filename, size google-apputils-0.4.2.tar.gz (81.1 kB) File type Source Python version None Upload date Hashes View
Filename, size (101.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page