| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 """Create a "virtual" Python installation | 2 """Create a "virtual" Python installation""" |
| 3 """ | |
| 4 | 3 |
| 5 __version__ = "13.0.3" | 4 import os |
| 6 virtualenv_version = __version__ # legacy | 5 import sys |
| 6 |
| 7 # If we are running in a new interpreter to create a virtualenv, |
| 8 # we do NOT want paths from our existing location interfering with anything, |
| 9 # So we remove this file's directory from sys.path - most likely to be |
| 10 # the previous interpreter's site-packages. Solves #705, #763, #779 |
| 11 if os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'): |
| 12 for path in sys.path[:]: |
| 13 if os.path.realpath(os.path.dirname(__file__)) == os.path.realpath(path)
: |
| 14 sys.path.remove(path) |
| 7 | 15 |
| 8 import base64 | 16 import base64 |
| 9 import sys | |
| 10 import os | |
| 11 import codecs | 17 import codecs |
| 12 import optparse | 18 import optparse |
| 13 import re | 19 import re |
| 14 import shutil | 20 import shutil |
| 15 import logging | 21 import logging |
| 16 import tempfile | |
| 17 import zlib | 22 import zlib |
| 18 import errno | 23 import errno |
| 19 import glob | 24 import glob |
| 20 import distutils.sysconfig | 25 import distutils.sysconfig |
| 21 from distutils.util import strtobool | |
| 22 import struct | 26 import struct |
| 23 import subprocess | 27 import subprocess |
| 24 import tarfile | 28 import pkgutil |
| 29 import tempfile |
| 30 import textwrap |
| 31 from distutils.util import strtobool |
| 32 from os.path import join |
| 33 |
| 34 try: |
| 35 import ConfigParser |
| 36 except ImportError: |
| 37 import configparser as ConfigParser |
| 38 |
| 39 __version__ = "15.0.2" |
| 40 virtualenv_version = __version__ # legacy |
| 25 | 41 |
| 26 if sys.version_info < (2, 6): | 42 if sys.version_info < (2, 6): |
| 27 print('ERROR: %s' % sys.exc_info()[1]) | 43 print('ERROR: %s' % sys.exc_info()[1]) |
| 28 print('ERROR: this script requires Python 2.6 or greater.') | 44 print('ERROR: this script requires Python 2.6 or greater.') |
| 29 sys.exit(101) | 45 sys.exit(101) |
| 30 | 46 |
| 31 try: | 47 try: |
| 32 basestring | 48 basestring |
| 33 except NameError: | 49 except NameError: |
| 34 basestring = str | 50 basestring = str |
| 35 | 51 |
| 36 try: | |
| 37 import ConfigParser | |
| 38 except ImportError: | |
| 39 import configparser as ConfigParser | |
| 40 | |
| 41 join = os.path.join | |
| 42 py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) | 52 py_version = 'python%s.%s' % (sys.version_info[0], sys.version_info[1]) |
| 43 | 53 |
| 44 is_jython = sys.platform.startswith('java') | 54 is_jython = sys.platform.startswith('java') |
| 45 is_pypy = hasattr(sys, 'pypy_version_info') | 55 is_pypy = hasattr(sys, 'pypy_version_info') |
| 46 is_win = (sys.platform == 'win32') | 56 is_win = (sys.platform == 'win32') |
| 47 is_cygwin = (sys.platform == 'cygwin') | 57 is_cygwin = (sys.platform == 'cygwin') |
| 48 is_darwin = (sys.platform == 'darwin') | 58 is_darwin = (sys.platform == 'darwin') |
| 49 abiflags = getattr(sys, 'abiflags', '') | 59 abiflags = getattr(sys, 'abiflags', '') |
| 50 | 60 |
| 51 user_dir = os.path.expanduser('~') | 61 user_dir = os.path.expanduser('~') |
| (...skipping 17 matching lines...) Expand all Loading... |
| 69 return {} | 79 return {} |
| 70 else: | 80 else: |
| 71 try: | 81 try: |
| 72 import winreg | 82 import winreg |
| 73 except ImportError: | 83 except ImportError: |
| 74 import _winreg as winreg | 84 import _winreg as winreg |
| 75 | 85 |
| 76 def get_installed_pythons(): | 86 def get_installed_pythons(): |
| 77 try: | 87 try: |
| 78 python_core = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, | 88 python_core = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, |
| 79 "Software\\Python\\PythonCore") | 89 "Software\\Python\\PythonCore") |
| 80 except WindowsError: | 90 except WindowsError: |
| 81 # No registered Python installations | 91 # No registered Python installations |
| 82 return {} | 92 return {} |
| 83 i = 0 | 93 i = 0 |
| 84 versions = [] | 94 versions = [] |
| 85 while True: | 95 while True: |
| 86 try: | 96 try: |
| 87 versions.append(winreg.EnumKey(python_core, i)) | 97 versions.append(winreg.EnumKey(python_core, i)) |
| 88 i = i + 1 | 98 i = i + 1 |
| 89 except WindowsError: | 99 except WindowsError: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 116 | 126 |
| 117 majver, minver = sys.version_info[:2] | 127 majver, minver = sys.version_info[:2] |
| 118 if majver == 2: | 128 if majver == 2: |
| 119 if minver >= 6: | 129 if minver >= 6: |
| 120 REQUIRED_MODULES.extend(['warnings', 'linecache', '_abcoll', 'abc']) | 130 REQUIRED_MODULES.extend(['warnings', 'linecache', '_abcoll', 'abc']) |
| 121 if minver >= 7: | 131 if minver >= 7: |
| 122 REQUIRED_MODULES.extend(['_weakrefset']) | 132 REQUIRED_MODULES.extend(['_weakrefset']) |
| 123 elif majver == 3: | 133 elif majver == 3: |
| 124 # Some extra modules are needed for Python 3, but different ones | 134 # Some extra modules are needed for Python 3, but different ones |
| 125 # for different versions. | 135 # for different versions. |
| 126 REQUIRED_MODULES.extend(['_abcoll', 'warnings', 'linecache', 'abc', 'io', | 136 REQUIRED_MODULES.extend([ |
| 127 '_weakrefset', 'copyreg', 'tempfile', 'random', | 137 » '_abcoll', 'warnings', 'linecache', 'abc', 'io', '_weakrefset', |
| 128 '__future__', 'collections', 'keyword', 'tarfile', | 138 » 'copyreg', 'tempfile', 'random', '__future__', 'collections', |
| 129 'shutil', 'struct', 'copy', 'tokenize', 'token', | 139 » 'keyword', 'tarfile', 'shutil', 'struct', 'copy', 'tokenize', |
| 130 'functools', 'heapq', 'bisect', 'weakref', | 140 » 'token', 'functools', 'heapq', 'bisect', 'weakref', 'reprlib' |
| 131 'reprlib']) | 141 ]) |
| 132 if minver >= 2: | 142 if minver >= 2: |
| 133 REQUIRED_FILES[-1] = 'config-%s' % majver | 143 REQUIRED_FILES[-1] = 'config-%s' % majver |
| 134 if minver >= 3: | 144 if minver >= 3: |
| 135 import sysconfig | 145 import sysconfig |
| 136 platdir = sysconfig.get_config_var('PLATDIR') | 146 platdir = sysconfig.get_config_var('PLATDIR') |
| 137 REQUIRED_FILES.append(platdir) | 147 REQUIRED_FILES.append(platdir) |
| 138 # The whole list of 3.3 modules is reproduced below - the current | |
| 139 # uncommented ones are required for 3.3 as of now, but more may be | |
| 140 # added as 3.3 development continues. | |
| 141 REQUIRED_MODULES.extend([ | 148 REQUIRED_MODULES.extend([ |
| 142 #"aifc", | 149 » 'base64', '_dummy_thread', 'hashlib', 'hmac', |
| 143 #"antigravity", | 150 » 'imp', 'importlib', 'rlcompleter' |
| 144 #"argparse", | |
| 145 #"ast", | |
| 146 #"asynchat", | |
| 147 #"asyncore", | |
| 148 "base64", | |
| 149 #"bdb", | |
| 150 #"binhex", | |
| 151 #"bisect", | |
| 152 #"calendar", | |
| 153 #"cgi", | |
| 154 #"cgitb", | |
| 155 #"chunk", | |
| 156 #"cmd", | |
| 157 #"codeop", | |
| 158 #"code", | |
| 159 #"colorsys", | |
| 160 #"_compat_pickle", | |
| 161 #"compileall", | |
| 162 #"concurrent", | |
| 163 #"configparser", | |
| 164 #"contextlib", | |
| 165 #"cProfile", | |
| 166 #"crypt", | |
| 167 #"csv", | |
| 168 #"ctypes", | |
| 169 #"curses", | |
| 170 #"datetime", | |
| 171 #"dbm", | |
| 172 #"decimal", | |
| 173 #"difflib", | |
| 174 #"dis", | |
| 175 #"doctest", | |
| 176 #"dummy_threading", | |
| 177 "_dummy_thread", | |
| 178 #"email", | |
| 179 #"filecmp", | |
| 180 #"fileinput", | |
| 181 #"formatter", | |
| 182 #"fractions", | |
| 183 #"ftplib", | |
| 184 #"functools", | |
| 185 #"getopt", | |
| 186 #"getpass", | |
| 187 #"gettext", | |
| 188 #"glob", | |
| 189 #"gzip", | |
| 190 "hashlib", | |
| 191 #"heapq", | |
| 192 "hmac", | |
| 193 #"html", | |
| 194 #"http", | |
| 195 #"idlelib", | |
| 196 #"imaplib", | |
| 197 #"imghdr", | |
| 198 "imp", | |
| 199 "importlib", | |
| 200 #"inspect", | |
| 201 #"json", | |
| 202 #"lib2to3", | |
| 203 #"logging", | |
| 204 #"macpath", | |
| 205 #"macurl2path", | |
| 206 #"mailbox", | |
| 207 #"mailcap", | |
| 208 #"_markupbase", | |
| 209 #"mimetypes", | |
| 210 #"modulefinder", | |
| 211 #"multiprocessing", | |
| 212 #"netrc", | |
| 213 #"nntplib", | |
| 214 #"nturl2path", | |
| 215 #"numbers", | |
| 216 #"opcode", | |
| 217 #"optparse", | |
| 218 #"os2emxpath", | |
| 219 #"pdb", | |
| 220 #"pickle", | |
| 221 #"pickletools", | |
| 222 #"pipes", | |
| 223 #"pkgutil", | |
| 224 #"platform", | |
| 225 #"plat-linux2", | |
| 226 #"plistlib", | |
| 227 #"poplib", | |
| 228 #"pprint", | |
| 229 #"profile", | |
| 230 #"pstats", | |
| 231 #"pty", | |
| 232 #"pyclbr", | |
| 233 #"py_compile", | |
| 234 #"pydoc_data", | |
| 235 #"pydoc", | |
| 236 #"_pyio", | |
| 237 #"queue", | |
| 238 #"quopri", | |
| 239 #"reprlib", | |
| 240 "rlcompleter", | |
| 241 #"runpy", | |
| 242 #"sched", | |
| 243 #"shelve", | |
| 244 #"shlex", | |
| 245 #"smtpd", | |
| 246 #"smtplib", | |
| 247 #"sndhdr", | |
| 248 #"socket", | |
| 249 #"socketserver", | |
| 250 #"sqlite3", | |
| 251 #"ssl", | |
| 252 #"stringprep", | |
| 253 #"string", | |
| 254 #"_strptime", | |
| 255 #"subprocess", | |
| 256 #"sunau", | |
| 257 #"symbol", | |
| 258 #"symtable", | |
| 259 #"sysconfig", | |
| 260 #"tabnanny", | |
| 261 #"telnetlib", | |
| 262 #"test", | |
| 263 #"textwrap", | |
| 264 #"this", | |
| 265 #"_threading_local", | |
| 266 #"threading", | |
| 267 #"timeit", | |
| 268 #"tkinter", | |
| 269 #"tokenize", | |
| 270 #"token", | |
| 271 #"traceback", | |
| 272 #"trace", | |
| 273 #"tty", | |
| 274 #"turtledemo", | |
| 275 #"turtle", | |
| 276 #"unittest", | |
| 277 #"urllib", | |
| 278 #"uuid", | |
| 279 #"uu", | |
| 280 #"wave", | |
| 281 #"weakref", | |
| 282 #"webbrowser", | |
| 283 #"wsgiref", | |
| 284 #"xdrlib", | |
| 285 #"xml", | |
| 286 #"xmlrpc", | |
| 287 #"zipfile", | |
| 288 ]) | 151 ]) |
| 289 if minver >= 4: | 152 if minver >= 4: |
| 290 REQUIRED_MODULES.extend([ | 153 REQUIRED_MODULES.extend([ |
| 291 'operator', | 154 'operator', |
| 292 '_collections_abc', | 155 '_collections_abc', |
| 293 '_bootlocale', | 156 '_bootlocale', |
| 294 ]) | 157 ]) |
| 295 | 158 |
| 296 if is_pypy: | 159 if is_pypy: |
| 297 # these are needed to correctly display the exceptions that may happen | 160 # these are needed to correctly display the exceptions that may happen |
| 298 # during the bootstrap | 161 # during the bootstrap |
| 299 REQUIRED_MODULES.extend(['traceback', 'linecache']) | 162 REQUIRED_MODULES.extend(['traceback', 'linecache']) |
| 300 | 163 |
| 164 if majver == 3: |
| 165 # _functools is needed to import locale during stdio initialization and |
| 166 # needs to be copied on PyPy because it's not built in |
| 167 REQUIRED_MODULES.append('_functools') |
| 168 |
| 169 |
| 301 class Logger(object): | 170 class Logger(object): |
| 302 | 171 |
| 303 """ | 172 """ |
| 304 Logging object for use in command-line script. Allows ranges of | 173 Logging object for use in command-line script. Allows ranges of |
| 305 levels, to avoid some redundancy of displayed information. | 174 levels, to avoid some redundancy of displayed information. |
| 306 """ | 175 """ |
| 307 | 176 |
| 308 DEBUG = logging.DEBUG | 177 DEBUG = logging.DEBUG |
| 309 INFO = logging.INFO | 178 INFO = logging.INFO |
| 310 NOTIFY = (logging.INFO+logging.WARN)/2 | 179 NOTIFY = (logging.INFO+logging.WARN)/2 |
| 311 WARN = WARNING = logging.WARN | 180 WARN = WARNING = logging.WARN |
| 312 ERROR = logging.ERROR | 181 ERROR = logging.ERROR |
| 313 FATAL = logging.FATAL | 182 FATAL = logging.FATAL |
| 314 | 183 |
| 315 LEVELS = [DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL] | 184 LEVELS = [DEBUG, INFO, NOTIFY, WARN, ERROR, FATAL] |
| 316 | 185 |
| 317 def __init__(self, consumers): | 186 def __init__(self, consumers): |
| 318 self.consumers = consumers | 187 self.consumers = consumers |
| 319 self.indent = 0 | 188 self.indent = 0 |
| 320 self.in_progress = None | 189 self.in_progress = None |
| 321 self.in_progress_hanging = False | 190 self.in_progress_hanging = False |
| 322 | 191 |
| 323 def debug(self, msg, *args, **kw): | 192 def debug(self, msg, *args, **kw): |
| 324 self.log(self.DEBUG, msg, *args, **kw) | 193 self.log(self.DEBUG, msg, *args, **kw) |
| 194 |
| 325 def info(self, msg, *args, **kw): | 195 def info(self, msg, *args, **kw): |
| 326 self.log(self.INFO, msg, *args, **kw) | 196 self.log(self.INFO, msg, *args, **kw) |
| 197 |
| 327 def notify(self, msg, *args, **kw): | 198 def notify(self, msg, *args, **kw): |
| 328 self.log(self.NOTIFY, msg, *args, **kw) | 199 self.log(self.NOTIFY, msg, *args, **kw) |
| 200 |
| 329 def warn(self, msg, *args, **kw): | 201 def warn(self, msg, *args, **kw): |
| 330 self.log(self.WARN, msg, *args, **kw) | 202 self.log(self.WARN, msg, *args, **kw) |
| 203 |
| 331 def error(self, msg, *args, **kw): | 204 def error(self, msg, *args, **kw): |
| 332 self.log(self.ERROR, msg, *args, **kw) | 205 self.log(self.ERROR, msg, *args, **kw) |
| 206 |
| 333 def fatal(self, msg, *args, **kw): | 207 def fatal(self, msg, *args, **kw): |
| 334 self.log(self.FATAL, msg, *args, **kw) | 208 self.log(self.FATAL, msg, *args, **kw) |
| 209 |
| 335 def log(self, level, msg, *args, **kw): | 210 def log(self, level, msg, *args, **kw): |
| 336 if args: | 211 if args: |
| 337 if kw: | 212 if kw: |
| 338 raise TypeError( | 213 raise TypeError( |
| 339 "You may give positional or keyword arguments, not both") | 214 "You may give positional or keyword arguments, not both") |
| 340 args = args or kw | 215 args = args or kw |
| 341 rendered = None | 216 rendered = None |
| 342 for consumer_level, consumer in self.consumers: | 217 for consumer_level, consumer in self.consumers: |
| 343 if self.level_matches(level, consumer_level): | 218 if self.level_matches(level, consumer_level): |
| 344 if (self.in_progress_hanging | 219 if (self.in_progress_hanging |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 if isinstance(level, slice): | 295 if isinstance(level, slice): |
| 421 start, stop = level.start, level.stop | 296 start, stop = level.start, level.stop |
| 422 if start is not None and start > consumer_level: | 297 if start is not None and start > consumer_level: |
| 423 return False | 298 return False |
| 424 if stop is not None and stop <= consumer_level: | 299 if stop is not None and stop <= consumer_level: |
| 425 return False | 300 return False |
| 426 return True | 301 return True |
| 427 else: | 302 else: |
| 428 return level >= consumer_level | 303 return level >= consumer_level |
| 429 | 304 |
| 430 #@classmethod | 305 @classmethod |
| 431 def level_for_integer(cls, level): | 306 def level_for_integer(cls, level): |
| 432 levels = cls.LEVELS | 307 levels = cls.LEVELS |
| 433 if level < 0: | 308 if level < 0: |
| 434 return levels[0] | 309 return levels[0] |
| 435 if level >= len(levels): | 310 if level >= len(levels): |
| 436 return levels[-1] | 311 return levels[-1] |
| 437 return levels[level] | 312 return levels[level] |
| 438 | 313 |
| 439 level_for_integer = classmethod(level_for_integer) | |
| 440 | |
| 441 # create a silent logger just to prevent this from being undefined | 314 # create a silent logger just to prevent this from being undefined |
| 442 # will be overridden with requested verbosity main() is called. | 315 # will be overridden with requested verbosity main() is called. |
| 443 logger = Logger([(Logger.LEVELS[-1], sys.stdout)]) | 316 logger = Logger([(Logger.LEVELS[-1], sys.stdout)]) |
| 444 | 317 |
| 445 def mkdir(path): | 318 def mkdir(path): |
| 446 if not os.path.exists(path): | 319 if not os.path.exists(path): |
| 447 logger.info('Creating %s', path) | 320 logger.info('Creating %s', path) |
| 448 os.makedirs(path) | 321 os.makedirs(path) |
| 449 else: | 322 else: |
| 450 logger.info('Directory %s already exists', path) | 323 logger.info('Directory %s already exists', path) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 477 except (OSError, NotImplementedError): | 350 except (OSError, NotImplementedError): |
| 478 logger.info('Symlinking failed, copying to %s', dest) | 351 logger.info('Symlinking failed, copying to %s', dest) |
| 479 copyfileordir(src, dest, symlink) | 352 copyfileordir(src, dest, symlink) |
| 480 else: | 353 else: |
| 481 logger.info('Copying to %s', dest) | 354 logger.info('Copying to %s', dest) |
| 482 copyfileordir(src, dest, symlink) | 355 copyfileordir(src, dest, symlink) |
| 483 | 356 |
| 484 def writefile(dest, content, overwrite=True): | 357 def writefile(dest, content, overwrite=True): |
| 485 if not os.path.exists(dest): | 358 if not os.path.exists(dest): |
| 486 logger.info('Writing %s', dest) | 359 logger.info('Writing %s', dest) |
| 487 f = open(dest, 'wb') | 360 with open(dest, 'wb') as f: |
| 488 f.write(content.encode('utf-8')) | 361 f.write(content.encode('utf-8')) |
| 489 f.close() | |
| 490 return | 362 return |
| 491 else: | 363 else: |
| 492 f = open(dest, 'rb') | 364 with open(dest, 'rb') as f: |
| 493 c = f.read() | 365 c = f.read() |
| 494 f.close() | |
| 495 if c != content.encode("utf-8"): | 366 if c != content.encode("utf-8"): |
| 496 if not overwrite: | 367 if not overwrite: |
| 497 logger.notify('File %s exists with different content; not overwr
iting', dest) | 368 logger.notify('File %s exists with different content; not overwr
iting', dest) |
| 498 return | 369 return |
| 499 logger.notify('Overwriting %s with new content', dest) | 370 logger.notify('Overwriting %s with new content', dest) |
| 500 f = open(dest, 'wb') | 371 with open(dest, 'wb') as f: |
| 501 f.write(content.encode('utf-8')) | 372 f.write(content.encode('utf-8')) |
| 502 f.close() | |
| 503 else: | 373 else: |
| 504 logger.info('Content %s already in place', dest) | 374 logger.info('Content %s already in place', dest) |
| 505 | 375 |
| 506 def rmtree(dir): | 376 def rmtree(dir): |
| 507 if os.path.exists(dir): | 377 if os.path.exists(dir): |
| 508 logger.notify('Deleting tree %s', dir) | 378 logger.notify('Deleting tree %s', dir) |
| 509 shutil.rmtree(dir) | 379 shutil.rmtree(dir) |
| 510 else: | 380 else: |
| 511 logger.info('Do not need to delete %s; already gone', dir) | 381 logger.info('Do not need to delete %s; already gone', dir) |
| 512 | 382 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 '--relocatable', | 577 '--relocatable', |
| 708 dest='relocatable', | 578 dest='relocatable', |
| 709 action='store_true', | 579 action='store_true', |
| 710 help='Make an EXISTING virtualenv environment relocatable. ' | 580 help='Make an EXISTING virtualenv environment relocatable. ' |
| 711 'This fixes up scripts and makes all .pth files relative.') | 581 'This fixes up scripts and makes all .pth files relative.') |
| 712 | 582 |
| 713 parser.add_option( | 583 parser.add_option( |
| 714 '--no-setuptools', | 584 '--no-setuptools', |
| 715 dest='no_setuptools', | 585 dest='no_setuptools', |
| 716 action='store_true', | 586 action='store_true', |
| 717 help='Do not install setuptools (or pip) in the new virtualenv.') | 587 help='Do not install setuptools in the new virtualenv.') |
| 718 | 588 |
| 719 parser.add_option( | 589 parser.add_option( |
| 720 '--no-pip', | 590 '--no-pip', |
| 721 dest='no_pip', | 591 dest='no_pip', |
| 722 action='store_true', | 592 action='store_true', |
| 723 help='Do not install pip in the new virtualenv.') | 593 help='Do not install pip in the new virtualenv.') |
| 724 | 594 |
| 725 parser.add_option( | 595 parser.add_option( |
| 726 '--no-wheel', | 596 '--no-wheel', |
| 727 dest='no_wheel', | 597 dest='no_wheel', |
| 728 action='store_true', | 598 action='store_true', |
| 729 help='Do not install wheel in the new virtualenv.') | 599 help='Do not install wheel in the new virtualenv.') |
| 730 | 600 |
| 731 default_search_dirs = file_search_dirs() | 601 default_search_dirs = file_search_dirs() |
| 732 parser.add_option( | 602 parser.add_option( |
| 733 '--extra-search-dir', | 603 '--extra-search-dir', |
| 734 dest="search_dirs", | 604 dest="search_dirs", |
| 735 action="append", | 605 action="append", |
| 736 metavar='DIR', | 606 metavar='DIR', |
| 737 default=default_search_dirs, | 607 default=default_search_dirs, |
| 738 help="Directory to look for setuptools/pip distributions in. " | 608 help="Directory to look for setuptools/pip distributions in. " |
| 739 "This option can be used multiple times.") | 609 "This option can be used multiple times.") |
| 740 | 610 |
| 741 parser.add_option( | 611 parser.add_option( |
| 612 "--download", |
| 613 dest="download", |
| 614 default=True, |
| 615 action="store_true", |
| 616 help="Download preinstalled packages from PyPI.", |
| 617 ) |
| 618 |
| 619 parser.add_option( |
| 620 "--no-download", |
| 742 '--never-download', | 621 '--never-download', |
| 743 dest="never_download", | 622 dest="download", |
| 744 action="store_true", | 623 action="store_false", |
| 745 default=True, | 624 help="Do not download preinstalled packages from PyPI.", |
| 746 help="DEPRECATED. Retained only for backward compatibility. This option
has no effect. " | 625 ) |
| 747 "Virtualenv never downloads pip or setuptools.") | |
| 748 | 626 |
| 749 parser.add_option( | 627 parser.add_option( |
| 750 '--prompt', | 628 '--prompt', |
| 751 dest='prompt', | 629 dest='prompt', |
| 752 help='Provides an alternative prompt prefix for this environment.') | 630 help='Provides an alternative prompt prefix for this environment.') |
| 753 | 631 |
| 754 parser.add_option( | 632 parser.add_option( |
| 755 '--setuptools', | 633 '--setuptools', |
| 756 dest='setuptools', | 634 dest='setuptools', |
| 757 action='store_true', | 635 action='store_true', |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 parser.print_help() | 673 parser.print_help() |
| 796 sys.exit(2) | 674 sys.exit(2) |
| 797 if len(args) > 1: | 675 if len(args) > 1: |
| 798 print('There must be only one argument: DEST_DIR (you gave %s)' % ( | 676 print('There must be only one argument: DEST_DIR (you gave %s)' % ( |
| 799 ' '.join(args))) | 677 ' '.join(args))) |
| 800 parser.print_help() | 678 parser.print_help() |
| 801 sys.exit(2) | 679 sys.exit(2) |
| 802 | 680 |
| 803 home_dir = args[0] | 681 home_dir = args[0] |
| 804 | 682 |
| 683 if os.path.exists(home_dir) and os.path.isfile(home_dir): |
| 684 logger.fatal('ERROR: File already exists and is not a directory.') |
| 685 logger.fatal('Please provide a different path or delete the file.') |
| 686 sys.exit(3) |
| 687 |
| 805 if os.environ.get('WORKING_ENV'): | 688 if os.environ.get('WORKING_ENV'): |
| 806 logger.fatal('ERROR: you cannot run virtualenv while in a workingenv') | 689 logger.fatal('ERROR: you cannot run virtualenv while in a workingenv') |
| 807 logger.fatal('Please deactivate your workingenv, then re-run this script
') | 690 logger.fatal('Please deactivate your workingenv, then re-run this script
') |
| 808 sys.exit(3) | 691 sys.exit(3) |
| 809 | 692 |
| 810 if 'PYTHONHOME' in os.environ: | 693 if 'PYTHONHOME' in os.environ: |
| 811 logger.warn('PYTHONHOME is set. You *must* activate the virtualenv befo
re using it') | 694 logger.warn('PYTHONHOME is set. You *must* activate the virtualenv befo
re using it') |
| 812 del os.environ['PYTHONHOME'] | 695 del os.environ['PYTHONHOME'] |
| 813 | 696 |
| 814 if options.relocatable: | 697 if options.relocatable: |
| 815 make_environment_relocatable(home_dir) | 698 make_environment_relocatable(home_dir) |
| 816 return | 699 return |
| 817 | 700 |
| 818 if not options.never_download: | |
| 819 logger.warn('The --never-download option is for backward compatibility o
nly.') | |
| 820 logger.warn('Setting it to false is no longer supported, and will be ign
ored.') | |
| 821 | |
| 822 create_environment(home_dir, | 701 create_environment(home_dir, |
| 823 site_packages=options.system_site_packages, | 702 site_packages=options.system_site_packages, |
| 824 clear=options.clear, | 703 clear=options.clear, |
| 825 unzip_setuptools=options.unzip_setuptools, | 704 unzip_setuptools=options.unzip_setuptools, |
| 826 prompt=options.prompt, | 705 prompt=options.prompt, |
| 827 search_dirs=options.search_dirs, | 706 search_dirs=options.search_dirs, |
| 828 never_download=True, | 707 download=options.download, |
| 829 no_setuptools=options.no_setuptools, | 708 no_setuptools=options.no_setuptools, |
| 830 no_pip=options.no_pip, | 709 no_pip=options.no_pip, |
| 831 no_wheel=options.no_wheel, | 710 no_wheel=options.no_wheel, |
| 832 symlink=options.symlink) | 711 symlink=options.symlink) |
| 833 if 'after_install' in globals(): | 712 if 'after_install' in globals(): |
| 834 after_install(options, home_dir) | 713 after_install(options, home_dir) |
| 835 | 714 |
| 836 def call_subprocess(cmd, show_stdout=True, | 715 def call_subprocess(cmd, show_stdout=True, |
| 837 filter_stdout=None, cwd=None, | 716 filter_stdout=None, cwd=None, |
| 838 raise_on_returncode=True, extra_env=None, | 717 raise_on_returncode=True, extra_env=None, |
| 839 remove_from_env=None): | 718 remove_from_env=None, stdin=None): |
| 840 cmd_parts = [] | 719 cmd_parts = [] |
| 841 for part in cmd: | 720 for part in cmd: |
| 842 if len(part) > 45: | 721 if len(part) > 45: |
| 843 part = part[:20]+"..."+part[-20:] | 722 part = part[:20]+"..."+part[-20:] |
| 844 if ' ' in part or '\n' in part or '"' in part or "'" in part: | 723 if ' ' in part or '\n' in part or '"' in part or "'" in part: |
| 845 part = '"%s"' % part.replace('"', '\\"') | 724 part = '"%s"' % part.replace('"', '\\"') |
| 846 if hasattr(part, 'decode'): | 725 if hasattr(part, 'decode'): |
| 847 try: | 726 try: |
| 848 part = part.decode(sys.getdefaultencoding()) | 727 part = part.decode(sys.getdefaultencoding()) |
| 849 except UnicodeDecodeError: | 728 except UnicodeDecodeError: |
| 850 part = part.decode(sys.getfilesystemencoding()) | 729 part = part.decode(sys.getfilesystemencoding()) |
| 851 cmd_parts.append(part) | 730 cmd_parts.append(part) |
| 852 cmd_desc = ' '.join(cmd_parts) | 731 cmd_desc = ' '.join(cmd_parts) |
| 853 if show_stdout: | 732 if show_stdout: |
| 854 stdout = None | 733 stdout = None |
| 855 else: | 734 else: |
| 856 stdout = subprocess.PIPE | 735 stdout = subprocess.PIPE |
| 857 logger.debug("Running command %s" % cmd_desc) | 736 logger.debug("Running command %s" % cmd_desc) |
| 858 if extra_env or remove_from_env: | 737 if extra_env or remove_from_env: |
| 859 env = os.environ.copy() | 738 env = os.environ.copy() |
| 860 if extra_env: | 739 if extra_env: |
| 861 env.update(extra_env) | 740 env.update(extra_env) |
| 862 if remove_from_env: | 741 if remove_from_env: |
| 863 for varname in remove_from_env: | 742 for varname in remove_from_env: |
| 864 env.pop(varname, None) | 743 env.pop(varname, None) |
| 865 else: | 744 else: |
| 866 env = None | 745 env = None |
| 867 try: | 746 try: |
| 868 proc = subprocess.Popen( | 747 proc = subprocess.Popen( |
| 869 cmd, stderr=subprocess.STDOUT, stdin=None, stdout=stdout, | 748 cmd, stderr=subprocess.STDOUT, |
| 749 stdin=None if stdin is None else subprocess.PIPE, |
| 750 stdout=stdout, |
| 870 cwd=cwd, env=env) | 751 cwd=cwd, env=env) |
| 871 except Exception: | 752 except Exception: |
| 872 e = sys.exc_info()[1] | 753 e = sys.exc_info()[1] |
| 873 logger.fatal( | 754 logger.fatal( |
| 874 "Error %s while executing command %s" % (e, cmd_desc)) | 755 "Error %s while executing command %s" % (e, cmd_desc)) |
| 875 raise | 756 raise |
| 876 all_output = [] | 757 all_output = [] |
| 877 if stdout is not None: | 758 if stdout is not None: |
| 759 if stdin is not None: |
| 760 proc.stdin.write(stdin) |
| 761 proc.stdin.close() |
| 762 |
| 878 stdout = proc.stdout | 763 stdout = proc.stdout |
| 879 encoding = sys.getdefaultencoding() | 764 encoding = sys.getdefaultencoding() |
| 880 fs_encoding = sys.getfilesystemencoding() | 765 fs_encoding = sys.getfilesystemencoding() |
| 881 while 1: | 766 while 1: |
| 882 line = stdout.readline() | 767 line = stdout.readline() |
| 883 try: | 768 try: |
| 884 line = line.decode(encoding) | 769 line = line.decode(encoding) |
| 885 except UnicodeDecodeError: | 770 except UnicodeDecodeError: |
| 886 line = line.decode(fs_encoding) | 771 line = line.decode(fs_encoding) |
| 887 if not line: | 772 if not line: |
| 888 break | 773 break |
| 889 line = line.rstrip() | 774 line = line.rstrip() |
| 890 all_output.append(line) | 775 all_output.append(line) |
| 891 if filter_stdout: | 776 if filter_stdout: |
| 892 level = filter_stdout(line) | 777 level = filter_stdout(line) |
| 893 if isinstance(level, tuple): | 778 if isinstance(level, tuple): |
| 894 level, line = level | 779 level, line = level |
| 895 logger.log(level, line) | 780 logger.log(level, line) |
| 896 if not logger.stdout_level_matches(level): | 781 if not logger.stdout_level_matches(level): |
| 897 logger.show_progress() | 782 logger.show_progress() |
| 898 else: | 783 else: |
| 899 logger.info(line) | 784 logger.info(line) |
| 900 else: | 785 else: |
| 901 proc.communicate() | 786 proc.communicate(stdin) |
| 902 proc.wait() | 787 proc.wait() |
| 903 if proc.returncode: | 788 if proc.returncode: |
| 904 if raise_on_returncode: | 789 if raise_on_returncode: |
| 905 if all_output: | 790 if all_output: |
| 906 logger.notify('Complete output from command %s:' % cmd_desc) | 791 logger.notify('Complete output from command %s:' % cmd_desc) |
| 907 logger.notify('\n'.join(all_output) + '\n-----------------------
-----------------') | 792 logger.notify('\n'.join(all_output) + '\n-----------------------
-----------------') |
| 908 raise OSError( | 793 raise OSError( |
| 909 "Command %s failed with error code %s" | 794 "Command %s failed with error code %s" |
| 910 % (cmd_desc, proc.returncode)) | 795 % (cmd_desc, proc.returncode)) |
| 911 else: | 796 else: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 937 files = glob.glob(os.path.join(dirname, project + '-*.whl')) | 822 files = glob.glob(os.path.join(dirname, project + '-*.whl')) |
| 938 if files: | 823 if files: |
| 939 wheels.append(os.path.abspath(files[0])) | 824 wheels.append(os.path.abspath(files[0])) |
| 940 break | 825 break |
| 941 else: | 826 else: |
| 942 # We're out of luck, so quit with a suitable error | 827 # We're out of luck, so quit with a suitable error |
| 943 logger.fatal('Cannot find a wheel for %s' % (project,)) | 828 logger.fatal('Cannot find a wheel for %s' % (project,)) |
| 944 | 829 |
| 945 return wheels | 830 return wheels |
| 946 | 831 |
| 947 def install_wheel(project_names, py_executable, search_dirs=None): | 832 def install_wheel(project_names, py_executable, search_dirs=None, |
| 833 download=False): |
| 948 if search_dirs is None: | 834 if search_dirs is None: |
| 949 search_dirs = file_search_dirs() | 835 search_dirs = file_search_dirs() |
| 950 | 836 |
| 951 wheels = find_wheels(['setuptools', 'pip'], search_dirs) | 837 wheels = find_wheels(['setuptools', 'pip'], search_dirs) |
| 952 pythonpath = os.pathsep.join(wheels) | 838 pythonpath = os.pathsep.join(wheels) |
| 953 findlinks = ' '.join(search_dirs) | |
| 954 | 839 |
| 955 cmd = [ | 840 # PIP_FIND_LINKS uses space as the path separator and thus cannot have paths |
| 956 py_executable, '-c', | 841 # with spaces in them. Convert any of those to local file:// URL form. |
| 957 'import sys, pip; sys.exit(pip.main(["install", "--ignore-installed"] +
sys.argv[1:]))', | 842 try: |
| 958 ] + project_names | 843 from urlparse import urljoin |
| 844 from urllib import pathname2url |
| 845 except ImportError: |
| 846 from urllib.parse import urljoin |
| 847 from urllib.request import pathname2url |
| 848 def space_path2url(p): |
| 849 if ' ' not in p: |
| 850 return p |
| 851 return urljoin('file:', pathname2url(os.path.abspath(p))) |
| 852 findlinks = ' '.join(space_path2url(d) for d in search_dirs) |
| 853 |
| 854 SCRIPT = textwrap.dedent(""" |
| 855 import sys |
| 856 import pkgutil |
| 857 import tempfile |
| 858 import os |
| 859 |
| 860 import pip |
| 861 |
| 862 cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem") |
| 863 if cert_data is not None: |
| 864 cert_file = tempfile.NamedTemporaryFile(delete=False) |
| 865 cert_file.write(cert_data) |
| 866 cert_file.close() |
| 867 else: |
| 868 cert_file = None |
| 869 |
| 870 try: |
| 871 args = ["install", "--ignore-installed"] |
| 872 if cert_file is not None: |
| 873 args += ["--cert", cert_file.name] |
| 874 args += sys.argv[1:] |
| 875 |
| 876 sys.exit(pip.main(args)) |
| 877 finally: |
| 878 if cert_file is not None: |
| 879 os.remove(cert_file.name) |
| 880 """).encode("utf8") |
| 881 |
| 882 cmd = [py_executable, '-'] + project_names |
| 959 logger.start_progress('Installing %s...' % (', '.join(project_names))) | 883 logger.start_progress('Installing %s...' % (', '.join(project_names))) |
| 960 logger.indent += 2 | 884 logger.indent += 2 |
| 885 |
| 886 env = { |
| 887 "PYTHONPATH": pythonpath, |
| 888 "JYTHONPATH": pythonpath, # for Jython < 3.x |
| 889 "PIP_FIND_LINKS": findlinks, |
| 890 "PIP_USE_WHEEL": "1", |
| 891 "PIP_ONLY_BINARY": ":all:", |
| 892 "PIP_PRE": "1", |
| 893 "PIP_USER": "0", |
| 894 } |
| 895 |
| 896 if not download: |
| 897 env["PIP_NO_INDEX"] = "1" |
| 898 |
| 961 try: | 899 try: |
| 962 call_subprocess(cmd, show_stdout=False, | 900 call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT) |
| 963 extra_env = { | |
| 964 'PYTHONPATH': pythonpath, | |
| 965 'JYTHONPATH': pythonpath, # for Jython < 3.x | |
| 966 'PIP_FIND_LINKS': findlinks, | |
| 967 'PIP_USE_WHEEL': '1', | |
| 968 'PIP_PRE': '1', | |
| 969 'PIP_NO_INDEX': '1' | |
| 970 } | |
| 971 ) | |
| 972 finally: | 901 finally: |
| 973 logger.indent -= 2 | 902 logger.indent -= 2 |
| 974 logger.end_progress() | 903 logger.end_progress() |
| 975 | 904 |
| 905 |
| 976 def create_environment(home_dir, site_packages=False, clear=False, | 906 def create_environment(home_dir, site_packages=False, clear=False, |
| 977 unzip_setuptools=False, | 907 unzip_setuptools=False, |
| 978 prompt=None, search_dirs=None, never_download=False, | 908 prompt=None, search_dirs=None, download=False, |
| 979 no_setuptools=False, no_pip=False, no_wheel=False, | 909 no_setuptools=False, no_pip=False, no_wheel=False, |
| 980 symlink=True): | 910 symlink=True): |
| 981 """ | 911 """ |
| 982 Creates a new environment in ``home_dir``. | 912 Creates a new environment in ``home_dir``. |
| 983 | 913 |
| 984 If ``site_packages`` is true, then the global ``site-packages/`` | 914 If ``site_packages`` is true, then the global ``site-packages/`` |
| 985 directory will be on the path. | 915 directory will be on the path. |
| 986 | 916 |
| 987 If ``clear`` is true (default False) then the environment will | 917 If ``clear`` is true (default False) then the environment will |
| 988 first be cleared. | 918 first be cleared. |
| 989 """ | 919 """ |
| 990 home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) | 920 home_dir, lib_dir, inc_dir, bin_dir = path_locations(home_dir) |
| 991 | 921 |
| 992 py_executable = os.path.abspath(install_python( | 922 py_executable = os.path.abspath(install_python( |
| 993 home_dir, lib_dir, inc_dir, bin_dir, | 923 home_dir, lib_dir, inc_dir, bin_dir, |
| 994 site_packages=site_packages, clear=clear, symlink=symlink)) | 924 site_packages=site_packages, clear=clear, symlink=symlink)) |
| 995 | 925 |
| 996 install_distutils(home_dir) | 926 install_distutils(home_dir) |
| 997 | 927 |
| 928 to_install = [] |
| 929 |
| 998 if not no_setuptools: | 930 if not no_setuptools: |
| 999 to_install = ['setuptools'] | 931 to_install.append('setuptools') |
| 1000 if not no_pip: | 932 |
| 1001 to_install.append('pip') | 933 if not no_pip: |
| 1002 if not no_wheel: | 934 to_install.append('pip') |
| 1003 to_install.append('wheel') | 935 |
| 1004 install_wheel(to_install, py_executable, search_dirs) | 936 if not no_wheel: |
| 937 to_install.append('wheel') |
| 938 |
| 939 if to_install: |
| 940 install_wheel( |
| 941 to_install, |
| 942 py_executable, |
| 943 search_dirs, |
| 944 download=download, |
| 945 ) |
| 1005 | 946 |
| 1006 install_activate(home_dir, bin_dir, prompt) | 947 install_activate(home_dir, bin_dir, prompt) |
| 1007 | 948 |
| 949 install_python_config(home_dir, bin_dir, prompt) |
| 950 |
| 1008 def is_executable_file(fpath): | 951 def is_executable_file(fpath): |
| 1009 return os.path.isfile(fpath) and os.access(fpath, os.X_OK) | 952 return os.path.isfile(fpath) and os.access(fpath, os.X_OK) |
| 1010 | 953 |
| 1011 def path_locations(home_dir): | 954 def path_locations(home_dir): |
| 1012 """Return the path locations for the environment (where libraries are, | 955 """Return the path locations for the environment (where libraries are, |
| 1013 where scripts go, etc)""" | 956 where scripts go, etc)""" |
| 957 home_dir = os.path.abspath(home_dir) |
| 1014 # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its | 958 # XXX: We'd use distutils.sysconfig.get_python_inc/lib but its |
| 1015 # prefix arg is broken: http://bugs.python.org/issue3386 | 959 # prefix arg is broken: http://bugs.python.org/issue3386 |
| 1016 if is_win: | 960 if is_win: |
| 1017 # Windows has lots of problems with executables with spaces in | 961 # Windows has lots of problems with executables with spaces in |
| 1018 # the name; this function will remove them (using the ~1 | 962 # the name; this function will remove them (using the ~1 |
| 1019 # format): | 963 # format): |
| 1020 mkdir(home_dir) | 964 mkdir(home_dir) |
| 1021 if ' ' in home_dir: | 965 if ' ' in home_dir: |
| 1022 import ctypes | 966 import ctypes |
| 1023 GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW | 967 GetShortPathName = ctypes.windll.kernel32.GetShortPathNameW |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1040 if is_jython: | 984 if is_jython: |
| 1041 lib_dir = join(home_dir, 'Lib') | 985 lib_dir = join(home_dir, 'Lib') |
| 1042 inc_dir = join(home_dir, 'Include') | 986 inc_dir = join(home_dir, 'Include') |
| 1043 bin_dir = join(home_dir, 'bin') | 987 bin_dir = join(home_dir, 'bin') |
| 1044 elif is_pypy: | 988 elif is_pypy: |
| 1045 lib_dir = home_dir | 989 lib_dir = home_dir |
| 1046 inc_dir = join(home_dir, 'include') | 990 inc_dir = join(home_dir, 'include') |
| 1047 bin_dir = join(home_dir, 'bin') | 991 bin_dir = join(home_dir, 'bin') |
| 1048 elif not is_win: | 992 elif not is_win: |
| 1049 lib_dir = join(home_dir, 'lib', py_version) | 993 lib_dir = join(home_dir, 'lib', py_version) |
| 1050 multiarch_exec = '/usr/bin/multiarch-platform' | 994 inc_dir = join(home_dir, 'include', py_version + abiflags) |
| 1051 if is_executable_file(multiarch_exec): | |
| 1052 # In Mageia (2) and Mandriva distros the include dir must be like: | |
| 1053 # virtualenv/include/multiarch-x86_64-linux/python2.7 | |
| 1054 # instead of being virtualenv/include/python2.7 | |
| 1055 p = subprocess.Popen(multiarch_exec, stdout=subprocess.PIPE, stderr=
subprocess.PIPE) | |
| 1056 stdout, stderr = p.communicate() | |
| 1057 # stdout.strip is needed to remove newline character | |
| 1058 inc_dir = join(home_dir, 'include', stdout.strip(), py_version + abi
flags) | |
| 1059 else: | |
| 1060 inc_dir = join(home_dir, 'include', py_version + abiflags) | |
| 1061 bin_dir = join(home_dir, 'bin') | 995 bin_dir = join(home_dir, 'bin') |
| 1062 return home_dir, lib_dir, inc_dir, bin_dir | 996 return home_dir, lib_dir, inc_dir, bin_dir |
| 1063 | 997 |
| 1064 | 998 |
| 1065 def change_prefix(filename, dst_prefix): | 999 def change_prefix(filename, dst_prefix): |
| 1066 prefixes = [sys.prefix] | 1000 prefixes = [sys.prefix] |
| 1067 | 1001 |
| 1068 if is_darwin: | 1002 if is_darwin: |
| 1069 prefixes.extend(( | 1003 prefixes.extend(( |
| 1070 os.path.join("/Library/Python", sys.version[:3], "site-packages"), | 1004 os.path.join("/Library/Python", sys.version[:3], "site-packages"), |
| 1071 os.path.join(sys.prefix, "Extras", "lib", "python"), | 1005 os.path.join(sys.prefix, "Extras", "lib", "python"), |
| 1072 os.path.join("~", "Library", "Python", sys.version[:3], "site-packag
es"), | 1006 os.path.join("~", "Library", "Python", sys.version[:3], "site-packag
es"), |
| 1073 # Python 2.6 no-frameworks | 1007 # Python 2.6 no-frameworks |
| 1074 os.path.join("~", ".local", "lib","python", sys.version[:3], "site-p
ackages"), | 1008 os.path.join("~", ".local", "lib","python", sys.version[:3], "site-p
ackages"), |
| 1075 # System Python 2.7 on OSX Mountain Lion | 1009 # System Python 2.7 on OSX Mountain Lion |
| 1076 os.path.join("~", "Library", "Python", sys.version[:3], "lib", "pyth
on", "site-packages"))) | 1010 os.path.join("~", "Library", "Python", sys.version[:3], "lib", "pyth
on", "site-packages"))) |
| 1077 | 1011 |
| 1078 if hasattr(sys, 'real_prefix'): | 1012 if hasattr(sys, 'real_prefix'): |
| 1079 prefixes.append(sys.real_prefix) | 1013 prefixes.append(sys.real_prefix) |
| 1080 if hasattr(sys, 'base_prefix'): | 1014 if hasattr(sys, 'base_prefix'): |
| 1081 prefixes.append(sys.base_prefix) | 1015 prefixes.append(sys.base_prefix) |
| 1082 prefixes = list(map(os.path.expanduser, prefixes)) | 1016 prefixes = list(map(os.path.expanduser, prefixes)) |
| 1083 prefixes = list(map(os.path.abspath, prefixes)) | 1017 prefixes = list(map(os.path.abspath, prefixes)) |
| 1084 # Check longer prefixes first so we don't split in the middle of a filename | 1018 # Check longer prefixes first so we don't split in the middle of a filename |
| 1085 prefixes = sorted(prefixes, key=len, reverse=True) | 1019 prefixes = sorted(prefixes, key=len, reverse=True) |
| 1086 filename = os.path.abspath(filename) | 1020 filename = os.path.abspath(filename) |
| 1021 # On Windows, make sure drive letter is uppercase |
| 1022 if is_win and filename[0] in 'abcdefghijklmnopqrstuvwxyz': |
| 1023 filename = filename[0].upper() + filename[1:] |
| 1024 for i, prefix in enumerate(prefixes): |
| 1025 if is_win and prefix[0] in 'abcdefghijklmnopqrstuvwxyz': |
| 1026 prefixes[i] = prefix[0].upper() + prefix[1:] |
| 1087 for src_prefix in prefixes: | 1027 for src_prefix in prefixes: |
| 1088 if filename.startswith(src_prefix): | 1028 if filename.startswith(src_prefix): |
| 1089 _, relpath = filename.split(src_prefix, 1) | 1029 _, relpath = filename.split(src_prefix, 1) |
| 1090 if src_prefix != os.sep: # sys.prefix == "/" | 1030 if src_prefix != os.sep: # sys.prefix == "/" |
| 1091 assert relpath[0] == os.sep | 1031 assert relpath[0] == os.sep |
| 1092 relpath = relpath[1:] | 1032 relpath = relpath[1:] |
| 1093 return join(dst_prefix, relpath) | 1033 return join(dst_prefix, relpath) |
| 1094 assert False, "Filename %s does not start with any of these prefixes: %s" %
\ | 1034 assert False, "Filename %s does not start with any of these prefixes: %s" %
\ |
| 1095 (filename, prefixes) | 1035 (filename, prefixes) |
| 1096 | 1036 |
| 1097 def copy_required_modules(dst_prefix, symlink): | 1037 def copy_required_modules(dst_prefix, symlink): |
| 1098 import imp | 1038 import imp |
| 1099 # If we are running under -p, we need to remove the current | 1039 |
| 1100 # directory from sys.path temporarily here, so that we | 1040 for modname in REQUIRED_MODULES: |
| 1101 # definitely get the modules from the site directory of | 1041 if modname in sys.builtin_module_names: |
| 1102 # the interpreter we are running under, not the one | 1042 logger.info("Ignoring built-in bootstrap module: %s" % modname) |
| 1103 # virtualenv.py is installed under (which might lead to py2/py3 | 1043 continue |
| 1104 # incompatibility issues) | 1044 try: |
| 1105 _prev_sys_path = sys.path | 1045 f, filename, _ = imp.find_module(modname) |
| 1106 if os.environ.get('VIRTUALENV_INTERPRETER_RUNNING'): | 1046 except ImportError: |
| 1107 sys.path = sys.path[1:] | 1047 logger.info("Cannot import bootstrap module: %s" % modname) |
| 1108 try: | 1048 else: |
| 1109 for modname in REQUIRED_MODULES: | 1049 if f is not None: |
| 1110 if modname in sys.builtin_module_names: | 1050 f.close() |
| 1111 logger.info("Ignoring built-in bootstrap module: %s" % modname) | 1051 # special-case custom readline.so on OS X, but not for pypy: |
| 1112 continue | 1052 if modname == 'readline' and sys.platform == 'darwin' and not ( |
| 1113 try: | 1053 is_pypy or filename.endswith(join('lib-dynload', 'readline.s
o'))): |
| 1114 f, filename, _ = imp.find_module(modname) | 1054 dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.version[
:3], 'readline.so') |
| 1115 except ImportError: | 1055 elif modname == 'readline' and sys.platform == 'win32': |
| 1116 logger.info("Cannot import bootstrap module: %s" % modname) | 1056 # special-case for Windows, where readline is not a |
| 1057 # standard module, though it may have been installed in |
| 1058 # site-packages by a third-party package |
| 1059 pass |
| 1117 else: | 1060 else: |
| 1118 if f is not None: | 1061 dst_filename = change_prefix(filename, dst_prefix) |
| 1119 f.close() | 1062 copyfile(filename, dst_filename, symlink) |
| 1120 # special-case custom readline.so on OS X, but not for pypy: | 1063 if filename.endswith('.pyc'): |
| 1121 if modname == 'readline' and sys.platform == 'darwin' and not ( | 1064 pyfile = filename[:-1] |
| 1122 is_pypy or filename.endswith(join('lib-dynload', 'readli
ne.so'))): | 1065 if os.path.exists(pyfile): |
| 1123 dst_filename = join(dst_prefix, 'lib', 'python%s' % sys.vers
ion[:3], 'readline.so') | 1066 copyfile(pyfile, dst_filename[:-1], symlink) |
| 1124 elif modname == 'readline' and sys.platform == 'win32': | |
| 1125 # special-case for Windows, where readline is not a | |
| 1126 # standard module, though it may have been installed in | |
| 1127 # site-packages by a third-party package | |
| 1128 pass | |
| 1129 else: | |
| 1130 dst_filename = change_prefix(filename, dst_prefix) | |
| 1131 copyfile(filename, dst_filename, symlink) | |
| 1132 if filename.endswith('.pyc'): | |
| 1133 pyfile = filename[:-1] | |
| 1134 if os.path.exists(pyfile): | |
| 1135 copyfile(pyfile, dst_filename[:-1], symlink) | |
| 1136 finally: | |
| 1137 sys.path = _prev_sys_path | |
| 1138 | 1067 |
| 1068 def copy_tcltk(src, dest, symlink): |
| 1069 """ copy tcl/tk libraries on Windows (issue #93) """ |
| 1070 if majver == 2: |
| 1071 libver = '8.5' |
| 1072 else: |
| 1073 libver = '8.6' |
| 1074 for name in ['tcl', 'tk']: |
| 1075 srcdir = src + '/tcl/' + name + libver |
| 1076 dstdir = dest + '/tcl/' + name + libver |
| 1077 if os.path.exists(srcdir): |
| 1078 copyfileordir(srcdir, dstdir, symlink) |
| 1139 | 1079 |
| 1140 def subst_path(prefix_path, prefix, home_dir): | 1080 def subst_path(prefix_path, prefix, home_dir): |
| 1141 prefix_path = os.path.normpath(prefix_path) | 1081 prefix_path = os.path.normpath(prefix_path) |
| 1142 prefix = os.path.normpath(prefix) | 1082 prefix = os.path.normpath(prefix) |
| 1143 home_dir = os.path.normpath(home_dir) | 1083 home_dir = os.path.normpath(home_dir) |
| 1144 if not prefix_path.startswith(prefix): | 1084 if not prefix_path.startswith(prefix): |
| 1145 logger.warn('Path not in prefix %r %r', prefix_path, prefix) | 1085 logger.warn('Path not in prefix %r %r', prefix_path, prefix) |
| 1146 return | 1086 return |
| 1147 return prefix_path.replace(prefix, home_dir, 1) | 1087 return prefix_path.replace(prefix, home_dir, 1) |
| 1148 | 1088 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 if not os.path.isdir(stdlib_dir): | 1125 if not os.path.isdir(stdlib_dir): |
| 1186 continue | 1126 continue |
| 1187 for fn in os.listdir(stdlib_dir): | 1127 for fn in os.listdir(stdlib_dir): |
| 1188 bn = os.path.splitext(fn)[0] | 1128 bn = os.path.splitext(fn)[0] |
| 1189 if fn != 'site-packages' and bn in REQUIRED_FILES: | 1129 if fn != 'site-packages' and bn in REQUIRED_FILES: |
| 1190 copyfile(join(stdlib_dir, fn), join(lib_dir, fn), symlink) | 1130 copyfile(join(stdlib_dir, fn), join(lib_dir, fn), symlink) |
| 1191 # ...and modules | 1131 # ...and modules |
| 1192 copy_required_modules(home_dir, symlink) | 1132 copy_required_modules(home_dir, symlink) |
| 1193 finally: | 1133 finally: |
| 1194 logger.indent -= 2 | 1134 logger.indent -= 2 |
| 1135 # ...copy tcl/tk |
| 1136 if is_win: |
| 1137 copy_tcltk(prefix, home_dir, symlink) |
| 1195 mkdir(join(lib_dir, 'site-packages')) | 1138 mkdir(join(lib_dir, 'site-packages')) |
| 1196 import site | 1139 import site |
| 1197 site_filename = site.__file__ | 1140 site_filename = site.__file__ |
| 1198 if site_filename.endswith('.pyc'): | 1141 if site_filename.endswith('.pyc') or site_filename.endswith('.pyo'): |
| 1199 site_filename = site_filename[:-1] | 1142 site_filename = site_filename[:-1] |
| 1200 elif site_filename.endswith('$py.class'): | 1143 elif site_filename.endswith('$py.class'): |
| 1201 site_filename = site_filename.replace('$py.class', '.py') | 1144 site_filename = site_filename.replace('$py.class', '.py') |
| 1202 site_filename_dst = change_prefix(site_filename, home_dir) | 1145 site_filename_dst = change_prefix(site_filename, home_dir) |
| 1203 site_dir = os.path.dirname(site_filename_dst) | 1146 site_dir = os.path.dirname(site_filename_dst) |
| 1204 writefile(site_filename_dst, SITE_PY) | 1147 writefile(site_filename_dst, SITE_PY) |
| 1205 writefile(join(site_dir, 'orig-prefix.txt'), prefix) | 1148 writefile(join(site_dir, 'orig-prefix.txt'), prefix) |
| 1206 site_packages_filename = join(site_dir, 'no-global-site-packages.txt') | 1149 site_packages_filename = join(site_dir, 'no-global-site-packages.txt') |
| 1207 if not site_packages: | 1150 if not site_packages: |
| 1208 writefile(site_packages_filename, '') | 1151 writefile(site_packages_filename, '') |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 | 1426 |
| 1484 if site_packages: | 1427 if site_packages: |
| 1485 if os.path.exists(site_packages_filename): | 1428 if os.path.exists(site_packages_filename): |
| 1486 logger.info('Deleting %s' % site_packages_filename) | 1429 logger.info('Deleting %s' % site_packages_filename) |
| 1487 os.unlink(site_packages_filename) | 1430 os.unlink(site_packages_filename) |
| 1488 | 1431 |
| 1489 return py_executable | 1432 return py_executable |
| 1490 | 1433 |
| 1491 | 1434 |
| 1492 def install_activate(home_dir, bin_dir, prompt=None): | 1435 def install_activate(home_dir, bin_dir, prompt=None): |
| 1493 home_dir = os.path.abspath(home_dir) | |
| 1494 if is_win or is_jython and os._name == 'nt': | 1436 if is_win or is_jython and os._name == 'nt': |
| 1495 files = { | 1437 files = { |
| 1496 'activate.bat': ACTIVATE_BAT, | 1438 'activate.bat': ACTIVATE_BAT, |
| 1497 'deactivate.bat': DEACTIVATE_BAT, | 1439 'deactivate.bat': DEACTIVATE_BAT, |
| 1498 'activate.ps1': ACTIVATE_PS, | 1440 'activate.ps1': ACTIVATE_PS, |
| 1499 } | 1441 } |
| 1500 | 1442 |
| 1501 # MSYS needs paths of the form /c/path/to/file | 1443 # MSYS needs paths of the form /c/path/to/file |
| 1502 drive, tail = os.path.splitdrive(home_dir.replace(os.sep, '/')) | 1444 drive, tail = os.path.splitdrive(home_dir.replace(os.sep, '/')) |
| 1503 home_dir_msys = (drive and "/%s%s" or "%s%s") % (drive[:1], tail) | 1445 home_dir_msys = (drive and "/%s%s" or "%s%s") % (drive[:1], tail) |
| 1504 | 1446 |
| 1505 # Run-time conditional enables (basic) Cygwin compatibility | 1447 # Run-time conditional enables (basic) Cygwin compatibility |
| 1506 home_dir_sh = ("""$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u '%s'
; else echo '%s'; fi;)""" % | 1448 home_dir_sh = ("""$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u '%s'
; else echo '%s'; fi;)""" % |
| 1507 (home_dir, home_dir_msys)) | 1449 (home_dir, home_dir_msys)) |
| 1508 files['activate'] = ACTIVATE_SH.replace('__VIRTUAL_ENV__', home_dir_sh) | 1450 files['activate'] = ACTIVATE_SH.replace('__VIRTUAL_ENV__', home_dir_sh) |
| 1509 | 1451 |
| 1510 else: | 1452 else: |
| 1511 files = {'activate': ACTIVATE_SH} | 1453 files = {'activate': ACTIVATE_SH} |
| 1512 | 1454 |
| 1513 # suppling activate.fish in addition to, not instead of, the | 1455 # suppling activate.fish in addition to, not instead of, the |
| 1514 # bash script support. | 1456 # bash script support. |
| 1515 files['activate.fish'] = ACTIVATE_FISH | 1457 files['activate.fish'] = ACTIVATE_FISH |
| 1516 | 1458 |
| 1517 # same for csh/tcsh support... | 1459 # same for csh/tcsh support... |
| 1518 files['activate.csh'] = ACTIVATE_CSH | 1460 files['activate.csh'] = ACTIVATE_CSH |
| 1519 | 1461 |
| 1520 files['activate_this.py'] = ACTIVATE_THIS | 1462 files['activate_this.py'] = ACTIVATE_THIS |
| 1463 |
| 1464 install_files(home_dir, bin_dir, prompt, files) |
| 1465 |
| 1466 def install_files(home_dir, bin_dir, prompt, files): |
| 1521 if hasattr(home_dir, 'decode'): | 1467 if hasattr(home_dir, 'decode'): |
| 1522 home_dir = home_dir.decode(sys.getfilesystemencoding()) | 1468 home_dir = home_dir.decode(sys.getfilesystemencoding()) |
| 1523 vname = os.path.basename(home_dir) | 1469 vname = os.path.basename(home_dir) |
| 1524 for name, content in files.items(): | 1470 for name, content in files.items(): |
| 1525 content = content.replace('__VIRTUAL_PROMPT__', prompt or '') | 1471 content = content.replace('__VIRTUAL_PROMPT__', prompt or '') |
| 1526 content = content.replace('__VIRTUAL_WINPROMPT__', prompt or '(%s)' % vn
ame) | 1472 content = content.replace('__VIRTUAL_WINPROMPT__', prompt or '(%s)' % vn
ame) |
| 1527 content = content.replace('__VIRTUAL_ENV__', home_dir) | 1473 content = content.replace('__VIRTUAL_ENV__', home_dir) |
| 1528 content = content.replace('__VIRTUAL_NAME__', vname) | 1474 content = content.replace('__VIRTUAL_NAME__', vname) |
| 1529 content = content.replace('__BIN_NAME__', os.path.basename(bin_dir)) | 1475 content = content.replace('__BIN_NAME__', os.path.basename(bin_dir)) |
| 1530 writefile(os.path.join(bin_dir, name), content) | 1476 writefile(os.path.join(bin_dir, name), content) |
| 1531 | 1477 |
| 1478 def install_python_config(home_dir, bin_dir, prompt=None): |
| 1479 if sys.platform == 'win32' or is_jython and os._name == 'nt': |
| 1480 files = {} |
| 1481 else: |
| 1482 files = {'python-config': PYTHON_CONFIG} |
| 1483 install_files(home_dir, bin_dir, prompt, files) |
| 1484 for name, content in files.items(): |
| 1485 make_exe(os.path.join(bin_dir, name)) |
| 1486 |
| 1532 def install_distutils(home_dir): | 1487 def install_distutils(home_dir): |
| 1533 distutils_path = change_prefix(distutils.__path__[0], home_dir) | 1488 distutils_path = change_prefix(distutils.__path__[0], home_dir) |
| 1534 mkdir(distutils_path) | 1489 mkdir(distutils_path) |
| 1535 ## FIXME: maybe this prefix setting should only be put in place if | 1490 ## FIXME: maybe this prefix setting should only be put in place if |
| 1536 ## there's a local distutils.cfg with a prefix setting? | 1491 ## there's a local distutils.cfg with a prefix setting? |
| 1537 home_dir = os.path.abspath(home_dir) | 1492 home_dir = os.path.abspath(home_dir) |
| 1538 ## FIXME: this is breaking things, removing for now: | 1493 ## FIXME: this is breaking things, removing for now: |
| 1539 #distutils_cfg = DISTUTILS_CFG + "\n[install]\nprefix=%s\n" % home_dir | 1494 #distutils_cfg = DISTUTILS_CFG + "\n[install]\nprefix=%s\n" % home_dir |
| 1540 writefile(os.path.join(distutils_path, '__init__.py'), DISTUTILS_INIT) | 1495 writefile(os.path.join(distutils_path, '__init__.py'), DISTUTILS_INIT) |
| 1541 writefile(os.path.join(distutils_path, 'distutils.cfg'), DISTUTILS_CFG, over
write=False) | 1496 writefile(os.path.join(distutils_path, 'distutils.cfg'), DISTUTILS_CFG, over
write=False) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1559 continue | 1514 continue |
| 1560 copyfile(os.path.abspath(os.path.join(home_dir, subdir_name)
), \ | 1515 copyfile(os.path.abspath(os.path.join(home_dir, subdir_name)
), \ |
| 1561 os.path.join(local_p
ath, subdir_name), symlink) | 1516 os.path.join(local_p
ath, subdir_name), symlink) |
| 1562 | 1517 |
| 1563 def fix_lib64(lib_dir, symlink=True): | 1518 def fix_lib64(lib_dir, symlink=True): |
| 1564 """ | 1519 """ |
| 1565 Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y | 1520 Some platforms (particularly Gentoo on x64) put things in lib64/pythonX.Y |
| 1566 instead of lib/pythonX.Y. If this is such a platform we'll just create a | 1521 instead of lib/pythonX.Y. If this is such a platform we'll just create a |
| 1567 symlink so lib64 points to lib | 1522 symlink so lib64 points to lib |
| 1568 """ | 1523 """ |
| 1569 if [p for p in distutils.sysconfig.get_config_vars().values() | 1524 # PyPy's library path scheme is not affected by this. |
| 1570 if isinstance(p, basestring) and 'lib64' in p]: | 1525 # Return early or we will die on the following assert. |
| 1571 # PyPy's library path scheme is not affected by this. | 1526 if is_pypy: |
| 1572 # Return early or we will die on the following assert. | 1527 logger.debug('PyPy detected, skipping lib64 symlinking') |
| 1573 if is_pypy: | 1528 return |
| 1574 logger.debug('PyPy detected, skipping lib64 symlinking') | 1529 # Check we have a lib64 library path |
| 1575 return | 1530 if not [p for p in distutils.sysconfig.get_config_vars().values() |
| 1531 if isinstance(p, basestring) and 'lib64' in p]: |
| 1532 return |
| 1576 | 1533 |
| 1577 logger.debug('This system uses lib64; symlinking lib64 to lib') | 1534 logger.debug('This system uses lib64; symlinking lib64 to lib') |
| 1578 | 1535 |
| 1579 assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], ( | 1536 assert os.path.basename(lib_dir) == 'python%s' % sys.version[:3], ( |
| 1580 "Unexpected python lib dir: %r" % lib_dir) | 1537 "Unexpected python lib dir: %r" % lib_dir) |
| 1581 lib_parent = os.path.dirname(lib_dir) | 1538 lib_parent = os.path.dirname(lib_dir) |
| 1582 top_level = os.path.dirname(lib_parent) | 1539 top_level = os.path.dirname(lib_parent) |
| 1583 lib_dir = os.path.join(top_level, 'lib') | 1540 lib_dir = os.path.join(top_level, 'lib') |
| 1584 lib64_link = os.path.join(top_level, 'lib64') | 1541 lib64_link = os.path.join(top_level, 'lib64') |
| 1585 assert os.path.basename(lib_parent) == 'lib', ( | 1542 assert os.path.basename(lib_parent) == 'lib', ( |
| 1586 "Unexpected parent dir: %r" % lib_parent) | 1543 "Unexpected parent dir: %r" % lib_parent) |
| 1587 if os.path.lexists(lib64_link): | 1544 if os.path.lexists(lib64_link): |
| 1588 return | 1545 return |
| 1589 if symlink: | 1546 if symlink: |
| 1590 os.symlink('lib', lib64_link) | 1547 os.symlink('lib', lib64_link) |
| 1591 else: | 1548 else: |
| 1592 copyfile('lib', lib64_link) | 1549 copyfile('lib', lib64_link) |
| 1593 | 1550 |
| 1594 def resolve_interpreter(exe): | 1551 def resolve_interpreter(exe): |
| 1595 """ | 1552 """ |
| 1596 If the executable given isn't an absolute path, search $PATH for the interpr
eter | 1553 If the executable given isn't an absolute path, search $PATH for the interpr
eter |
| 1597 """ | 1554 """ |
| 1598 # If the "executable" is a version number, get the installed executable for | 1555 # If the "executable" is a version number, get the installed executable for |
| 1599 # that version | 1556 # that version |
| 1600 python_versions = get_installed_pythons() | 1557 python_versions = get_installed_pythons() |
| 1601 if exe in python_versions: | 1558 if exe in python_versions: |
| 1602 exe = python_versions[exe] | 1559 exe = python_versions[exe] |
| 1603 | 1560 |
| 1604 if os.path.abspath(exe) != exe: | 1561 if os.path.abspath(exe) != exe: |
| 1605 paths = os.environ.get('PATH', '').split(os.pathsep) | 1562 paths = os.environ.get('PATH', '').split(os.pathsep) |
| 1606 for path in paths: | 1563 for path in paths: |
| 1607 if os.path.exists(os.path.join(path, exe)): | 1564 if os.path.exists(join(path, exe)): |
| 1608 exe = os.path.join(path, exe) | 1565 exe = join(path, exe) |
| 1609 break | 1566 break |
| 1610 if not os.path.exists(exe): | 1567 if not os.path.exists(exe): |
| 1611 logger.fatal('The executable %s (from --python=%s) does not exist' % (ex
e, exe)) | 1568 logger.fatal('The executable %s (from --python=%s) does not exist' % (ex
e, exe)) |
| 1612 raise SystemExit(3) | 1569 raise SystemExit(3) |
| 1613 if not is_executable(exe): | 1570 if not is_executable(exe): |
| 1614 logger.fatal('The executable %s (from --python=%s) is not executable' %
(exe, exe)) | 1571 logger.fatal('The executable %s (from --python=%s) is not executable' %
(exe, exe)) |
| 1615 raise SystemExit(3) | 1572 raise SystemExit(3) |
| 1616 return exe | 1573 return exe |
| 1617 | 1574 |
| 1618 def is_executable(exe): | 1575 def is_executable(exe): |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 shebang = '#!%s' % os.path.normcase(os.path.join( | 1610 shebang = '#!%s' % os.path.normcase(os.path.join( |
| 1654 os.path.abspath(bin_dir), 'python%s' % new_shebang_args[2])) | 1611 os.path.abspath(bin_dir), 'python%s' % new_shebang_args[2])) |
| 1655 # This is what we'll put: | 1612 # This is what we'll put: |
| 1656 new_shebang = '#!%s python%s%s' % new_shebang_args | 1613 new_shebang = '#!%s python%s%s' % new_shebang_args |
| 1657 | 1614 |
| 1658 for filename in os.listdir(bin_dir): | 1615 for filename in os.listdir(bin_dir): |
| 1659 filename = os.path.join(bin_dir, filename) | 1616 filename = os.path.join(bin_dir, filename) |
| 1660 if not os.path.isfile(filename): | 1617 if not os.path.isfile(filename): |
| 1661 # ignore subdirs, e.g. .svn ones. | 1618 # ignore subdirs, e.g. .svn ones. |
| 1662 continue | 1619 continue |
| 1663 f = open(filename, 'rb') | 1620 lines = None |
| 1664 try: | 1621 with open(filename, 'rb') as f: |
| 1665 try: | 1622 try: |
| 1666 lines = f.read().decode('utf-8').splitlines() | 1623 lines = f.read().decode('utf-8').splitlines() |
| 1667 except UnicodeDecodeError: | 1624 except UnicodeDecodeError: |
| 1668 # This is probably a binary program instead | 1625 # This is probably a binary program instead |
| 1669 # of a script, so just ignore it. | 1626 # of a script, so just ignore it. |
| 1670 continue | 1627 continue |
| 1671 finally: | |
| 1672 f.close() | |
| 1673 if not lines: | 1628 if not lines: |
| 1674 logger.warn('Script %s is an empty file' % filename) | 1629 logger.warn('Script %s is an empty file' % filename) |
| 1675 continue | 1630 continue |
| 1676 | 1631 |
| 1677 old_shebang = lines[0].strip() | 1632 old_shebang = lines[0].strip() |
| 1678 old_shebang = old_shebang[0:2] + os.path.normcase(old_shebang[2:]) | 1633 old_shebang = old_shebang[0:2] + os.path.normcase(old_shebang[2:]) |
| 1679 | 1634 |
| 1680 if not old_shebang.startswith(shebang): | 1635 if not old_shebang.startswith(shebang): |
| 1681 if os.path.basename(filename) in OK_ABS_SCRIPTS: | 1636 if os.path.basename(filename) in OK_ABS_SCRIPTS: |
| 1682 logger.debug('Cannot make script %s relative' % filename) | 1637 logger.debug('Cannot make script %s relative' % filename) |
| 1683 elif lines[0].strip() == new_shebang: | 1638 elif lines[0].strip() == new_shebang: |
| 1684 logger.info('Script %s has already been made relative' % filenam
e) | 1639 logger.info('Script %s has already been made relative' % filenam
e) |
| 1685 else: | 1640 else: |
| 1686 logger.warn('Script %s cannot be made relative (it\'s not a norm
al script that starts with %s)' | 1641 logger.warn('Script %s cannot be made relative (it\'s not a norm
al script that starts with %s)' |
| 1687 % (filename, shebang)) | 1642 % (filename, shebang)) |
| 1688 continue | 1643 continue |
| 1689 logger.notify('Making script %s relative' % filename) | 1644 logger.notify('Making script %s relative' % filename) |
| 1690 script = relative_script([new_shebang] + lines[1:]) | 1645 script = relative_script([new_shebang] + lines[1:]) |
| 1691 f = open(filename, 'wb') | 1646 with open(filename, 'wb') as f: |
| 1692 f.write('\n'.join(script).encode('utf-8')) | 1647 f.write('\n'.join(script).encode('utf-8')) |
| 1693 f.close() | 1648 |
| 1694 | 1649 |
| 1695 def relative_script(lines): | 1650 def relative_script(lines): |
| 1696 "Return a script that'll work in a relocatable environment." | 1651 "Return a script that'll work in a relocatable environment." |
| 1697 activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.re
alpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(),
activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this" | 1652 activate = "import os; activate_this=os.path.join(os.path.dirname(os.path.re
alpath(__file__)), 'activate_this.py'); exec(compile(open(activate_this).read(),
activate_this, 'exec'), dict(__file__=activate_this)); del os, activate_this" |
| 1698 # Find the last future statement in the script. If we insert the activation | 1653 # Find the last future statement in the script. If we insert the activation |
| 1699 # line before a future statement, Python will raise a SyntaxError. | 1654 # line before a future statement, Python will raise a SyntaxError. |
| 1700 activate_at = None | 1655 activate_at = None |
| 1701 for idx, line in reversed(list(enumerate(lines))): | 1656 for idx, line in reversed(list(enumerate(lines))): |
| 1702 if line.split()[:3] == ['from', '__future__', 'import']: | 1657 if line.split()[:3] == ['from', '__future__', 'import']: |
| 1703 activate_at = idx + 1 | 1658 activate_at = idx + 1 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1730 fixup_pth_file(filename) | 1685 fixup_pth_file(filename) |
| 1731 if filename.endswith('.egg-link'): | 1686 if filename.endswith('.egg-link'): |
| 1732 if not os.access(filename, os.W_OK): | 1687 if not os.access(filename, os.W_OK): |
| 1733 logger.warn('Cannot write .egg-link file %s, skipping' % fil
ename) | 1688 logger.warn('Cannot write .egg-link file %s, skipping' % fil
ename) |
| 1734 else: | 1689 else: |
| 1735 fixup_egg_link(filename) | 1690 fixup_egg_link(filename) |
| 1736 | 1691 |
| 1737 def fixup_pth_file(filename): | 1692 def fixup_pth_file(filename): |
| 1738 lines = [] | 1693 lines = [] |
| 1739 prev_lines = [] | 1694 prev_lines = [] |
| 1740 f = open(filename) | 1695 with open(filename) as f: |
| 1741 prev_lines = f.readlines() | 1696 prev_lines = f.readlines() |
| 1742 f.close() | |
| 1743 for line in prev_lines: | 1697 for line in prev_lines: |
| 1744 line = line.strip() | 1698 line = line.strip() |
| 1745 if (not line or line.startswith('#') or line.startswith('import ') | 1699 if (not line or line.startswith('#') or line.startswith('import ') |
| 1746 or os.path.abspath(line) != line): | 1700 or os.path.abspath(line) != line): |
| 1747 lines.append(line) | 1701 lines.append(line) |
| 1748 else: | 1702 else: |
| 1749 new_value = make_relative_path(filename, line) | 1703 new_value = make_relative_path(filename, line) |
| 1750 if line != new_value: | 1704 if line != new_value: |
| 1751 logger.debug('Rewriting path %s as %s (in %s)' % (line, new_valu
e, filename)) | 1705 logger.debug('Rewriting path %s as %s (in %s)' % (line, new_valu
e, filename)) |
| 1752 lines.append(new_value) | 1706 lines.append(new_value) |
| 1753 if lines == prev_lines: | 1707 if lines == prev_lines: |
| 1754 logger.info('No changes to .pth file %s' % filename) | 1708 logger.info('No changes to .pth file %s' % filename) |
| 1755 return | 1709 return |
| 1756 logger.notify('Making paths in .pth file %s relative' % filename) | 1710 logger.notify('Making paths in .pth file %s relative' % filename) |
| 1757 f = open(filename, 'w') | 1711 with open(filename, 'w') as f: |
| 1758 f.write('\n'.join(lines) + '\n') | 1712 f.write('\n'.join(lines) + '\n') |
| 1759 f.close() | |
| 1760 | 1713 |
| 1761 def fixup_egg_link(filename): | 1714 def fixup_egg_link(filename): |
| 1762 f = open(filename) | 1715 with open(filename) as f: |
| 1763 link = f.readline().strip() | 1716 link = f.readline().strip() |
| 1764 f.close() | |
| 1765 if os.path.abspath(link) != link: | 1717 if os.path.abspath(link) != link: |
| 1766 logger.debug('Link in %s already relative' % filename) | 1718 logger.debug('Link in %s already relative' % filename) |
| 1767 return | 1719 return |
| 1768 new_link = make_relative_path(filename, link) | 1720 new_link = make_relative_path(filename, link) |
| 1769 logger.notify('Rewriting link %s in %s as %s' % (link, filename, new_link)) | 1721 logger.notify('Rewriting link %s in %s as %s' % (link, filename, new_link)) |
| 1770 f = open(filename, 'w') | 1722 with open(filename, 'w') as f: |
| 1771 f.write(new_link) | 1723 f.write(new_link) |
| 1772 f.close() | |
| 1773 | 1724 |
| 1774 def make_relative_path(source, dest, dest_is_directory=True): | 1725 def make_relative_path(source, dest, dest_is_directory=True): |
| 1775 """ | 1726 """ |
| 1776 Make a filename relative, where the filename is dest, and it is | 1727 Make a filename relative, where the filename is dest, and it is |
| 1777 being referred to from the filename source. | 1728 being referred to from the filename source. |
| 1778 | 1729 |
| 1779 >>> make_relative_path('/usr/share/something/a-file.pth', | 1730 >>> make_relative_path('/usr/share/something/a-file.pth', |
| 1780 ... '/usr/share/another-place/src/Directory') | 1731 ... '/usr/share/another-place/src/Directory') |
| 1781 '../another-place/src/Directory' | 1732 '../another-place/src/Directory' |
| 1782 >>> make_relative_path('/usr/share/something/a-file.pth', | 1733 >>> make_relative_path('/usr/share/something/a-file.pth', |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 script from that package. | 1796 script from that package. |
| 1846 | 1797 |
| 1847 If you provide something like ``python_version='2.5'`` then the | 1798 If you provide something like ``python_version='2.5'`` then the |
| 1848 script will start with ``#!/usr/bin/env python2.5`` instead of | 1799 script will start with ``#!/usr/bin/env python2.5`` instead of |
| 1849 ``#!/usr/bin/env python``. You can use this when the script must | 1800 ``#!/usr/bin/env python``. You can use this when the script must |
| 1850 be run with a particular Python version. | 1801 be run with a particular Python version. |
| 1851 """ | 1802 """ |
| 1852 filename = __file__ | 1803 filename = __file__ |
| 1853 if filename.endswith('.pyc'): | 1804 if filename.endswith('.pyc'): |
| 1854 filename = filename[:-1] | 1805 filename = filename[:-1] |
| 1855 f = codecs.open(filename, 'r', encoding='utf-8') | 1806 with codecs.open(filename, 'r', encoding='utf-8') as f: |
| 1856 content = f.read() | 1807 content = f.read() |
| 1857 f.close() | |
| 1858 py_exe = 'python%s' % python_version | 1808 py_exe = 'python%s' % python_version |
| 1859 content = (('#!/usr/bin/env %s\n' % py_exe) | 1809 content = (('#!/usr/bin/env %s\n' % py_exe) |
| 1860 + '## WARNING: This file is generated\n' | 1810 + '## WARNING: This file is generated\n' |
| 1861 + content) | 1811 + content) |
| 1862 return content.replace('##EXT' 'END##', extra_text) | 1812 return content.replace('##EXT' 'END##', extra_text) |
| 1863 | 1813 |
| 1864 ##EXTEND## | 1814 ##EXTEND## |
| 1865 | 1815 |
| 1866 def convert(s): | 1816 def convert(s): |
| 1867 b = base64.b64decode(s.encode('ascii')) | 1817 b = base64.b64decode(s.encode('ascii')) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 Q+6hHuihalPc51hgzNIcqicV3xFkPs4UdMGX53zgGbre9sPX28uXR/ZwAfkdXzuKhLLJRo5hv3Sy | 1957 Q+6hHuihalPc51hgzNIcqicV3xFkPs4UdMGX53zgGbre9sPX28uXR/ZwAfkdXzuKhLLJRo5hv3Sy |
| 2008 MXdeKul0J2Ypp5Suh3s1JySsW1w5UNknGNrbdEpSBvY/Js+BIY289/0hM9PDu3p/1MbUst4RTEmM | 1958 MXdeKul0J2Ypp5Suh3s1JySsW1w5UNknGNrbdEpSBvY/Js+BIY289/0hM9PDu3p/1MbUst4RTEmM |
| 2009 n6kJTcsp4tG42yeT7nQbtdUFwgVJjwDSUYEAC8F0dKOTILrlLO/xC70bnNd0Ha97whQ6UkHJYj5H | 1959 n6kJTcsp4tG42yeT7nQbtdUFwgVJjwDSUYEAC8F0dKOTILrlLO/xC70bnNd0Ha97whQ6UkHJYj5H |
| 2010 cA/j+zX4tbtTIfGjujOKpj83aHOgXnIQbvYduNXEC4UMm4T21Bs+GHABuCa7v//LR/TvpjHa7oe7 | 1960 cA/j+zX4tbtTIfGjujOKpj83aHOgXnIQbvYduNXEC4UMm4T21Bs+GHABuCa7v//LR/TvpjHa7oe7 |
| 2011 /Grb6lVvHSD7spj5iplBLRKZxxEYGdCbY9LWWC5hBB2voWno6DJUMzfkC3T8KJsWL9umDQY5szPt | 1961 /Grb6lVvHSD7spj5iplBLRKZxxEYGdCbY9LWWC5hBB2voWno6DJUMzfkC3T8KJsWL9umDQY5szPt |
| 2012 AVijEPwfucjncQ== | 1962 AVijEPwfucjncQ== |
| 2013 """) | 1963 """) |
| 2014 | 1964 |
| 2015 ##file activate.sh | 1965 ##file activate.sh |
| 2016 ACTIVATE_SH = convert(""" | 1966 ACTIVATE_SH = convert(""" |
| 2017 eJytVVFvokAQfudXTLEPtTlLeo9tvMSmJpq02hSvl7u2wRUG2QR2DSxSe7n/frOACEVNLlceRHa+ | 1967 eJytVd9v2kAMfs9fYQLq2m4MscdNVKMqEkgtVIQxbeuUHolpTgsXdHehpT/+9/mSEBJS2MOaB0ji |
| 2018 nfl25pvZDswCnoDPQ4QoTRQsENIEPci4CsBMZBq7CAsuLOYqvmYKTTj3YxnBgiXBudGBjUzBZUJI | 1968 z77P9menDpOAK5jzEGERKw0zhFihD/dcB2CrKJYewoyLFvM0XzGNNpzOZbSAGVPBqVWHdRSDx4SI |
| 2019 BXEqgCvweIyuCjeG4eF2F5x14bcB9KQiQQWrjSddI1/oQIx6SYYeoFjzWIoIhYI1izlbhJjkKO7D | 1969 NMhYANfgc4meDteW5ePGC45P4MkCumKhUENzDsu1H3lw1vJx1RJxGMKns6O2lWDqINGgotAHFCsu |
| 2020 M/QEmKfO9O7WeRo/zr4P7pyHwWxkwitcgwpQ5Ej96OX+PmiFwLeVjFUOrNYKaq1Nud3nR2n8nI2m | 1970 I7FAoWHFJGezEFWGqsEvaD5C42naHb93X+A3+elYCgVaxgh8DmQAys9HL2SS0mIaWBgm7mTN/O3G |
| 2021 k9H0friPTGVsUdptaxGrTEfpNVFEskxpXtUkkCkl1UNF9cgLBkx48J4EXyALuBtAwNYIjF5kcmUU | 1971 kzu6vHCng/HkW/fSve5O+hTOpnhfQAcoEry5jKVjNypoO0fgwzKSOgHm79KUK06Jfc7/RebHpD8a |
| 2022 abMKmMq1ULoiRbgsDEkTSsKSGFCJ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VvI2KosIw+vqW1gIItEG5KJb+xb09g65ktwYKgTc51 |
| 2029 Ad37nIU0fCj5NE5gQCuC5sOSu+UdI2NeXg/lFkQIlFpdWVaWZRfvqGiirC9o6liJ9FXGYrSY9mI1 | 1979 uGJ/EFQs0ayEWLCQM5V9N4g+1+8UbXOJzF8bqhKtIqIwicWvzNFROZJlpfD8A7Vc044R0FxkcezG |
| 2030 D/Ncozgn13vJvsznr7DnkJWXsyMH7e42ljdJ+aqNDF1bFnKWFLdj31xtaJYK6EXFgqmV/ymD/ROG | 1980 VzsV75usvTdYef+57v5n1b225qhXfwEmxHEs |
| 2031 +n8O9H8f5vsGOWXsL1+1k3g= | |
| 2032 """) | 1981 """) |
| 2033 | 1982 |
| 2034 ##file activate.fish | 1983 ##file activate.fish |
| 2035 ACTIVATE_FISH = convert(""" | 1984 ACTIVATE_FISH = convert(""" |
| 2036 eJydVW2P2jgQ/s6vmAZQoVpA9/WkqqJaTou0u6x2uZVOVWWZZEKsS+yc7UDpr+84bziQbauLxEvs | 1985 eJyFVVFv2zYQftevuMoOnBS1gr0WGIZ08RADSRw4boBhGGhGOsUcKFIjKbUu9uN7lC2JsrXWDzZM |
| 2037 eXnsZ56ZIWwTYSAWKUJWGAs7hMJgBEdhEwiMKnSIsBNywUMrDtziPBYmCeBDrFUG7v8HmCTW5n8u | 1986 fnf38e6+uwlsdsJCLiRCUVkHrwiVxYy+hHqDbQKvQl3z1ImaO0xyYXdbeP9FuJ1QwMFUSnmcP4dL |
| 2038 Fu7NJJim81Bl08EQTqqAkEupLOhCgrAQCY2hTU+DQVxIiqgkRNiEBphFEKy+kd1BaFvwFOUBuIxA | 1987 2DlXfry+9v/sDqVMUl3AFVi0Vmj1PokmcKtBaecNQTjIhMHUyX0SRXmlKIpWkGEbDuYZzBZfCVcL |
| 2039 oy20BKtAKp3xFMo0QNtCK5mhtMEA6BmSpUELKo38TThwLfguRVNaiRgs0llnEoIR29zfstf18/bv | 1988 4youUdVQ6AyBqwwMusoocB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pMhhCo/lXthQTxJ2ysO4Ka0ad97S7VT/n6YXus6fzk3fLnBZW5C | 1995 nEFTzwO6U+q34cvY7fL55tP94tg58XEA/q7LfdPsaUXFoEIMJdHF5iSW0+48CnDQ82G7n3XzAD6q |
| 2047 KDC6gSO62QDqgFqLCCtPmjegjnLeAdArtSE8VYGbAJ/aLb+vnQutFhk768E9uRbSxhCMzdgEveYw | 1996 Bmo5XuOA0NQ67ir7AXJtQhtLKO7XhC0l39PGOBsHPvzBuHUSjoOnA0ldozGC9gZ5rek3+y3ALHO/ |
| 2048 IZ5ZqFKl6+kz7UR4U+buqQZXu9SIujrAfD7f0FXpozB4Q0gwp31H9mVTZGGC4b871/wm7lvyDLu1 | 1997 kT7AP379lQZLSnFDLtwWihfYxw4nZd+ZR7myfkI2ZTRCuRxmF/bCzkbhcElvYamW9PbDGrvqPKC0 |
| 2049 FUyvTj/yvD66k3UPTs08x1AQQaGziOl0S1qRkPG9COtBTSTWM9NzQ4R64B+Px/l3tDzCgxv5C6Ni | 1998 +D/uLi/sFcxGjOHylYagZzzsjjhw206RQwrWIwOxS2dnk+40xOjX8bTPegz/gdWVSXuaowNuOLda |
| 2050 e+QaF9xFWrxx0V/G5uvYQOdiZzvYpQUVQSIsTr1TTghI33GnPbTA7/GCqcE3oE3GZurq4HeQXQD6 | 1999 wYyNuRPSTcd/B48Ppeg= |
| 2051 32XS1ITj/qLjN72ob0hc5C9bzw8MhfmL | |
| 2052 """) | 2000 """) |
| 2053 | 2001 |
| 2054 ##file activate.csh | 2002 ##file activate.csh |
| 2055 ACTIVATE_CSH = convert(""" | 2003 ACTIVATE_CSH = convert(""" |
| 2056 eJx9VG1P2zAQ/u5fcYQKNgTNPtN1WxlIQ4KCUEGaxuQ6yYVYSuzKdhqVX7+zk3bpy5YPUXL3PPfc | 2004 eJx1U2FP2zAQ/e5f8TAV3Soo+0zXbYUiDQkKQgVp2ibjJNfFUuIg22nVf885SVFLO3+I7Lt3fr6X |
| 2057 ne98DLNCWsh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W2JBtOGcyYVW7SnB3v6RS91g3gKapZ0oWxbHVteYIIq3iv7QeuSrUj6KSqQ+yqsxDj1ivNQxKF |
| 2064 TXX/jbJTbMtUmcxZ+/bbqOsy82suFQg/BhdSOTRhMNBHlUarCpU7JzBhmkKmRejKOQzayQe6MWoa | 2012 YON10Q+NH/ARS95i5Tuqq2Vxfvc23f/FO6zrtXXmJr+ZtMY9/A15ZXFWtmch2rEQ4g1ryVHH |
| 2065 n1wqWmuh6LZAaHxcdeqIlVLhIBJdO9/kbl0It2oEXQj+eGjJOuvOIR/YGRqvFhttUB2XTvLXYN2H | |
| 2066 37CBdbW2W7j2r2+VsCn0doVWcFG1/4y1VwBjfwAyoZhD | |
| 2067 """) | 2013 """) |
| 2068 | 2014 |
| 2069 ##file activate.bat | 2015 ##file activate.bat |
| 2070 ACTIVATE_BAT = convert(""" | 2016 ACTIVATE_BAT = convert(""" |
| 2071 eJx9UdEKgjAUfW6wfxjiIH+hEDKUFHSKLCMI7kNOEkIf9P9pTJ3OLJ/03HPPPed4Es9XS9qqwqgT | 2017 eJx9Ul9LhEAQfxf8DoOclI/dYyFkaCmcq4gZQTBUrincuZFbff12T133TM+nnd35/Zvxlr7XDFhV |
| 2072 PbGKKOdXL4aAFS7A4gvAwgijuiKlqOpGlATS2NeMLE+TjJM9RkQ+SmqAXLrBo1LLIeLdiWlD6jZt | 2018 mUZHOVhFlOWP3g4DUriIWoVomYZpNBWUtGpaWgImO191pFkSpzlcmgaI70jVX7n2Qp8tuByg+46O |
| 2073 r7VNubWkndkXaxg5GO3UaOOKS6drO3luDDiO5my3iA0YAKGzPRV1ack8cOdhysI0CYzIPzjSiH5X | 2019 CMHbMq64T+nmlJt082D1T44muCDk2prgEHF4mdI9RaS/QwSt3zSyIAaftRccvqVTBziD1x/WlPD5 |
| 2074 0QcvC8Lfaj0emsVKYF2rhL5L3fCkVjV76kShi59NHwDniAHzkgDgqBcwOgTMx+gDQQqXCw== | 2020 xd729NDBb8Nr4DU9QNMKsJeH9pkhPedhQsIkDuCDCa6A+NF9IevVFAohkqizdHetg/tkWvPoftWJ |
| 2021 MCqnOxv7/x7Np6yv9P2Ker5dmX8yNyCkkWnbZy3N5LarczlqL8htx2EM9rQ/2H5BvIsIEi8OEG8U |
| 2022 +g8CsNTr |
| 2075 """) | 2023 """) |
| 2076 | 2024 |
| 2077 ##file deactivate.bat | 2025 ##file deactivate.bat |
| 2078 DEACTIVATE_BAT = convert(""" | 2026 DEACTIVATE_BAT = convert(""" |
| 2079 eJxzSE3OyFfIT0vj4ipOLVEI8wwKCXX0iXf1C7Pl4spMU0hJTcvMS01RiPf3cYmHyQYE+fsGhCho | 2027 eJyFkN0KgkAUhO8F32EQpHqFQEjQUPAPMaErqVxzId3IrV6/XST/UDx3c86c4WMO5FYysKJQFVVp |
| 2080 cCkAAUibEkTEVhWLMlUlLk6QGixStlyaeCyJDPHw9/Pw93VFsQguim4ZXAJoIUw5DhX47XUM8UCx | 2028 CEfqxsnJ9DI7SA25i20fFqs3HO+GYLsDZ7h8GM3xfLHrg1QNvpSX4CWpQGvokZk4uqrQAjXjyElB |
| 2081 EchHtwsohN1bILUgw61c/Vy4AJYPYm4= | 2029 a5IjCz0r+2dHcehHCe5MZNmB5R7TdqMqECMptHZh6DN/utb7Zs6Cej8OXYE5J04YOKFvD4GkHuJ0 |
| 2030 pilSd1jG6n87tDZ+BUwUOepI6CGSkFMYWf0ihvT33Qj1A+tCkSI= |
| 2082 """) | 2031 """) |
| 2083 | 2032 |
| 2084 ##file activate.ps1 | 2033 ##file activate.ps1 |
| 2085 ACTIVATE_PS = convert(""" | 2034 ACTIVATE_PS = convert(""" |
| 2086 eJylWdmO41hyfW+g/0FTU7C7IXeJIqmtB/3AnZRIStxF2kaBm7gv4ipyMF/mB3+Sf8GXVGVl1tLT | 2035 eJylWdmO41hyfW+g/0FTU7C7IXeJIqmtB/3AnZRIStxF2kaBm7gv4ipyMF/mB3+Sf8GXVGVl1tLT |
| 2087 43ECSqR4b5wbETeWE8z/+a///vNCDaN6cYtSf5G1dbNw/IVXNIu6aCvX9xa3qsgWl0IJ/7IYinbh | 2036 43ECSqR4b5wbETeWE8z/+a///vNCDaN6cYtSf5G1dbNw/IVXNIu6aCvX9xa3qsgWl0IJ/7IYinbh |
| 2088 2nkOVqs2X0TNjz/8eeFFle826fBhQRaLBkD9uviw+LCy3Sbq7Mb/UNbrH3+YNtLcVaB+Xbipb+eL | 2037 2nkOVqs2X0TNjz/8eeFFle826fBhQRaLBkD9uviw+LCy3Sbq7Mb/UNbrH3+YNtLcVaB+Xbipb+eL |
| 2089 tly0eVsD/M6u6g8//vC+dquobH5VWU75eMFUdvHb4n02RHlXuHYTFfmHbHCLLLNz70NpN+GrBI4p | 2038 tly0eVsD/M6u6g8//vC+dquobH5VWU75eMFUdvHb4n02RHlXuHYTFfmHbHCLLLNz70NpN+GrBI4p |
| 2090 1EeSk4FAXaZR88u0vPip8usi7fznt3fvP+OuPnx49/Pil4td+XnzigIAPoqYQH2J8v4z+C+8b98m | 2039 1EeSk4FAXaZR88u0vPip8usi7fznt3fvP+OuPnx49/Pil4td+XnzigIAPoqYQH2J8v4z+C+8b98m |
| 2091 Q25t7k76LIK0cOz0V89/MXXx0+Lf6z5q3PA/F+/FIif9uqnaadFf/PzXSXYBfqIb2NeApecJwPzI | 2040 Q25t7k76LIK0cOz0V89/MXXx0+Lf6z5q3PA/F+/FIif9uqnaadFf/PzXSXYBfqIb2NeApecJwPzI |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2213 5a3p0cRKiEe2NtLAFikftnDco0ko/SFEVgEZ8aRCZDIPY9xbA8pE9M4jfW/B2CjiHq9zbJVZuOQq | 2162 5a3p0cRKiEe2NtLAFikftnDco0ko/SFEVgEZ8aRCZDIPY9xbA8pE9M4jfW/B2CjiHq9zbJVZuOQq |
| 2214 siwTIvpxKYCembPAU4Muwi/Z4zfvrZ/MXipKeB8C+qisSZYiWfjJfs+0/MFMdWn1hJcO5U7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3azT+0eikVlWD |
| 2187 /vBHbzQumP23uBCjsYdrL9OWARwxs/nuLOzeXbPJTa/Xv6sUmQir5pC1YRLz3eA+CD8Z0XpcW8v9 |
| 2188 MZWF36ryyXXf3yBIz6nzqz8Muyz0m5Qj7OexfYo/Ph3LqvkHUg7AuA== |
| 2189 """) |
| 2190 |
| 2223 MH_MAGIC = 0xfeedface | 2191 MH_MAGIC = 0xfeedface |
| 2224 MH_CIGAM = 0xcefaedfe | 2192 MH_CIGAM = 0xcefaedfe |
| 2225 MH_MAGIC_64 = 0xfeedfacf | 2193 MH_MAGIC_64 = 0xfeedfacf |
| 2226 MH_CIGAM_64 = 0xcffaedfe | 2194 MH_CIGAM_64 = 0xcffaedfe |
| 2227 FAT_MAGIC = 0xcafebabe | 2195 FAT_MAGIC = 0xcafebabe |
| 2228 BIG_ENDIAN = '>' | 2196 BIG_ENDIAN = '>' |
| 2229 LITTLE_ENDIAN = '<' | 2197 LITTLE_ENDIAN = '<' |
| 2230 LC_LOAD_DYLIB = 0xc | 2198 LC_LOAD_DYLIB = 0xc |
| 2231 maxint = majver == 3 and getattr(sys, 'maxsize') or getattr(sys, 'maxint') | 2199 maxint = majver == 3 and getattr(sys, 'maxsize') or getattr(sys, 'maxint') |
| 2232 | 2200 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 elif magic == MH_MAGIC: | 2317 elif magic == MH_MAGIC: |
| 2350 do_macho(file, 32, BIG_ENDIAN) | 2318 do_macho(file, 32, BIG_ENDIAN) |
| 2351 elif magic == MH_CIGAM: | 2319 elif magic == MH_CIGAM: |
| 2352 do_macho(file, 32, LITTLE_ENDIAN) | 2320 do_macho(file, 32, LITTLE_ENDIAN) |
| 2353 elif magic == MH_MAGIC_64: | 2321 elif magic == MH_MAGIC_64: |
| 2354 do_macho(file, 64, BIG_ENDIAN) | 2322 do_macho(file, 64, BIG_ENDIAN) |
| 2355 elif magic == MH_CIGAM_64: | 2323 elif magic == MH_CIGAM_64: |
| 2356 do_macho(file, 64, LITTLE_ENDIAN) | 2324 do_macho(file, 64, LITTLE_ENDIAN) |
| 2357 | 2325 |
| 2358 assert(len(what) >= len(value)) | 2326 assert(len(what) >= len(value)) |
| 2359 do_file(open(path, 'r+b')) | 2327 |
| 2328 with open(path, 'r+b') as f: |
| 2329 do_file(f) |
| 2360 | 2330 |
| 2361 | 2331 |
| 2362 if __name__ == '__main__': | 2332 if __name__ == '__main__': |
| 2363 main() | 2333 main() |
| 2364 | 2334 |
| 2365 ## TODO: | 2335 # TODO: |
| 2366 ## Copy python.exe.manifest | 2336 # Copy python.exe.manifest |
| 2367 ## Monkeypatch distutils.sysconfig | 2337 # Monkeypatch distutils.sysconfig |
| OLD | NEW |