sbin/create_python_env.py
changeset 33 b25bb1dd177c
parent 32 e28089cee66c
child 34 05d10640919a
equal deleted inserted replaced
32:e28089cee66c 33:b25bb1dd177c
     6 
     6 
     7 - virtualenv
     7 - virtualenv
     8 - distribute
     8 - distribute
     9 - psycopg2 requires the PostgreSQL libpq libraries and the pg_config utility
     9 - psycopg2 requires the PostgreSQL libpq libraries and the pg_config utility
    10 
    10 
       
    11 - virtualenv --distribute --no-site-packages venv
    11 
    12 
    12 """
    13 """
    13 import os
    14 import os
    14 import subprocess
    15 import subprocess
    15 import re
    16 import re
    19 script_name = os.path.join(base_dir, 'blinkster-boot.py')
    20 script_name = os.path.join(base_dir, 'blinkster-boot.py')
    20 
    21 
    21 import virtualenv
    22 import virtualenv
    22 
    23 
    23 # things to install
    24 # things to install
    24 # - psycopg2
    25 # - psycopg2 -> pip
    25 # - PIL
    26 # - PIL -> pip
    26 # - pylucene
    27 # - pyxml -> pip
    27 # - pyxml
    28 # - 4Suite-xml - easy_install ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2
    28 # - 4Suite-xml
    29 # - pylucene  - script
       
    30 
    29 
    31 
    30 
    32 
    31 EXTRA_TEXT = """
    33 EXTRA_TEXT = """
    32 
    34 
    33 import shutil
    35 import shutil
    34 import tarfile
    36 import tarfile
    35 import urllib
    37 import urllib
    36 
    38 
       
    39 4SUITE_XML_URL = 'ftp://ftp.4suite.org/pub/4Suite/4Suite-XML-1.0.2.tar.bz2'
       
    40 PY_LUCENE_URL = 'http://apache.crihan.fr/dist/lucene/pylucene/pylucene-3.0.1-1-src.tar.gz'
       
    41 
    37 def extend_parser(parser):
    42 def extend_parser(parser):
    38     parser.add_option(
    43     pass
    39         '--svn',
       
    40         metavar='DIR_OR_URL',
       
    41         dest='fassembler_svn',
       
    42         default=FASS_SVN_LOCATION,
       
    43         help='Location of a svn directory or URL to use for the installation of fassembler')
       
    44 
    44 
    45 def adjust_options(options, args):
    45 def adjust_options(options, args):
    46     if not args:
    46     if not args:
    47         return # caller will raise error
    47         return # caller will raise error
    48     
    48     
    53     else:
    53     else:
    54         venv_name = "blinkster"
    54         venv_name = "blinkster"
    55         
    55         
    56     args[0] = join(base_dir, venv_name)
    56     args[0] = join(base_dir, venv_name)
    57 
    57 
       
    58 
    58 def after_install(options, home_dir):
    59 def after_install(options, home_dir):
    59     base_dir = os.path.dirname(home_dir)
    60     base_dir = os.path.dirname(home_dir)
    60     src_dir = join(home_dir, 'src')
    61     src_dir = join(home_dir, 'src')
    61     tmp_dir = join(home_dir, 'tmp')
    62     tmp_dir = join(home_dir, 'tmp')
    62     ensure_dir(src_dir)
    63     ensure_dir(src_dir)
    63     ensure_dir(tmp_dir)
    64     ensure_dir(tmp_dir)
    64     #logger.indent += 2
    65     #logger.indent += 2
    65     try:
    66     try:
    66         call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), 'psycopg2'],
    67         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), ,'-E '+ os.path.abspath(home_dir), 'psycopg2', 'pil', 'pyxml'],
    67                         cwd=os.path.abspath(tmp_dir),
    68                         cwd=os.path.abspath(tmp_dir),
    68                         filter_stdout=filter_python_develop,
    69                         filter_stdout=filter_python_develop,
    69                         show_stdout=False)
    70                         show_stdout=False)
    70         call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), 'pyxml'],
    71         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), 4SUITE_XML_URL],
    71                         cwd=os.path.abspath(tmp_dir),
       
    72                         filter_stdout=filter_python_develop,
       
    73                         show_stdout=False)
       
    74         call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), '4suite-xml'],
       
    75                         cwd=os.path.abspath(tmp_dir),
       
    76                         filter_stdout=filter_python_develop,
       
    77                         show_stdout=False)
       
    78         call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), 'pil'],
       
    79                         cwd=os.path.abspath(tmp_dir),
       
    80                         filter_stdout=filter_python_develop,
       
    81                         show_stdout=False)
       
    82         call_subprocess([os.path.abspath(join(home_dir, 'bin', 'easy_install')), 'pil'],
       
    83                         cwd=os.path.abspath(tmp_dir),
    72                         cwd=os.path.abspath(tmp_dir),
    84                         filter_stdout=filter_python_develop,
    73                         filter_stdout=filter_python_develop,
    85                         show_stdout=False)
    74                         show_stdout=False)
    86 
    75 
    87 #get pylucene
    76         #get pylucene
    88 #cd jcc
    77         pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
    89 #install jcc
    78         urllib.urlretrieve(PY_LUCENE_URL, pylucene_src)
    90 #cd pylucene
    79         tf = tarfile.open(pylucene_src,'r:gz')
    91 #instqll pylucene
    80         tf.extractall(os.path.join(src_dir,"pylucene"))
       
    81         tf.close()
       
    82         #install jcc
       
    83         call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
       
    84                         cwd=os.path.abspath(os.path.join(src_dir,"pylucene","pylucene-3.0.1-1","jcc")),
       
    85                         filter_stdout=filter_python_develop,
       
    86                         show_stdout=False)
       
    87         #install pylucene       
       
    88         #modify makefile 
       
    89 #PREFIX_PYTHON=os.path.abspath(fassembler_dir)
       
    90 #ANT=ant
       
    91 #PYTHON=$(PREFIX_PYTHON)/bin/python
       
    92 #osx 10.5 10.6 32-64 bit
       
    93 #JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386
       
    94 #NUM_FILES=2
       
    95 
       
    96 #linux 
       
    97 #JCC=$(PYTHON) -m jcc --shared
       
    98 #NUM_FILES=2
       
    99 
       
   100 # windows
       
   101 #JCC=$(PYTHON) -m jcc --shared
       
   102 #NUM_FILES=3
       
   103 
       
   104 
       
   105 #install pylucene
    92 #delete src
   106 #delete src
    93         #call_subprocess([os.path.abspath(join(home_dir, 'bin', 'python')), 'setup.py', 'develop'],
   107         #call_subprocess([os.path.abspath(join(home_dir, 'bin', 'python')), 'setup.py', 'develop'],
    94         #                cwd=os.path.abspath(fassembler_dir),
   108         #                cwd=os.path.abspath(fassembler_dir),
    95         #                filter_stdout=filter_python_develop,
   109         #                filter_stdout=filter_python_develop,
    96         #                show_stdout=False)
   110         #                show_stdout=False)
    97     finally:
   111     finally:
    98         logger.indent -= 2
   112         #logger.indent -= 2
    99     script_dir = join(base_dir, 'bin')
   113     script_dir = join(base_dir, 'bin')
   100     logger.notify('Run "%s Package" to install new packages that provide builds'
   114     logger.notify('Run "%s Package" to install new packages that provide builds'
   101                   % join(script_dir, 'easy_install'))
   115                   % join(script_dir, 'easy_install'))
   102 
   116 
   103 def ensure_dir(dir):
   117 def ensure_dir(dir):
   115             return Logger.DEBUG
   129             return Logger.DEBUG
   116     return Logger.NOTIFY
   130     return Logger.NOTIFY
   117 """
   131 """
   118 
   132 
   119 def main():
   133 def main():
   120     text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version='2.4')
   134     python_version = ".".join(map(str,sys.version_info[0:2]))
       
   135     text = virtualenv.create_bootstrap_script(EXTRA_TEXT, python_version=python_version)
   121     if os.path.exists(script_name):
   136     if os.path.exists(script_name):
   122         f = open(script_name)
   137         f = open(script_name)
   123         cur_text = f.read()
   138         cur_text = f.read()
   124         f.close()
   139         f.close()
   125     else:
   140     else: