| 1 |
"""Installs CherryPy using distutils |
|---|
| 2 |
|
|---|
| 3 |
Run: |
|---|
| 4 |
python setup.py install |
|---|
| 5 |
|
|---|
| 6 |
to install this package. |
|---|
| 7 |
""" |
|---|
| 8 |
|
|---|
| 9 |
from distutils.core import setup |
|---|
| 10 |
from distutils.command.install import INSTALL_SCHEMES |
|---|
| 11 |
import sys |
|---|
| 12 |
import os |
|---|
| 13 |
import shutil |
|---|
| 14 |
|
|---|
| 15 |
required_python_version = '2.3' |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
name = "CherryPy" |
|---|
| 21 |
version = "2.2.0beta" |
|---|
| 22 |
desc = "Object-Oriented web development framework" |
|---|
| 23 |
long_desc = "CherryPy is a pythonic, object-oriented web development framework" |
|---|
| 24 |
classifiers=[ |
|---|
| 25 |
"Development Status :: Stable", |
|---|
| 26 |
"Intended Audience :: Developers", |
|---|
| 27 |
"License :: Freely Distributable", |
|---|
| 28 |
"Programming Language :: Python", |
|---|
| 29 |
"Topic :: Internet ", |
|---|
| 30 |
"Topic :: Software Development :: Libraries :: Application Frameworks", |
|---|
| 31 |
] |
|---|
| 32 |
author="CherryPy Team" |
|---|
| 33 |
author_email="team@cherrypy.org" |
|---|
| 34 |
url="http://www.cherrypy.org" |
|---|
| 35 |
cp_license="BSD" |
|---|
| 36 |
packages=[ |
|---|
| 37 |
"cherrypy", "cherrypy.lib", "cherrypy.lib.filter", |
|---|
| 38 |
"cherrypy.tutorial", "cherrypy.test", "cherrypy.filters", |
|---|
| 39 |
] |
|---|
| 40 |
download_url="http://sourceforge.net/project/showfiles.php?group_id=56099" |
|---|
| 41 |
data_files=[ |
|---|
| 42 |
('cherrypy/tutorial', |
|---|
| 43 |
[ |
|---|
| 44 |
'cherrypy/tutorial/tutorial.conf', |
|---|
| 45 |
'cherrypy/tutorial/README.txt', |
|---|
| 46 |
'cherrypy/tutorial/pdf_file.pdf', |
|---|
| 47 |
'cherrypy/tutorial/custom_error.html', |
|---|
| 48 |
] |
|---|
| 49 |
), |
|---|
| 50 |
('cherrypy', ['cherrypy/favicon.ico',]), |
|---|
| 51 |
('cherrypy/test', ['cherrypy/test/style.css',]), |
|---|
| 52 |
('cherrypy/test/static', ['cherrypy/test/static/index.html', |
|---|
| 53 |
'cherrypy/test/static/has space.html',]), |
|---|
| 54 |
] |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
def main(): |
|---|
| 61 |
if sys.version < required_python_version: |
|---|
| 62 |
s = "I'm sorry, but %s %s requires Python %s or later." |
|---|
| 63 |
print s % (name, version, required_python_version) |
|---|
| 64 |
sys.exit(1) |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
for scheme in INSTALL_SCHEMES.values(): |
|---|
| 69 |
scheme['data'] = scheme['purelib'] |
|---|
| 70 |
|
|---|
| 71 |
dist = setup( |
|---|
| 72 |
name=name, |
|---|
| 73 |
version=version, |
|---|
| 74 |
description=desc, |
|---|
| 75 |
long_description=long_desc, |
|---|
| 76 |
classifiers=classifiers, |
|---|
| 77 |
author=author, |
|---|
| 78 |
author_email=author_email, |
|---|
| 79 |
url=url, |
|---|
| 80 |
license=cp_license, |
|---|
| 81 |
packages=packages, |
|---|
| 82 |
download_url=download_url, |
|---|
| 83 |
data_files=data_files, |
|---|
| 84 |
) |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
if 'install_lib' in dist.command_obj: |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
install_dir = dist.command_obj['install_lib'].install_dir |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
install_dir = os.path.join(os.path.abspath('/'), install_dir) |
|---|
| 96 |
|
|---|
| 97 |
old_session_filter_path = os.path.join( |
|---|
| 98 |
install_dir, 'cherrypy', 'lib', 'filter', 'sessionfilter') |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
if os.path.exists(old_session_filter_path): |
|---|
| 103 |
handle_old_session_filter(old_session_filter_path) |
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
def handle_old_session_filter(pth): |
|---|
| 107 |
warn_old_session_filter(pth) |
|---|
| 108 |
choice = raw_input('Delete old sessionfilter directory? (yes/no): ') |
|---|
| 109 |
if choice.lower() in ('y', 'yes'): |
|---|
| 110 |
shutil.rmtree(pth) |
|---|
| 111 |
print "Old sessionfilter directory deleted." |
|---|
| 112 |
else: |
|---|
| 113 |
print "You will need to manually need to delete the old sessionfilter directory." |
|---|
| 114 |
|
|---|
| 115 |
|
|---|
| 116 |
def warn_old_session_filter(pth): |
|---|
| 117 |
msg = """ |
|---|
| 118 |
************************ WARNING ***************************** |
|---|
| 119 |
Since you have installed over the top of an existing CherryPy |
|---|
| 120 |
installation, you must remove the old sessionfilter package |
|---|
| 121 |
directory at: |
|---|
| 122 |
%s |
|---|
| 123 |
************************ WARNING ***************************** |
|---|
| 124 |
""" % (pth,) |
|---|
| 125 |
print msg |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
if __name__ == "__main__": |
|---|
| 129 |
main() |
|---|