Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Delta Between Two Patch Sets: Lib/distutils/command/install.py

Issue 3871: cross and native build of python for mingw32 with distutils
Left Patch Set: Created 9 years, 6 months ago
Right Patch Set: Created 7 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/distutils/command/build_ext.py ('k') | Lib/distutils/cygwinccompiler.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """distutils.command.install 1 """distutils.command.install
2 2
3 Implements the Distutils 'install' command.""" 3 Implements the Distutils 'install' command."""
4
5 __revision__ = "$Id$"
6 4
7 import sys 5 import sys
8 import os 6 import os
9 7
10 from distutils import log 8 from distutils import log
11 from distutils.core import Command 9 from distutils.core import Command
12 from distutils.debug import DEBUG 10 from distutils.debug import DEBUG
13 from distutils.sysconfig import get_config_vars 11 from distutils.sysconfig import get_config_vars
14 from distutils.errors import DistutilsPlatformError 12 from distutils.errors import DistutilsPlatformError
15 from distutils.file_util import write_file 13 from distutils.file_util import write_file
16 from distutils.util import convert_path, subst_vars, change_root 14 from distutils.util import convert_path, subst_vars, change_root
17 from distutils.util import get_platform 15 from distutils.util import get_platform
18 from distutils.errors import DistutilsOptionError 16 from distutils.errors import DistutilsOptionError
19 17
20 # this keeps compatibility from 2.3 to 2.5 18 # this keeps compatibility from 2.3 to 2.5
21 if sys.version < "2.6": 19 if sys.version < "2.6":
22 USER_BASE = None 20 USER_BASE = None
23 USER_SITE = None 21 USER_SITE = None
24 HAS_USER_SITE = False 22 HAS_USER_SITE = False
25 else: 23 else:
26 from site import USER_BASE 24 from site import USER_BASE
27 from site import USER_SITE 25 from site import USER_SITE
28 HAS_USER_SITE = True 26 HAS_USER_SITE = True
29 27
30 if 'msys' in sys.builtin_module_names: 28 if sys.version < "2.2":
31 WINDOWS_SCHEME = {
32 'purelib': '$base/lib/python$py_version_short/site-packages',
33 'platlib': '$platbase/lib/python$py_version_short/site-packages',
34 'headers': '$base/include/python$py_version_short/$dist_name',
35 'scripts': '$base/bin',
36 'data' : '$base',
37 }
38 elif sys.version < "2.2":
39 WINDOWS_SCHEME = { 29 WINDOWS_SCHEME = {
40 'purelib': '$base', 30 'purelib': '$base',
41 'platlib': '$base', 31 'platlib': '$base',
42 'headers': '$base/Include/$dist_name', 32 'headers': '$base/Include/$dist_name',
43 'scripts': '$base/Scripts', 33 'scripts': '$base/Scripts',
44 'data' : '$base', 34 'data' : '$base',
45 } 35 }
46 else: 36 else:
47 WINDOWS_SCHEME = { 37 WINDOWS_SCHEME = {
48 'purelib': '$base/Lib/site-packages', 38 'purelib': '$base/Lib/site-packages',
49 'platlib': '$base/Lib/site-packages', 39 'platlib': '$base/Lib/site-packages',
50 'headers': '$base/Include/$dist_name', 40 'headers': '$base/Include/$dist_name',
51 'scripts': '$base/Scripts', 41 'scripts': '$base/Scripts',
52 'data' : '$base', 42 'data' : '$base',
53 } 43 }
54 44
55 INSTALL_SCHEMES = { 45 INSTALL_SCHEMES = {
56 'unix_prefix': { 46 'unix_prefix': {
57 'purelib': '$base/lib/python$py_version_short/site-packages', 47 'purelib': '$base/lib/python$py_version_short/site-packages',
58 'platlib': '$platbase/lib/python$py_version_short/site-packages', 48 'platlib': '$platbase/lib/python$py_version_short/site-packages',
59 'headers': '$base/include/python$py_version_short/$dist_name', 49 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
60 'scripts': '$base/bin', 50 'scripts': '$base/bin',
61 'data' : '$base', 51 'data' : '$base',
62 }, 52 },
63 'unix_home': { 53 'unix_home': {
64 'purelib': '$base/lib/python', 54 'purelib': '$base/lib/python',
65 'platlib': '$base/lib/python', 55 'platlib': '$base/lib/python',
66 'headers': '$base/include/python/$dist_name', 56 'headers': '$base/include/python/$dist_name',
67 'scripts': '$base/bin', 57 'scripts': '$base/bin',
68 'data' : '$base', 58 'data' : '$base',
69 }, 59 },
70 'nt': WINDOWS_SCHEME, 60 'nt': WINDOWS_SCHEME,
71 'mac': {
72 'purelib': '$base/Lib/site-packages',
73 'platlib': '$base/Lib/site-packages',
74 'headers': '$base/Include/$dist_name',
75 'scripts': '$base/Scripts',
76 'data' : '$base',
77 },
78
79 'os2': { 61 'os2': {
80 'purelib': '$base/Lib/site-packages', 62 'purelib': '$base/Lib/site-packages',
81 'platlib': '$base/Lib/site-packages', 63 'platlib': '$base/Lib/site-packages',
82 'headers': '$base/Include/$dist_name', 64 'headers': '$base/Include/$dist_name',
83 'scripts': '$base/Scripts', 65 'scripts': '$base/Scripts',
84 'data' : '$base', 66 'data' : '$base',
85 }, 67 },
86 } 68 }
87 69
88 # user site schemes 70 # user site schemes
89 if HAS_USER_SITE: 71 if HAS_USER_SITE:
90 if 'msys' in sys.builtin_module_names: 72 INSTALL_SCHEMES['nt_user'] = {
91 INSTALL_SCHEMES['nt_user'] = { 73 'purelib': '$usersite',
92 'purelib': '$usersite', 74 'platlib': '$usersite',
93 'platlib': '$usersite', 75 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
94 'headers': '$userbase/include/python$py_version_short/$dist_name', 76 'scripts': '$userbase/Scripts',
95 'scripts': '$userbase/bin', 77 'data' : '$userbase',
96 'data' : '$userbase', 78 }
97 }
98 else:
99 INSTALL_SCHEMES['nt_user'] = {
100 'purelib': '$usersite',
101 'platlib': '$usersite',
102 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
103 'scripts': '$userbase/Scripts',
104 'data' : '$userbase',
105 }
106
107 79
108 INSTALL_SCHEMES['unix_user'] = { 80 INSTALL_SCHEMES['unix_user'] = {
109 'purelib': '$usersite', 81 'purelib': '$usersite',
110 'platlib': '$usersite', 82 'platlib': '$usersite',
111 'headers': '$userbase/include/python$py_version_short/$dist_name', 83 'headers':
112 'scripts': '$userbase/bin', 84 '$userbase/include/python$py_version_short$abiflags/$dist_name',
113 'data' : '$userbase',
114 }
115
116 INSTALL_SCHEMES['mac_user'] = {
117 'purelib': '$usersite',
118 'platlib': '$usersite',
119 'headers': '$userbase/$py_version_short/include/$dist_name',
120 'scripts': '$userbase/bin', 85 'scripts': '$userbase/bin',
121 'data' : '$userbase', 86 'data' : '$userbase',
122 } 87 }
123 88
124 INSTALL_SCHEMES['os2_home'] = { 89 INSTALL_SCHEMES['os2_home'] = {
125 'purelib': '$usersite', 90 'purelib': '$usersite',
126 'platlib': '$usersite', 91 'platlib': '$usersite',
127 'headers': '$userbase/include/python$py_version_short/$dist_name', 92 'headers': '$userbase/include/python$py_version_short/$dist_name',
128 'scripts': '$userbase/bin', 93 'scripts': '$userbase/bin',
129 'data' : '$userbase', 94 'data' : '$userbase',
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 304
340 self.dump_dirs("post-finalize_{unix,other}()") 305 self.dump_dirs("post-finalize_{unix,other}()")
341 306
342 # Expand configuration variables, tilde, etc. in self.install_base 307 # Expand configuration variables, tilde, etc. in self.install_base
343 # and self.install_platbase -- that way, we can use $base or 308 # and self.install_platbase -- that way, we can use $base or
344 # $platbase in the other installation directories and not worry 309 # $platbase in the other installation directories and not worry
345 # about needing recursive variable expansion (shudder). 310 # about needing recursive variable expansion (shudder).
346 311
347 py_version = sys.version.split()[0] 312 py_version = sys.version.split()[0]
348 (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix') 313 (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
314 try:
315 abiflags = sys.abiflags
316 except AttributeError:
317 # sys.abiflags may not be defined on all platforms.
318 abiflags = ''
349 self.config_vars = {'dist_name': self.distribution.get_name(), 319 self.config_vars = {'dist_name': self.distribution.get_name(),
350 'dist_version': self.distribution.get_version(), 320 'dist_version': self.distribution.get_version(),
351 'dist_fullname': self.distribution.get_fullname(), 321 'dist_fullname': self.distribution.get_fullname(),
352 'py_version': py_version, 322 'py_version': py_version,
353 'py_version_short': py_version[0:3], 323 'py_version_short': py_version[0:3],
354 'py_version_nodot': py_version[0] + py_version[2], 324 'py_version_nodot': py_version[0] + py_version[2],
355 'sys_prefix': prefix, 325 'sys_prefix': prefix,
356 'prefix': prefix, 326 'prefix': prefix,
357 'sys_exec_prefix': exec_prefix, 327 'sys_exec_prefix': exec_prefix,
358 'exec_prefix': exec_prefix, 328 'exec_prefix': exec_prefix,
329 'abiflags': abiflags,
359 } 330 }
360 331
361 if HAS_USER_SITE: 332 if HAS_USER_SITE:
362 self.config_vars['userbase'] = self.install_userbase 333 self.config_vars['userbase'] = self.install_userbase
363 self.config_vars['usersite'] = self.install_usersite 334 self.config_vars['usersite'] = self.install_usersite
364 335
365 self.expand_basedirs() 336 self.expand_basedirs()
366 337
367 self.dump_dirs("post-expand_basedirs()") 338 self.dump_dirs("post-expand_basedirs()")
368 339
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 # Well, we're not actually fully completely finalized yet: we still 377 # Well, we're not actually fully completely finalized yet: we still
407 # have to deal with 'extra_path', which is the hack for allowing 378 # have to deal with 'extra_path', which is the hack for allowing
408 # non-packagized module distributions (hello, Numerical Python!) to 379 # non-packagized module distributions (hello, Numerical Python!) to
409 # get their own directories. 380 # get their own directories.
410 self.handle_extra_path() 381 self.handle_extra_path()
411 self.install_libbase = self.install_lib # needed for .pth file 382 self.install_libbase = self.install_lib # needed for .pth file
412 self.install_lib = os.path.join(self.install_lib, self.extra_dirs) 383 self.install_lib = os.path.join(self.install_lib, self.extra_dirs)
413 384
414 # If a new root directory was supplied, make all the installation 385 # If a new root directory was supplied, make all the installation
415 # dirs relative to it. 386 # dirs relative to it.
416 if self.root is not None: 387
388 # root and prefix aren't clearly defined or used in the midst of this in stall
389 # on posix systems prefix is used to define a base path. If root is used
390 # in addition, it will prefix the prefix path. Not sure if that's intent ional
391 # or not but it certainly doesn't work on mingw.
392 # Ex: prefix=/mingw/, root=/mingw/lib
393 # this will distribute all the scrits and libs in /mingw/lib/mingw
394 #
395 print('root=%s, prefix-%s' % (self.root, prefix))
396 if self.root is not None and prefix is None:
417 self.change_roots('libbase', 'lib', 'purelib', 'platlib', 397 self.change_roots('libbase', 'lib', 'purelib', 'platlib',
418 'scripts', 'data', 'headers') 398 'scripts', 'data', 'headers')
419 399
420 self.dump_dirs("after prepending root") 400 self.dump_dirs("after prepending root")
421 401
422 # Find out the build directories, ie. where to install from. 402 # Find out the build directories, ie. where to install from.
423 self.set_undefined_options('build', 403 self.set_undefined_options('build',
424 ('build_base', 'build_base'), 404 ('build_base', 'build_base'),
425 ('build_lib', 'build_lib')) 405 ('build_lib', 'build_lib'))
426 406
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 return self.distribution.has_data_files() 680 return self.distribution.has_data_files()
701 681
702 # 'sub_commands': a list of commands this command might have to run to 682 # 'sub_commands': a list of commands this command might have to run to
703 # get its work done. See cmd.py for more info. 683 # get its work done. See cmd.py for more info.
704 sub_commands = [('install_lib', has_lib), 684 sub_commands = [('install_lib', has_lib),
705 ('install_headers', has_headers), 685 ('install_headers', has_headers),
706 ('install_scripts', has_scripts), 686 ('install_scripts', has_scripts),
707 ('install_data', has_data), 687 ('install_data', has_data),
708 ('install_egg_info', lambda self:True), 688 ('install_egg_info', lambda self:True),
709 ] 689 ]
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+