setup.py :  » Web-Frameworks » Karrigell » Karrigell-3.1 » karrigell » dist » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Web Frameworks » Karrigell 
Karrigell » Karrigell 3.1 » karrigell » dist » setup.py
import os
import sys
import tempfile
import zipfile

# customize these lines for your application
app_name = "MyKarrigellApplication"
version = "1.0"
author = "Pierre Quentel",
author_email = "pierre.quentel@gmail.com"
# choose the built-in server
server = "Karrigell.py"

from distutils.core import setup
import py2exe

# ugly hacks to make "import Karrigell" work
this_dir = os.path.dirname(__file__)
server_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.append(server_dir)
os.chdir(server_dir)
sys.argv[0] = os.path.join(server_dir,"Karrigell.py")
sys.argv.append(server_dir)

# aaah !
import Karrigell
conf = Karrigell.k_config.config[None]
cache_dir = conf.cache_dir

del sys.argv[-1]
sys.argv.append('-q')
sys.argv.append('py2exe')

temp_dir = tempfile.mkdtemp()
excluded = [".pyc",".pdl",".bat",".sqlite"]
data_files = []

def is_valid(filename):
    base,ext = os.path.splitext(filename)
    if ext.lower() in excluded:
        return False
    if ext == '.dat' and base != "translations":
        return False
    return True

for dirpath,dirnames,filenames in os.walk(os.getcwd()):

    if dirpath == cache_dir:
        continue
    if dirpath.endswith('.svn'):
        del dirnames[:]
        continue
    _dirpath = dirpath[len(os.getcwd())+1:]
    filenames = [ os.path.join(dirpath,f)[len(os.getcwd())+1:]
        for f in filenames 
        if is_valid(f) ]
    data_files.append((_dirpath,filenames))

setup(
    name = app_name,
    version = version,
    author = author,
    author_email = author_email,
    license = "BSD",
    options = {'py2exe':
            {'bundle_files':1,
             'includes':['mimetypes','Cookie','cgi','shutil','gzip',
                'sqlite3','csv','ConfigParser'],
             'packages':['email'],
             'dist_dir':temp_dir}
        },
    data_files = data_files,
    console = [{"script":server}
        ]
    )

path = os.path.join(temp_dir)

exe = zipfile.ZipFile("%s-%s.zip" %(app_name,version),"w",
    zipfile.ZIP_DEFLATED)
for dirpath,dirnames,filenames in os.walk(path):
    if dirpath == path:
        filenames = [ f for f in filenames
            if not f=="setup.py"
            and not (os.path.splitext(f)[1]==".py" and f.startswith("Karrigell"))]
    for f in filenames:
        f_path = os.path.join(dirpath,f)
        exe.write(f_path,os.path.join(app_name,f_path[len(path)+1:]))
exe.close()

# cleanup server dir
build_dir = os.path.join(server_dir,'build')
if os.path.exists(build_dir):
    import shutil
    shutil.rmtree(build_dir)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.