Skip to content

Instantly share code, notes, and snippets.

@embray
Created September 2, 2011 19:29
Show Gist options
  • Save embray/1189618 to your computer and use it in GitHub Desktop.
Save embray/1189618 to your computer and use it in GitHub Desktop.
A d2to1 example of setup_hooks and pre/post command hooks
$ ./setup.py build
Setting up testproj
running build
running pre_hook testproj.pre_build_hook for command build
Someone is building my project!
running build_py
running post_hook testproj.post_build_hook for command build
Someone built my project!
[metadata]
name = testproj
version = 0.1
[files]
modules = testproj
[global]
setup-hooks = testproj.setup_hook
[build]
pre-hook.test-hook = testproj.pre_build_hook
post-hook.test-hook = testproj.post_build_hook
#!/usr/bin/env python
from setuptools import setup
setup(
setup_requires=['d2to1'],
d2to1=True
)
def setup_hook(cfg):
print 'Setting up %s' % cfg['metadata']['name']
def pre_build_hook(cmd):
print 'Someone is building my project!'
def post_build_hook(cmd):
print 'Someone built my project!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment