Permalink
Browse files

Fix: Wasn't activating virtualenv.

  • Loading branch information...
1 parent d3f2895 commit 3990baaab87e99e9d83c94483d307649d036ad5a @nficano nficano committed Jul 30, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 src/vinegar/bootstrap.py
View
23 src/vinegar/bootstrap.py
@@ -36,6 +36,7 @@ def create_virtualenv(project_name):
bin_dirname = 'bin'
bin_path = join(home_path, bin_dirname)
+ activate_virtualenv(bin_path)
base_req = os.path.join(working_dir, 'base-requirements.txt')
easy_install(bin_path, 'pip')
pip(bin_path, req_file=base_req)
@@ -52,6 +53,28 @@ def pip(bin_path, package_name=None, req_file=None):
if req_file:
subprocess.call([f, 'install', '-U', '-r', req_file])
+def activate_virtualenv(bin_path):
+ base = os.path.abspath(os.path.join(bin_path, '../'))
+ if sys.platform == 'win32':
+ site_packages = os.path.join(base, 'Lib', 'site-packages')
+ else:
+ site_packages = os.path.join(base, 'lib', 'python%s' % sys.version[:3], 'site-packages')
+ prev_sys_path = list(sys.path)
+ import site
+ site.addsitedir(site_packages)
+ sys.real_prefix = sys.prefix
+ sys.prefix = base
+
+ new_sys_path = []
+ for item in list(sys.path):
+ if item not in prev_sys_path:
+ new_sys_path.append(item)
+ sys.path.remove(item)
+ sys.path[:0] = new_sys_path
+
+def clean_up(bin_path):
+ pass
+
def django_init(bin_path, project_name=PROJECT_NAME):
f = os.path.join(bin_path, 'django-admin.py')
subprocess.call([f, 'startproject', project_name])

0 comments on commit 3990baa

Please sign in to comment.