--- a/sbin/virtualenv/create_python_env.py Tue Jun 08 01:16:35 2010 +0200
+++ b/sbin/virtualenv/create_python_env.py Tue Jun 08 13:39:41 2010 +0200
@@ -8,8 +8,9 @@
- distribute
- psycopg2 requires the PostgreSQL libpq libraries and the pg_config utility
-- virtualenv --distribute --no-site-packages venv
-- python project-boot.py --distribute --no-site-packages --index-url=http://pypi.websushi.org/ --clear bvenv
+- python project-boot.py --distribute --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local <path_to_venv>
+- For Linux :
+python project-boot.py --unzip-setuptools --no-site-packages --index-url=http://pypi.websushi.org/ --clear --type-install=local <path_to_venv>
"""
@@ -79,6 +80,13 @@
dest='type_install',
default='local',
help='type install : local, url, setup')
+ parser.add_option(
+ '--ignore-packages',
+ metavar='ignore_packages',
+ dest='ignore_packages',
+ default=None,
+ help='list of comma separated keys for package to ignore')
+
def adjust_options(options, args):
@@ -96,117 +104,126 @@
res_source_key = options.type_install
+ ignore_packages = []
+
+ if options.ignore_packages :
+ ignore_packages = options.ignore_packages.split(",")
+
logger.indent += 2
try:
- #get pylucene
- logger.notify("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key])
- pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
- urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src)
- tf = tarfile.open(pylucene_src,'r:gz')
- pylucene_base_path = os.path.join(src_dir,"pylucene")
- logger.notify("Extract Pylucene to %s " % pylucene_base_path)
- tf.extractall(pylucene_base_path)
- tf.close()
-
- pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0])
- jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc"))
-
- #install jcc
+ if 'PYLUCENE' not in ignore_packages:
+ #get pylucene
+ logger.notify("Get Pylucene from %s " % URLS['PYLUCENE'][res_source_key])
+ pylucene_src = os.path.join(src_dir,"pylucene.tar.gz")
+ urllib.urlretrieve(URLS['PYLUCENE'][res_source_key], pylucene_src)
+ tf = tarfile.open(pylucene_src,'r:gz')
+ pylucene_base_path = os.path.join(src_dir,"pylucene")
+ logger.notify("Extract Pylucene to %s " % pylucene_base_path)
+ tf.extractall(pylucene_base_path)
+ tf.close()
+
+ pylucene_src_path = os.path.join(pylucene_base_path, os.listdir(pylucene_base_path)[0])
+ jcc_src_path = os.path.abspath(os.path.join(pylucene_src_path,"jcc"))
+
+ #install jcc
+
+ #patch for linux
+ if system_str == 'Linux' :
+ olddir = os.getcwd()
+ patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg')
+ logger.notify("Patch jcc : %s " % (patch_dest_path))
+ os.chdir(patch_dest_path)
+ p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11"))
+ p.apply()
+ os.chdir(olddir)
+
+ logger.notify("Install jcc")
+ call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
+ cwd=jcc_src_path,
+ filter_stdout=filter_python_develop,
+ show_stdout=True)
+ #install pylucene
+
+ logger.notify("Install pylucene")
+ #modify makefile
+ makefile_path = os.path.join(pylucene_src_path,"Makefile")
+ logger.notify("Modify makefile %s " % makefile_path)
+ shutil.move( makefile_path, makefile_path+"~" )
+
+ destination= open( makefile_path, "w" )
+ source= open( makefile_path+"~", "r" )
+ destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n")
+ destination.write("ANT=ant\\n")
+ destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n")
+
+ if system_str == "Darwin":
+ if sys.version_info >= (2,6):
+ destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n")
+ else:
+ destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\\n")
+ destination.write("NUM_FILES=2\\n")
+ elif system_str == "Windows":
+ destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n")
+ destination.write("NUM_FILES=2\\n")
+ else:
+ destination.write("JCC=$(PYTHON) -m jcc --shared\\n")
+ destination.write("NUM_FILES=2\\n")
+ for line in source:
+ destination.write( line )
+ source.close()
+ destination.close()
+ os.remove(makefile_path+"~" )
+
+ logger.notify("pylucene make")
+ call_subprocess(['make'],
+ cwd=os.path.abspath(pylucene_src_path),
+ filter_stdout=filter_python_develop,
+ show_stdout=True)
+
+ logger.notify("pylucene make install")
+ call_subprocess(['make', 'install'],
+ cwd=os.path.abspath(pylucene_src_path),
+ filter_stdout=filter_python_develop,
+ show_stdout=True)
- #patch for linux
- if system_str == 'Linux' :
- olddir = os.getcwd()
- patch_dest_path = os.path.join(lib_dir,'site-packages','setuptools-0.6c11-py'+'%s.%s' % (sys.version_info[0], sys.version_info[1])+'.egg')
- logger.notify("Patch jcc : %s " % (patch_dest_path))
- os.chdir(patch_dest_path)
- p = patch.fromfile(os.path.join(jcc_src_path,"jcc","patches","patch.43.0.6c11"))
- p.apply()
- os.chdir(olddir)
+ if system_str == 'Linux' and 'DISTRIBUTE' not in ignore_packages:
+ normal_install('DISTRIBUTE', 'pip', None, res_source_key, home_dir, tmp_dir)
- logger.notify("Install jcc")
- call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'python')), 'setup.py', 'install'],
- cwd=jcc_src_path,
+ if 'PYXML' not in ignore_packages:
+ logger.notify("PyXML install : %s " % URLS['PYXML'][res_source_key])
+ if sys.version_info >= (2,6):
+ logger.notify("PyXML -> python version >= 2.6 : patching")
+ pyxml_src = os.path.join(src_dir,"pyxml.tar.gz")
+ urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src)
+ logger.notify("PyXML -> python version >= 2.6 : extract archive")
+ tf = tarfile.open(pyxml_src,'r:gz')
+ pyxml_base_path = os.path.join(src_dir,"pyxml")
+ tf.extractall(pyxml_base_path)
+ tf.close()
+
+ #patch
+ pyxml_version = os.listdir(pyxml_base_path)[0]
+ pyxml_path = os.path.join(pyxml_base_path, pyxml_version)
+ olddir = os.getcwd()
+ os.chdir(pyxml_path)
+ logger.notify("PyXML -> python version >= 2.6 : do patch %s : %s " % (pyxml_path, URLS['PYXML']['patch']))
+ p = patch.fromfile(URLS['PYXML']['patch'])
+ p.apply()
+ os.chdir(olddir)
+ logger.notify("PyXML -> python version >= 2.6 : install")
+ call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), '--build='+os.path.abspath(pyxml_base_path), '--no-download', pyxml_version],
+ cwd=os.path.abspath(tmp_dir),
filter_stdout=filter_python_develop,
show_stdout=True)
- #install pylucene
-
- logger.notify("Install pylucene")
- #modify makefile
- makefile_path = os.path.join(pylucene_src_path,"Makefile")
- logger.notify("Modify makefile %s " % makefile_path)
- shutil.move( makefile_path, makefile_path+"~" )
-
- destination= open( makefile_path, "w" )
- source= open( makefile_path+"~", "r" )
- destination.write("PREFIX_PYTHON="+os.path.abspath(home_dir)+"\\n")
- destination.write("ANT=ant\\n")
- destination.write("PYTHON=$(PREFIX_PYTHON)/bin/python\\n")
-
- if system_str == "Darwin":
- if sys.version_info >= (2,6):
- destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n")
else:
- destination.write("JCC=$(PYTHON) -m jcc --shared --arch x86_64 --arch i386\\n")
- destination.write("NUM_FILES=2\\n")
- elif system_str == "Windows":
- destination.write("JCC=$(PYTHON) -m jcc.__main__ --shared --arch x86_64 --arch i386\\n")
- destination.write("NUM_FILES=2\\n")
- else:
- destination.write("JCC=$(PYTHON) -m jcc --shared\\n")
- destination.write("NUM_FILES=2\\n")
- for line in source:
- destination.write( line )
- source.close()
- destination.close()
- os.remove(makefile_path+"~" )
-
- logger.notify("pylucene make")
- call_subprocess(['make'],
- cwd=os.path.abspath(pylucene_src_path),
+ call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]],
+ cwd=os.path.abspath(tmp_dir),
filter_stdout=filter_python_develop,
show_stdout=True)
-
- logger.notify("pylucene make install")
- call_subprocess(['make', 'install'],
- cwd=os.path.abspath(pylucene_src_path),
- filter_stdout=filter_python_develop,
- show_stdout=True)
-
- logger.notify("PyXML install : %s " % URLS['PYXML'][res_source_key])
- if sys.version_info >= (2,6):
- logger.notify("PyXML -> python version >= 2.6 : patching")
- pyxml_src = os.path.join(src_dir,"pyxml.tar.gz")
- urllib.urlretrieve(URLS['PYXML'][res_source_key], pyxml_src)
- logger.notify("PyXML -> python version >= 2.6 : extract archive")
- tf = tarfile.open(pyxml_src,'r:gz')
- pyxml_base_path = os.path.join(src_dir,"pyxml")
- tf.extractall(pyxml_base_path)
- tf.close()
-
- #patch
- pyxml_version = os.listdir(pyxml_base_path)[0]
- pyxml_path = os.path.join(pyxml_base_path, pyxml_version)
- olddir = os.getcwd()
- os.chdir(pyxml_path)
- logger.notify("PyXML -> python version >= 2.6 : do patch %s : %s " % (pyxml_path, URLS['PYXML']['patch']))
- p = patch.fromfile(URLS['PYXML']['patch'])
- p.apply()
- os.chdir(olddir)
- logger.notify("PyXML -> python version >= 2.6 : install")
- call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), '--build='+os.path.abspath(pyxml_base_path), '--no-download', pyxml_version],
- cwd=os.path.abspath(tmp_dir),
- filter_stdout=filter_python_develop,
- show_stdout=True)
- else:
- call_subprocess([os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS['PYXML'][res_source_key]],
- cwd=os.path.abspath(tmp_dir),
- filter_stdout=filter_python_develop,
- show_stdout=True)
NORMAL_INSTALL = [ #(key,method)
- ('DISTRIBUTE', 'pip', None),
('PSYCOPG2', 'pip', None),
('MYSQL', 'pip', None),
('PIL', 'pip', None),
@@ -215,30 +232,14 @@
('DJANGO-EXTENSIONS', 'pip', None),
('DJANGO-REGISTRATION', 'easy_install', '-Z')
]
-
- if sys.version_info < (2,6):
- NORMAL_INSTALL.append(('JSON','pip'))
+
+ if sys.version_info < (2,6):
+ NORMAL_INSTALL.append(('JSON','pip', None))
- for key, method, options in NORMAL_INSTALL:
- logger.notify("Install %s from %s with %s" % (key,URLS[key][res_source_key],method))
- if method == 'pip':
- args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS[key][res_source_key]]
- if options :
- args.insert(4,options)
- call_subprocess(args,
- cwd=os.path.abspath(tmp_dir),
- filter_stdout=filter_python_develop,
- show_stdout=True)
- else:
- args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS[key][res_source_key]]
- if options :
- args.insert(1,options)
- call_subprocess(args,
- cwd=os.path.abspath(tmp_dir),
- filter_stdout=filter_python_develop,
- show_stdout=True)
-
+ for key, method, option_str in NORMAL_INSTALL:
+ if key not in ignore_packages:
+ normal_install(key, method, option_str, res_source_key, home_dir, tmp_dir)
logger.notify("Clear source dir")
shutil.rmtree(src_dir)
@@ -249,6 +250,27 @@
logger.notify('Run "%s Package" to install new packages that provide builds'
% join(script_dir, 'easy_install'))
+
+def normal_install(key, method, option_str, res_source_key, home_dir, tmp_dir):
+ logger.notify("Install %s from %s with %s" % (key,URLS[key][res_source_key],method))
+ if method == 'pip':
+ args = [os.path.abspath(os.path.join(home_dir, 'bin', 'pip')), 'install', '-E', os.path.abspath(home_dir), URLS[key][res_source_key]]
+ if option_str :
+ args.insert(4,option_str)
+ call_subprocess(args,
+ cwd=os.path.abspath(tmp_dir),
+ filter_stdout=filter_python_develop,
+ show_stdout=True)
+ else:
+ args = [os.path.abspath(os.path.join(home_dir, 'bin', 'easy_install')), URLS[key][res_source_key]]
+ if option_str :
+ args.insert(1,option_str)
+ call_subprocess(args,
+ cwd=os.path.abspath(tmp_dir),
+ filter_stdout=filter_python_develop,
+ show_stdout=True)
+
+
def ensure_dir(dir):
if not os.path.exists(dir):
logger.notify('Creating directory %s' % dir)