Skip to content

Commit

Permalink
new setup
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitc committed Jan 28, 2011
1 parent 29331a5 commit a056340
Show file tree
Hide file tree
Showing 13 changed files with 162 additions and 35 deletions.
8 changes: 8 additions & 0 deletions Couchapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of couchapp released under the Apache 2 license.
# See the NOTICE for more information.

if __name__ == "__main__":
from couchapp import dispatch
8 changes: 8 additions & 0 deletions couchapp.pyw
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This file is part of couchapp released under the Apache 2 license.
# See the NOTICE for more information.

if __name__ == "__main__":
from couchapp import dispatch
2 changes: 2 additions & 0 deletions couchapp/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,5 @@ def parseopts(args, options, state):

return args

if __name__ in ('__main__', 'couchapp.dispatch'):
run()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions resources/scripts/couchapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env sh
# This file is part of couchapp released under the Apache 2 license.
# See the NOTICE for more information.

PYTHON_BIN=`which python`

$PYTHON_BIN -OO -c "import couchapp.dispatch"
5 changes: 5 additions & 0 deletions resources/scripts/couchapp.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo
REM This file is part of couchapp released under the Apache 2 license.
REM See the NOTICE for more information.

pythonw.exe -OO -c "import couchapp:dispatch"
6 changes: 6 additions & 0 deletions resources/scripts/couchapp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
#
# This file is part of couchapp released under the Apache 2 license.
# See the NOTICE for more information.

__import__("couchapp.dispatch")
File renamed without changes.
File renamed without changes.
161 changes: 126 additions & 35 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,17 @@
# See the NOTICE for more information.

from distutils.command.install_data import install_data
from distutils.core import setup

import os
import sys

if not hasattr(sys, 'version_info') or sys.version_info < (2, 5, 0, 'final'):
raise SystemExit("Couchapp requires Python 2.5 or later.")


from distutils.core import setup


setup_requires = []
extra = {}
data_files = []
for root in ('templates', 'vendor'):
for dir, dirs, files in os.walk(root):
dirs[:] = [x for x in dirs if not x.startswith('.')]
files = [x for x in files if not x.startswith('.')]
data_files.append((os.path.join('couchapp', dir),
[os.path.join(dir, file_) for file_ in files]))

class install_package_data(install_data):
def finalize_options(self):
self.set_undefined_options('install',
Expand All @@ -31,7 +23,73 @@ def finalize_options(self):

cmdclass = {'install_data': install_package_data }

if os.name == "nt":

def get_data_files():
data_files = []

data_files.append((os.curdir,
["LICENSE", "MANIFEST.in", "NOTICE", "README.md",
"THANKS.txt",]))

for root in ('templates', 'vendor'):
for dir, dirs, files in os.walk(root):
dirs[:] = [x for x in dirs if not x.startswith('.')]
files = [x for x in files if not x.startswith('.')]
data_files.append((os.path.join('couchapp', dir),
[os.path.join(dir, file_) for file_ in files]))

def get_include_files():
include_files = []

data_path_src = os.curdir
data_path_dst = os.curdir

filelist = ["LICENSE", "MANIFEST.in", "NOTICE", "README.md",
"THANKS.txt",]

for fl in filelist:
include_files.append((os.path.join(data_path_src, fl),
os.path.join(data_path_dst, fl)))

for root in ('templates', 'vendor'):
for dir, dirs, files in os.walk(root):
dirs[:] = [x for x in dirs if not x.startswith('.')]
files = [x for x in files if not x.startswith('.')]

for f in files:
src = os.path.join(dir, f)
include_files.append((src, src))

def get_packages_data():
return {
"couchapp": [
"templates/*",
"vendor/*"
]
}

def all_packages():
return [
'couchapp',
'couchapp.ext',
'couchapp.hooks',
'couchapp.hooks.compress',
'couchapp.restkit',
'couchapp.restkit.client',
'couchapp.restkit.conn',
'couchapp.restkit.filters',
'couchapp.restkit.http',
'couchapp.restkit.util',
'couchapp.vendors',
'couchapp.vendors.backends',
]

def get_scripts():
if os.name == "posix":
return [os.path.join("resources", "scripts", "couchapp")]
return [os.path.join("resources", "scripts", "couchapp.bat")]

if os.name == "nt" or sys.platform == "win32":
# py2exe needs to be installed to work
try:
import py2exe
Expand All @@ -50,10 +108,22 @@ def finalize_options(self):
except ImportError:
raise SystemExit('You need pywin32 installed ' +
'http:https://sourceforge.net/projects/pywin32')
extra['console'] = ['bin/couchapp.py']

# If run without args, build executables, in quiet mode.
if len(sys.argv) == 1:
sys.argv.append("py2exe")
sys.argv.append("-q")
Executable = lambda x, *y, **z: x
setup_requires = ["py2exe"]

except ImportError:
raise SystemExit('You need py2exe installed to run Couchapp.')

elif sys.platform == "linux2":
import cx_Freeze
from cx_Freeze import setup, Executable
setup_requires = ["cx_Freeze"]



from couchapp import __version__

Expand Down Expand Up @@ -82,31 +152,52 @@ def finalize_options(self):
'Topic :: Utilities',
],

packages = [
'couchapp',
'couchapp.ext',
'couchapp.hooks',
'couchapp.hooks.compress',
'couchapp.restkit',
'couchapp.restkit.client',
'couchapp.restkit.conn',
'couchapp.restkit.filters',
'couchapp.restkit.http',
'couchapp.restkit.util',
'couchapp.vendors',
'couchapp.vendors.backends',
],

data_files=data_files,

packages = all_packages(),
packages_data = get_packages_data(),
data_files=get_data_files(),
include_package_data = True,

cmdclass=cmdclass,

scripts=get_scripts(),

executables=[
Executable(
"Couchapp.py",
compress=1,
copyDependentFiles=True)
],

options = dict(py2exe={'dll_excludes': [ "kernelbase.dll", "powrprof.dll" ]},
options = dict(py2exe={
'compressed': 1,
'optimize': 2,
"ascii": 1,
"excludes": [
"pywin",
"pywin.debugger",
"pywin.debugger.dbgcon",
"pywin.dialogs",
"pywin.dialogs.list",
],
'dll_excludes': [
"kernelbase.dll",
"powrprof.dll"
]
},

build_exe={
"compressed": 1,
"optimize": 2,
"include_files": get_include_files(),
"create_shared_zip": 1,
"include_in_shared_zip": get_include_files()
},

bdist_mpkg=dict(zipdist=True,
license='LICENSE',
readme='contrib/macosx/Readme.html',
welcome='contrib/macosx/Welcome.html')),
readme='resources/macosx/Readme.html',
welcome='resources/macosx/Welcome.html')
),

entry_points="""
[couchapp.extension]
Expand All @@ -124,6 +215,6 @@ def finalize_options(self):
couchapp=couchapp.dispatch:run
""",

test_suite='tests',
setup_requires=setup_requires,
**extra
)

0 comments on commit a056340

Please sign in to comment.