#!/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

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=[] # No need for a "contributed_modules"
import os
for root, dirs, files in os.walk('gluon'): # find all *.py inside gluon automatically
  for candidate in ['.'.join(
      os.path.join(root,os.path.splitext(name)[0]).split(os.sep))
      for name in files if name.endswith('.py')
        and root.split(os.sep)!=['gluon','tests'] # Skip gluon/tests, it is not a module
      ]:
    packages.append(candidate)

setup(
  console=['web2py.py'],
  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),
    }},
  )
