Source

astdump /

Filename Size Date modified Message
180 B
1.1 KB
5.0 KB

Fetch module version without executing the module. Generates setup.py using information from the module. Can become handy for distutils.

$ ./astdump.py
Usage: astdump.py [options] <filename.py>

Read top level variables from the module without importing it. Additional keys
allow to generate setup.py automatically or view tree structure of an Abstract
Syntax Tree.

Options:
  -h, --help  show this help message and exit
  --dump      dump abstract syntax tree
  --generate  generate setup.py for a given filename

Examples:

$ ./astdump.py astdump.py
__author__ = 'anatoly techtonik <techtonik@gmail.com>'
__description__ = 'Extract information from Python module without importing it.'
__license__ = 'Public Domain'
__version__ = '0.5'
$ ./astdump.py astdump.py --generate
#!/usr/bin/env python
from distutils.core import setup

setup(
  name = 'astdump',
  version = '0.5',
  author = 'anatoly techtonik',
  author_email = 'techtonik@gmail.com',
  description = 'Extract information from Python module without importing it.',
  license = 'Public Domain',

  py_modules=['astdump'],
)