#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from distutils.core import setup
import py2exe

APP = ['web2py.py']
DATA_FILES = [
    'admin.w2p',
    'examples.w2p',
    'welcome.w2p',
    'ABOUT',
    'LICENSE',
    'VERSION',
    ]

import sys,gluon.import_all
python_base_version = sys.version[:3]
includes=set(gluon.import_all.base_modules) - set(['os.path'])
if python_base_version!='2.6':
  includes -= set(['json','multiprocessing'])

packages=[] # We can manually define some extra modules here.
import os   # Or try to find all *.py inside gluon compulsively.
for root, dirs, files in os.walk('gluon'): # No need for a "contributed_modules"
  for candidate in ['.'.join(
      os.path.join(root,os.path.splitext(name)[0]).split(os.sep))
      for name in files if name.endswith('.py')]:
    try: exec('import %s'%candidate)
    except: pass # to skip gluon.tests
    else: packages.append(candidate)
setup(
  console=APP,
  windows=[{'script':'web2py.py','dest_base':'web2py_no_console'}], # Perhaps not applicable to Mac
  data_files=DATA_FILES,
  options={ 'py2exe': {
    'packages':packages,
    'includes':list(includes),
    }},
  )
