Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/tags/cherrypy-2.1.1/setup.py

Revision 919 (checked in by rdelon, 3 years ago)

Backporting security patch to 2.1.0. Preparing for 2.1.1 release

Line 
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 # arguments for the setup command
19 ###############################################################################
20 name = "CherryPy"
21 version = "2.1.1"
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",
39 ]
40 data_files=[
41     ('cherrypy/tutorial',
42         [
43             'cherrypy/tutorial/tutorial.conf',
44             'cherrypy/tutorial/README.txt',
45             'cherrypy/tutorial/pdf_file.pdf',
46             'cherrypy/tutorial/custom_error.html',
47         ]
48     ),
49     ('cherrypy', ['cherrypy/favicon.ico',]),
50     ('cherrypy/test', ['cherrypy/test/style.css',]),
51     ('cherrypy/test/static', ['cherrypy/test/static/index.html',
52                               'cherrypy/test/static/has space.html',]),
53 ]
54 ###############################################################################
55 # end arguments for setup
56 ###############################################################################
57
58
59 def main():
60     if sys.version < required_python_version:
61         s = "I'm sorry, but %s %s requires Python %s or later."
62         print s % (name, version, required_python_version)
63         sys.exit(1)
64
65     # set default location for "data_files" to platform specific "site-packages"
66     # location
67     for scheme in INSTALL_SCHEMES.values():
68         scheme['data'] = scheme['purelib']
69
70     dist = setup(
71         name=name,
72         version=version,
73         description=desc,
74         long_description=long_desc,
75         classifiers=classifiers,
76         author=author,
77         author_email=author_email,
78         url=url,
79         license=cp_license,
80         packages=packages,
81         data_files=data_files,
82     )
83
84     # the code in the following "if" block handles situations where the
85     # user has installed over an older release of 2.1 with a conflicting
86     # version of the sessionfilter
87     if 'install_lib' in dist.command_obj:
88        
89         # get the installation directory (is there a better way to do this?)
90         install_dir = dist.command_obj['install_lib'].install_dir
91
92         # make sure we have an absolute install path
93         install_dir = os.path.join(os.path.abspath('/'), install_dir)
94        
95         old_session_filter_path = os.path.join(
96             install_dir, 'cherrypy', 'lib', 'filter', 'sessionfilter')
97        
98         # check for existence of old sessionfilter package dir
99         # and prompt the user if it exists
100         if os.path.exists(old_session_filter_path):
101             handle_old_session_filter(old_session_filter_path)
102
103        
104 def handle_old_session_filter(pth):
105     warn_old_session_filter(pth)
106     choice = raw_input('Delete old sessionfilter directory? (yes/no): ')
107     if choice.lower() in ('y', 'yes'):
108         shutil.rmtree(pth)
109         print "Old sessionfilter directory deleted."
110     else:
111         print "You will need to manually need to delete the old sessionfilter directory."
112
113
114 def warn_old_session_filter(pth):
115     msg = """
116 ************************ WARNING *****************************
117  Since you have installed over the top of an existing CherryPy
118  installation, you must remove the old sessionfilter package
119  directory at:
120  %s
121 ************************ WARNING *****************************
122 """ % (pth,)
123     print msg
124    
125
126 if __name__ == "__main__":
127     main()
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets