Bug 1100925 - Virtualenv now copies a site.py file in its folder (if it exists) instead of using the hex string for site.py that is in its source code. r?gps draft
authorNathan Hakkakzadeh <nhakkakzadeh@mozilla.com>
Mon, 06 Jun 2016 10:27:05 -0700
changeset 387434 a847bffa63924fed2d66a7bc717301c3e23a7e4a
parent 387433 5809399602693eb91a1c4f620bc22ea722e8250c
child 387435 d899af450469c870b8b98a3529bd0a8ce1932ad4
push id22949
push userbmo:nhakkakzadeh@mozilla.com
push dateWed, 13 Jul 2016 22:42:05 +0000
reviewersgps
bugs1100925
milestone50.0a1
Bug 1100925 - Virtualenv now copies a site.py file in its folder (if it exists) instead of using the hex string for site.py that is in its source code. r?gps We need this to avoid weird site.py hacks to get msys2 to play nicely with virtualenv. MozReview-Commit-ID: 9lJSo6MistO
python/virtualenv/virtualenv.py
--- a/python/virtualenv/virtualenv.py
+++ b/python/virtualenv/virtualenv.py
@@ -1125,17 +1125,23 @@ def install_python(home_dir, lib_dir, in
     import site
     site_filename = site.__file__
     if site_filename.endswith('.pyc') or site_filename.endswith('.pyo'):
         site_filename = site_filename[:-1]
     elif site_filename.endswith('$py.class'):
         site_filename = site_filename.replace('$py.class', '.py')
     site_filename_dst = change_prefix(site_filename, home_dir)
     site_dir = os.path.dirname(site_filename_dst)
-    writefile(site_filename_dst, SITE_PY)
+    # MOZ: Copies a site.py if it exists instead of using the one hex encoded in
+    # this file. Necessary for some site.py fixes for MinGW64 version of python
+    site_py_src_path = os.path.join(os.path.dirname(__file__), 'site.py')
+    if os.path.isfile(site_py_src_path):
+        shutil.copy(site_py_src_path, site_filename_dst)
+    else:
+        writefile(site_filename_dst, SITE_PY)
     writefile(join(site_dir, 'orig-prefix.txt'), prefix)
     site_packages_filename = join(site_dir, 'no-global-site-packages.txt')
     if not site_packages:
         writefile(site_packages_filename, '')
 
     if is_pypy or is_win:
         stdinc_dir = join(prefix, 'include')
     else: