Zine

open source content publishing system


source: scripts/_make-setup-virtualenv.py @ 1375:01b77c91b28e

Revision 1375:01b77c91b28e, 2.4 KB checked in by mitsuhiko, 2 years ago (diff)

Merged

Line 
1# -*- coding: utf-8 -*-
2"""
3    _make-setup-virtualenv.py
4    ~~~~~~~~~~~~~~~~~~~~~~~~~
5
6    Execute this file to regenerate the `setup-virtualenv` script.
7
8    :copyright: (c) 2010 by the Zine Team, see AUTHORS for more details.
9    :license: BSD, see LICENSE for more details.
10"""
11import os
12from virtualenv import create_bootstrap_script
13
14
15FILENAME = 'setup-virtualenv'
16CODE = '''
17import os
18import sys
19from subprocess import call
20
21# requirements without lxml, because lxml is special for OS X
22REQUIREMENTS = [
23    'Werkzeug>=0.6',
24    'Jinja2>=2.1',
25    'SQLAlchemy>=0.6',
26    'pytz',
27    'Babel>=0.9.4',
28    'sqlalchemy-migrate>=0.6'
29]
30
31# for python 2.5 we want simplejson installed too.
32if sys.version_info < (2, 6):
33    REQUIREMENTS.append('simplejson')
34
35# os x has some problems with lxml, make sure the user has port installed
36# so that we can compile lxml
37lxml_static_deps=False
38if sys.platform == 'darwin':
39    print '=' * 60
40    print 'It appears that you are using OS X.  If an installation error'
41    print 'occurs on installing lxml, please make sure you have port'
42    print 'installed.'
43    print '=' * 60
44
45    # no idea if that actually helps, but let's hope it does :D
46    _dyld_path = os.environ.get('DYLD_LIBRARY_PATH', '')
47    if _dyld_path:
48        _dyld_path += ':'
49    _dyld_path += '/opt/local/lib'
50    os.environ['DYLD_LIBRARY_PATH']= _dyld_path
51    lxml_static_deps = True
52
53def install(home_dir, *args, **kw):
54    static_deps = kw.pop('static_deps', False)
55    if kw:
56        raise TypeError('too many keyword arguments')
57    env = None
58    if static_deps:
59        env = dict(os.environ.items())
60        env['STATIC_DEPS'] = 'true'
61    call([os.path.join(home_dir, 'bin', 'easy_install')] + list(args), env=env)
62
63def after_install(options, home_dir):
64    site_packages = os.path.normpath(os.path.join(home_dir, 'lib', 'python%%d.%%d'
65        %% sys.version_info[:2], 'site-packages'))
66    for requirement in REQUIREMENTS:
67        install(home_dir, requirement)
68    install(home_dir, 'lxml>=2.0', static_deps=lxml_static_deps)
69    call(['ln', '-s', %(zine_path)r, os.path.join(site_packages, 'zine')])
70'''
71
72
73if __name__ == '__main__':
74    os.chdir(os.path.dirname(__file__) or '.')
75    f = file(FILENAME, 'w')
76    try:
77        f.write(create_bootstrap_script(CODE % {
78            'zine_path':    os.path.normpath(os.path.join('..', 'zine'))
79        }))
80    finally:
81        f.close()
82    os.chmod(FILENAME, 0755)
Note: See TracBrowser for help on using the repository browser.