From: <cg...@us...> - 2007-12-30 02:04:56
|
Revision: 3898 http://jython.svn.sourceforge.net/jython/?rev=3898&view=rev Author: cgroves Date: 2007-12-29 18:04:55 -0800 (Sat, 29 Dec 2007) Log Message: ----------- Merged revisions 3858-3897 via svnmerge from https://jython.svn.sourceforge.net/svnroot/jython/trunk/jython ........ r3863 | pjenvey | 2007-12-24 11:36:03 -0800 (Mon, 24 Dec 2007) | 6 lines restrict reference counting code to isinstance(sock, _nonblocking_api_mixin) instead not isinstance(sock, _closedsocket). allows urllib2's usage of _fileobject to wrap a non socket object fixes #1850722 thanks Daniel Menezes ........ r3865 | pjenvey | 2007-12-24 20:32:59 -0800 (Mon, 24 Dec 2007) | 5 lines fix test_tarfile failing only in the regrtest: o always use the tempdir, even when testtar is a relative path (it is when ran via the regrtest) o fix the tarname() path, it was including unneeded subdirs that broke os.mkdir ........ r3867 | pjenvey | 2007-12-25 16:48:19 -0800 (Tue, 25 Dec 2007) | 4 lines add the python.executable registry option for specifying the path to sys.executable. sys.executable defaults to None if python.executable is invalid or undefined ........ r3876 | pjenvey | 2007-12-27 15:51:54 -0800 (Thu, 27 Dec 2007) | 3 lines add getpass for distutils. it requires a small change, so pull it from CPython 2.5.1 ........ r3877 | pjenvey | 2007-12-27 16:23:34 -0800 (Thu, 27 Dec 2007) | 4 lines _raw_input must flush the stream after printing the password prompt; stdin.readline() doesn't flush it for us with py3k style file objects (py3k also shares this bug: http://bugs.python.org/issue1703 ) ........ r3878 | pjenvey | 2007-12-27 16:25:12 -0800 (Thu, 27 Dec 2007) | 1 line almost forgot to label as from CPython 2.5.1 ........ r3880 | cgroves | 2007-12-27 18:51:45 -0800 (Thu, 27 Dec 2007) | 1 line Break the tests apart into separate assert calls for each condition so different failures can be distinguished ........ r3882 | pjenvey | 2007-12-28 16:06:25 -0800 (Fri, 28 Dec 2007) | 3 lines need to pass the real socket (_nonblocking_api_mixin) to ssl now that we're wrapping it, just like CPython does ........ r3886 | pjenvey | 2007-12-28 16:35:37 -0800 (Fri, 28 Dec 2007) | 1 line include a site-packages directory for installation via distutils ........ r3887 | pjenvey | 2007-12-28 16:51:48 -0800 (Fri, 28 Dec 2007) | 1 line include distutils. the following distutils modules will need jython modifications ........ r3888 | pjenvey | 2007-12-28 17:27:22 -0800 (Fri, 28 Dec 2007) | 11 lines jython distutils changes: o map default archive format and directory layout for os.name == 'java'. use $base/Scripts as the bin directory (like the os2 and mac); maybe package managers can patch this value to a more appropriate path (like $base/bin on unix) o compile byte code to $py.class when sys.platform.startswith('java') -- which is preferred over os.name == 'java' here for the rare case os.name is changed (for use with jnios or something similar) o add our own spawn function using os.system o avoid os.chmod when it's not present ........ r3889 | pjenvey | 2007-12-28 17:27:47 -0800 (Fri, 28 Dec 2007) | 1 line sync a little more with the original now that we have distutils ........ r3891 | pjenvey | 2007-12-28 18:01:58 -0800 (Fri, 28 Dec 2007) | 1 line changelog r3885 (r3863 merge) ........ r3893 | pjenvey | 2007-12-28 20:32:20 -0800 (Fri, 28 Dec 2007) | 1 line use the recursive wildcard ........ r3894 | pjenvey | 2007-12-28 21:02:39 -0800 (Fri, 28 Dec 2007) | 3 lines lock imports with a ReentrantLock (instead of a synchronized method) and expose the lock via the imp module. fixes test_threaded_import ........ r3897 | cgroves | 2007-12-29 17:50:28 -0800 (Sat, 29 Dec 2007) | 1 line Pull over the switch from svn.tag to svn.main.dir from branches/Release_2_2maint ........ Modified Paths: -------------- branches/exposed_annotation/CPythonLib.includes branches/exposed_annotation/Lib/socket.py branches/exposed_annotation/Lib/test/regrtest.py branches/exposed_annotation/Lib/test/test_dict2java.py branches/exposed_annotation/Lib/test/test_importhooks.py branches/exposed_annotation/Lib/test/test_socket.py branches/exposed_annotation/Lib/test/test_sys.py branches/exposed_annotation/Lib/test/test_tarfile.py branches/exposed_annotation/NEWS branches/exposed_annotation/build.xml branches/exposed_annotation/src/org/python/core/PySystemState.java branches/exposed_annotation/src/org/python/core/imp.java branches/exposed_annotation/src/org/python/modules/imp.java Added Paths: ----------- branches/exposed_annotation/Lib/distutils/ branches/exposed_annotation/Lib/distutils/command/ branches/exposed_annotation/Lib/distutils/command/bdist.py branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py branches/exposed_annotation/Lib/distutils/command/install.py branches/exposed_annotation/Lib/distutils/command/sdist.py branches/exposed_annotation/Lib/distutils/file_util.py branches/exposed_annotation/Lib/distutils/spawn.py branches/exposed_annotation/Lib/distutils/sysconfig.py branches/exposed_annotation/Lib/distutils/util.py branches/exposed_annotation/Lib/getpass.py Removed Paths: ------------- branches/exposed_annotation/Lib/distutils/command/ branches/exposed_annotation/Lib/distutils/command/bdist.py branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py branches/exposed_annotation/Lib/distutils/command/install.py branches/exposed_annotation/Lib/distutils/command/sdist.py branches/exposed_annotation/Lib/distutils/file_util.py branches/exposed_annotation/Lib/distutils/spawn.py branches/exposed_annotation/Lib/distutils/sysconfig.py branches/exposed_annotation/Lib/distutils/util.py Property Changed: ---------------- branches/exposed_annotation/ Property changes on: branches/exposed_annotation ___________________________________________________________________ Name: svnmerge-integrated - /trunk/jython:1-3857 + /trunk/jython:1-3897 Modified: branches/exposed_annotation/CPythonLib.includes =================================================================== --- branches/exposed_annotation/CPythonLib.includes 2007-12-30 01:50:28 UTC (rev 3897) +++ branches/exposed_annotation/CPythonLib.includes 2007-12-30 02:04:55 UTC (rev 3898) @@ -2,6 +2,7 @@ # used as fileset in build.xml (target copy-full) # Lib directories, in alphabetical order: +distutils/** email/** encodings/** logging/* @@ -100,6 +101,7 @@ shutil.py SimpleHTTPServer.py SimpleXMLRPCServer.py +site-packages/README smtplib.py sndhdr.py SocketServer.py Copied: branches/exposed_annotation/Lib/distutils (from rev 3897, trunk/jython/Lib/distutils) Copied: branches/exposed_annotation/Lib/distutils/command (from rev 3897, trunk/jython/Lib/distutils/command) Deleted: branches/exposed_annotation/Lib/distutils/command/bdist.py =================================================================== --- trunk/jython/Lib/distutils/command/bdist.py 2007-12-30 01:50:28 UTC (rev 3897) +++ branches/exposed_annotation/Lib/distutils/command/bdist.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -1,151 +0,0 @@ -"""distutils.command.bdist - -Implements the Distutils 'bdist' command (create a built [binary] -distribution).""" - -# This module should be kept compatible with Python 1.5.2. - -__revision__ = "$Id: bdist.py 29762 2002-11-19 13:12:28Z akuchling $" - -import os, string -from types import * -from distutils.core import Command -from distutils.errors import * -from distutils.util import get_platform - - -def show_formats (): - """Print list of available formats (arguments to "--format" option). - """ - from distutils.fancy_getopt import FancyGetopt - formats=[] - for format in bdist.format_commands: - formats.append(("formats=" + format, None, - bdist.format_command[format][1])) - pretty_printer = FancyGetopt(formats) - pretty_printer.print_help("List of available distribution formats:") - - -class bdist (Command): - - description = "create a built (binary) distribution" - - user_options = [('bdist-base=', 'b', - "temporary directory for creating built distributions"), - ('plat-name=', 'p', - "platform name to embed in generated filenames " - "(default: %s)" % get_platform()), - ('formats=', None, - "formats for distribution (comma-separated list)"), - ('dist-dir=', 'd', - "directory to put final built distributions in " - "[default: dist]"), - ('skip-build', None, - "skip rebuilding everything (for testing/debugging)"), - ] - - boolean_options = ['skip-build'] - - help_options = [ - ('help-formats', None, - "lists available distribution formats", show_formats), - ] - - # The following commands do not take a format option from bdist - no_format_option = ('bdist_rpm', - #'bdist_sdux', 'bdist_pkgtool' - ) - - # This won't do in reality: will need to distinguish RPM-ish Linux, - # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS. - default_format = { 'posix': 'gztar', - 'java': 'gztar', - 'nt': 'zip', - 'os2': 'zip', } - - # Establish the preferred order (for the --help-formats option). - format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', - 'wininst', 'zip', - #'pkgtool', 'sdux' - ] - - # And the real information. - format_command = { 'rpm': ('bdist_rpm', "RPM distribution"), - 'zip': ('bdist_dumb', "ZIP file"), - 'gztar': ('bdist_dumb', "gzip'ed tar file"), - 'bztar': ('bdist_dumb', "bzip2'ed tar file"), - 'ztar': ('bdist_dumb', "compressed tar file"), - 'tar': ('bdist_dumb', "tar file"), - 'wininst': ('bdist_wininst', - "Windows executable installer"), - 'zip': ('bdist_dumb', "ZIP file"), - #'pkgtool': ('bdist_pkgtool', - # "Solaris pkgtool distribution"), - #'sdux': ('bdist_sdux', "HP-UX swinstall depot"), - } - - - def initialize_options (self): - self.bdist_base = None - self.plat_name = None - self.formats = None - self.dist_dir = None - self.skip_build = 0 - - # initialize_options() - - - def finalize_options (self): - # have to finalize 'plat_name' before 'bdist_base' - if self.plat_name is None: - self.plat_name = get_platform() - - # 'bdist_base' -- parent of per-built-distribution-format - # temporary directories (eg. we'll probably have - # "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.) - if self.bdist_base is None: - build_base = self.get_finalized_command('build').build_base - self.bdist_base = os.path.join(build_base, - 'bdist.' + self.plat_name) - - self.ensure_string_list('formats') - if self.formats is None: - try: - self.formats = [self.default_format[os.name]] - except KeyError: - raise DistutilsPlatformError, \ - "don't know how to create built distributions " + \ - "on platform %s" % os.name - - if self.dist_dir is None: - self.dist_dir = "dist" - - # finalize_options() - - - def run (self): - - # Figure out which sub-commands we need to run. - commands = [] - for format in self.formats: - try: - commands.append(self.format_command[format][0]) - except KeyError: - raise DistutilsOptionError, "invalid format '%s'" % format - - # Reinitialize and run each command. - for i in range(len(self.formats)): - cmd_name = commands[i] - sub_cmd = self.reinitialize_command(cmd_name) - if cmd_name not in self.no_format_option: - sub_cmd.format = self.formats[i] - - # If we're going to need to run this command again, tell it to - # keep its temporary files around so subsequent runs go faster. - if cmd_name in commands[i+1:]: - sub_cmd.keep_temp = 1 - self.run_command(cmd_name) - - # run() - -# class bdist Copied: branches/exposed_annotation/Lib/distutils/command/bdist.py (from rev 3897, trunk/jython/Lib/distutils/command/bdist.py) =================================================================== --- branches/exposed_annotation/Lib/distutils/command/bdist.py (rev 0) +++ branches/exposed_annotation/Lib/distutils/command/bdist.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -0,0 +1,151 @@ +"""distutils.command.bdist + +Implements the Distutils 'bdist' command (create a built [binary] +distribution).""" + +# This module should be kept compatible with Python 1.5.2. + +__revision__ = "$Id: bdist.py 29762 2002-11-19 13:12:28Z akuchling $" + +import os, string +from types import * +from distutils.core import Command +from distutils.errors import * +from distutils.util import get_platform + + +def show_formats (): + """Print list of available formats (arguments to "--format" option). + """ + from distutils.fancy_getopt import FancyGetopt + formats=[] + for format in bdist.format_commands: + formats.append(("formats=" + format, None, + bdist.format_command[format][1])) + pretty_printer = FancyGetopt(formats) + pretty_printer.print_help("List of available distribution formats:") + + +class bdist (Command): + + description = "create a built (binary) distribution" + + user_options = [('bdist-base=', 'b', + "temporary directory for creating built distributions"), + ('plat-name=', 'p', + "platform name to embed in generated filenames " + "(default: %s)" % get_platform()), + ('formats=', None, + "formats for distribution (comma-separated list)"), + ('dist-dir=', 'd', + "directory to put final built distributions in " + "[default: dist]"), + ('skip-build', None, + "skip rebuilding everything (for testing/debugging)"), + ] + + boolean_options = ['skip-build'] + + help_options = [ + ('help-formats', None, + "lists available distribution formats", show_formats), + ] + + # The following commands do not take a format option from bdist + no_format_option = ('bdist_rpm', + #'bdist_sdux', 'bdist_pkgtool' + ) + + # This won't do in reality: will need to distinguish RPM-ish Linux, + # Debian-ish Linux, Solaris, FreeBSD, ..., Windows, Mac OS. + default_format = { 'posix': 'gztar', + 'java': 'gztar', + 'nt': 'zip', + 'os2': 'zip', } + + # Establish the preferred order (for the --help-formats option). + format_commands = ['rpm', 'gztar', 'bztar', 'ztar', 'tar', + 'wininst', 'zip', + #'pkgtool', 'sdux' + ] + + # And the real information. + format_command = { 'rpm': ('bdist_rpm', "RPM distribution"), + 'zip': ('bdist_dumb', "ZIP file"), + 'gztar': ('bdist_dumb', "gzip'ed tar file"), + 'bztar': ('bdist_dumb', "bzip2'ed tar file"), + 'ztar': ('bdist_dumb', "compressed tar file"), + 'tar': ('bdist_dumb', "tar file"), + 'wininst': ('bdist_wininst', + "Windows executable installer"), + 'zip': ('bdist_dumb', "ZIP file"), + #'pkgtool': ('bdist_pkgtool', + # "Solaris pkgtool distribution"), + #'sdux': ('bdist_sdux', "HP-UX swinstall depot"), + } + + + def initialize_options (self): + self.bdist_base = None + self.plat_name = None + self.formats = None + self.dist_dir = None + self.skip_build = 0 + + # initialize_options() + + + def finalize_options (self): + # have to finalize 'plat_name' before 'bdist_base' + if self.plat_name is None: + self.plat_name = get_platform() + + # 'bdist_base' -- parent of per-built-distribution-format + # temporary directories (eg. we'll probably have + # "build/bdist.<plat>/dumb", "build/bdist.<plat>/rpm", etc.) + if self.bdist_base is None: + build_base = self.get_finalized_command('build').build_base + self.bdist_base = os.path.join(build_base, + 'bdist.' + self.plat_name) + + self.ensure_string_list('formats') + if self.formats is None: + try: + self.formats = [self.default_format[os.name]] + except KeyError: + raise DistutilsPlatformError, \ + "don't know how to create built distributions " + \ + "on platform %s" % os.name + + if self.dist_dir is None: + self.dist_dir = "dist" + + # finalize_options() + + + def run (self): + + # Figure out which sub-commands we need to run. + commands = [] + for format in self.formats: + try: + commands.append(self.format_command[format][0]) + except KeyError: + raise DistutilsOptionError, "invalid format '%s'" % format + + # Reinitialize and run each command. + for i in range(len(self.formats)): + cmd_name = commands[i] + sub_cmd = self.reinitialize_command(cmd_name) + if cmd_name not in self.no_format_option: + sub_cmd.format = self.formats[i] + + # If we're going to need to run this command again, tell it to + # keep its temporary files around so subsequent runs go faster. + if cmd_name in commands[i+1:]: + sub_cmd.keep_temp = 1 + self.run_command(cmd_name) + + # run() + +# class bdist Deleted: branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py =================================================================== --- trunk/jython/Lib/distutils/command/bdist_dumb.py 2007-12-30 01:50:28 UTC (rev 3897) +++ branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -1,129 +0,0 @@ -"""distutils.command.bdist_dumb - -Implements the Distutils 'bdist_dumb' command (create a "dumb" built -distribution -- i.e., just an archive to be unpacked under $prefix or -$exec_prefix).""" - -# This module should be kept compatible with Python 1.5.2. - -__revision__ = "$Id: bdist_dumb.py 29901 2002-11-26 17:45:19Z akuchling $" - -import os -from distutils.core import Command -from distutils.util import get_platform -from distutils.dir_util import create_tree, remove_tree, ensure_relative -from distutils.errors import * -from distutils import log - -class bdist_dumb (Command): - - description = "create a \"dumb\" built distribution" - - user_options = [('bdist-dir=', 'd', - "temporary directory for creating the distribution"), - ('plat-name=', 'p', - "platform name to embed in generated filenames " - "(default: %s)" % get_platform()), - ('format=', 'f', - "archive format to create (tar, ztar, gztar, zip)"), - ('keep-temp', 'k', - "keep the pseudo-installation tree around after " + - "creating the distribution archive"), - ('dist-dir=', 'd', - "directory to put final built distributions in"), - ('skip-build', None, - "skip rebuilding everything (for testing/debugging)"), - ('relative', None, - "build the archive using relative paths" - "(default: false)"), - ] - - boolean_options = ['keep-temp', 'skip-build', 'relative'] - - default_format = { 'posix': 'gztar', - 'java': 'gztar', - 'nt': 'zip', - 'os2': 'zip' } - - - def initialize_options (self): - self.bdist_dir = None - self.plat_name = None - self.format = None - self.keep_temp = 0 - self.dist_dir = None - self.skip_build = 0 - self.relative = 0 - - # initialize_options() - - - def finalize_options (self): - - if self.bdist_dir is None: - bdist_base = self.get_finalized_command('bdist').bdist_base - self.bdist_dir = os.path.join(bdist_base, 'dumb') - - if self.format is None: - try: - self.format = self.default_format[os.name] - except KeyError: - raise DistutilsPlatformError, \ - ("don't know how to create dumb built distributions " + - "on platform %s") % os.name - - self.set_undefined_options('bdist', - ('dist_dir', 'dist_dir'), - ('plat_name', 'plat_name')) - - # finalize_options() - - - def run (self): - - if not self.skip_build: - self.run_command('build') - - install = self.reinitialize_command('install', reinit_subcommands=1) - install.root = self.bdist_dir - install.skip_build = self.skip_build - install.warn_dir = 0 - - log.info("installing to %s" % self.bdist_dir) - self.run_command('install') - - # And make an archive relative to the root of the - # pseudo-installation tree. - archive_basename = "%s.%s" % (self.distribution.get_fullname(), - self.plat_name) - - # OS/2 objects to any ":" characters in a filename (such as when - # a timestamp is used in a version) so change them to hyphens. - if os.name == "os2": - archive_basename = archive_basename.replace(":", "-") - - pseudoinstall_root = os.path.join(self.dist_dir, archive_basename) - if not self.relative: - archive_root = self.bdist_dir - else: - if (self.distribution.has_ext_modules() and - (install.install_base != install.install_platbase)): - raise DistutilsPlatformError, \ - ("can't make a dumb built distribution where " - "base and platbase are different (%s, %s)" - % (repr(install.install_base), - repr(install.install_platbase))) - else: - archive_root = os.path.join(self.bdist_dir, - ensure_relative(install.install_base)) - - # Make the archive - self.make_archive(pseudoinstall_root, - self.format, root_dir=archive_root) - - if not self.keep_temp: - remove_tree(self.bdist_dir, dry_run=self.dry_run) - - # run() - -# class bdist_dumb Copied: branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py (from rev 3897, trunk/jython/Lib/distutils/command/bdist_dumb.py) =================================================================== --- branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py (rev 0) +++ branches/exposed_annotation/Lib/distutils/command/bdist_dumb.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -0,0 +1,129 @@ +"""distutils.command.bdist_dumb + +Implements the Distutils 'bdist_dumb' command (create a "dumb" built +distribution -- i.e., just an archive to be unpacked under $prefix or +$exec_prefix).""" + +# This module should be kept compatible with Python 1.5.2. + +__revision__ = "$Id: bdist_dumb.py 29901 2002-11-26 17:45:19Z akuchling $" + +import os +from distutils.core import Command +from distutils.util import get_platform +from distutils.dir_util import create_tree, remove_tree, ensure_relative +from distutils.errors import * +from distutils import log + +class bdist_dumb (Command): + + description = "create a \"dumb\" built distribution" + + user_options = [('bdist-dir=', 'd', + "temporary directory for creating the distribution"), + ('plat-name=', 'p', + "platform name to embed in generated filenames " + "(default: %s)" % get_platform()), + ('format=', 'f', + "archive format to create (tar, ztar, gztar, zip)"), + ('keep-temp', 'k', + "keep the pseudo-installation tree around after " + + "creating the distribution archive"), + ('dist-dir=', 'd', + "directory to put final built distributions in"), + ('skip-build', None, + "skip rebuilding everything (for testing/debugging)"), + ('relative', None, + "build the archive using relative paths" + "(default: false)"), + ] + + boolean_options = ['keep-temp', 'skip-build', 'relative'] + + default_format = { 'posix': 'gztar', + 'java': 'gztar', + 'nt': 'zip', + 'os2': 'zip' } + + + def initialize_options (self): + self.bdist_dir = None + self.plat_name = None + self.format = None + self.keep_temp = 0 + self.dist_dir = None + self.skip_build = 0 + self.relative = 0 + + # initialize_options() + + + def finalize_options (self): + + if self.bdist_dir is None: + bdist_base = self.get_finalized_command('bdist').bdist_base + self.bdist_dir = os.path.join(bdist_base, 'dumb') + + if self.format is None: + try: + self.format = self.default_format[os.name] + except KeyError: + raise DistutilsPlatformError, \ + ("don't know how to create dumb built distributions " + + "on platform %s") % os.name + + self.set_undefined_options('bdist', + ('dist_dir', 'dist_dir'), + ('plat_name', 'plat_name')) + + # finalize_options() + + + def run (self): + + if not self.skip_build: + self.run_command('build') + + install = self.reinitialize_command('install', reinit_subcommands=1) + install.root = self.bdist_dir + install.skip_build = self.skip_build + install.warn_dir = 0 + + log.info("installing to %s" % self.bdist_dir) + self.run_command('install') + + # And make an archive relative to the root of the + # pseudo-installation tree. + archive_basename = "%s.%s" % (self.distribution.get_fullname(), + self.plat_name) + + # OS/2 objects to any ":" characters in a filename (such as when + # a timestamp is used in a version) so change them to hyphens. + if os.name == "os2": + archive_basename = archive_basename.replace(":", "-") + + pseudoinstall_root = os.path.join(self.dist_dir, archive_basename) + if not self.relative: + archive_root = self.bdist_dir + else: + if (self.distribution.has_ext_modules() and + (install.install_base != install.install_platbase)): + raise DistutilsPlatformError, \ + ("can't make a dumb built distribution where " + "base and platbase are different (%s, %s)" + % (repr(install.install_base), + repr(install.install_platbase))) + else: + archive_root = os.path.join(self.bdist_dir, + ensure_relative(install.install_base)) + + # Make the archive + self.make_archive(pseudoinstall_root, + self.format, root_dir=archive_root) + + if not self.keep_temp: + remove_tree(self.bdist_dir, dry_run=self.dry_run) + + # run() + +# class bdist_dumb Deleted: branches/exposed_annotation/Lib/distutils/command/install.py =================================================================== --- trunk/jython/Lib/distutils/command/install.py 2007-12-30 01:50:28 UTC (rev 3897) +++ branches/exposed_annotation/Lib/distutils/command/install.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -1,613 +0,0 @@ -"""distutils.command.install - -Implements the Distutils 'install' command.""" - -from distutils import log - -# This module should be kept compatible with Python 1.5.2. - -__revision__ = "$Id: install.py 38351 2005-01-20 19:16:27Z theller $" - -import sys, os, string -from types import * -from distutils.core import Command -from distutils.debug import DEBUG -from distutils.sysconfig import get_config_vars -from distutils.errors import DistutilsPlatformError -from distutils.file_util import write_file -from distutils.util import convert_path, subst_vars, change_root -from distutils.errors import DistutilsOptionError -from glob import glob - -if sys.version < "2.2": - WINDOWS_SCHEME = { - 'purelib': '$base', - 'platlib': '$base', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - } -else: - WINDOWS_SCHEME = { - 'purelib': '$base/Lib/site-packages', - 'platlib': '$base/Lib/site-packages', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - } - -INSTALL_SCHEMES = { - 'unix_prefix': { - 'purelib': '$base/lib/python$py_version_short/site-packages', - 'platlib': '$platbase/lib/python$py_version_short/site-packages', - 'headers': '$base/include/python$py_version_short/$dist_name', - 'scripts': '$base/bin', - 'data' : '$base', - }, - 'unix_home': { - 'purelib': '$base/lib/python', - 'platlib': '$base/lib/python', - 'headers': '$base/include/python/$dist_name', - 'scripts': '$base/bin', - 'data' : '$base', - }, - 'nt': WINDOWS_SCHEME, - 'mac': { - 'purelib': '$base/Lib/site-packages', - 'platlib': '$base/Lib/site-packages', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - }, - 'os2': { - 'purelib': '$base/Lib/site-packages', - 'platlib': '$base/Lib/site-packages', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - }, - 'java': { - 'purelib': '$base/Lib/site-packages', - 'platlib': '$base/Lib/site-packages', - 'headers': '$base/Include/$dist_name', - 'scripts': '$base/Scripts', - 'data' : '$base', - } - } - -# The keys to an installation scheme; if any new types of files are to be -# installed, be sure to add an entry to every installation scheme above, -# and to SCHEME_KEYS here. -SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') - - -class install (Command): - - description = "install everything from build directory" - - user_options = [ - # Select installation scheme and set base director(y|ies) - ('prefix=', None, - "installation prefix"), - ('exec-prefix=', None, - "(Unix only) prefix for platform-specific files"), - ('home=', None, - "(Unix only) home directory to install under"), - - # Or, just set the base director(y|ies) - ('install-base=', None, - "base installation directory (instead of --prefix or --home)"), - ('install-platbase=', None, - "base installation directory for platform-specific files " + - "(instead of --exec-prefix or --home)"), - ('root=', None, - "install everything relative to this alternate root directory"), - - # Or, explicitly set the installation scheme - ('install-purelib=', None, - "installation directory for pure Python module distributions"), - ('install-platlib=', None, - "installation directory for non-pure module distributions"), - ('install-lib=', None, - "installation directory for all module distributions " + - "(overrides --install-purelib and --install-platlib)"), - - ('install-headers=', None, - "installation directory for C/C++ headers"), - ('install-scripts=', None, - "installation directory for Python scripts"), - ('install-data=', None, - "installation directory for data files"), - - # Byte-compilation options -- see install_lib.py for details, as - # these are duplicated from there (but only install_lib does - # anything with them). - ('compile', 'c', "compile .py to .pyc [default]"), - ('no-compile', None, "don't compile .py files"), - ('optimize=', 'O', - "also compile with optimization: -O1 for \"python -O\", " - "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), - - # Miscellaneous control options - ('force', 'f', - "force installation (overwrite any existing files)"), - ('skip-build', None, - "skip rebuilding everything (for testing/debugging)"), - - # Where to install documentation (eventually!) - #('doc-format=', None, "format of documentation to generate"), - #('install-man=', None, "directory for Unix man pages"), - #('install-html=', None, "directory for HTML documentation"), - #('install-info=', None, "directory for GNU info files"), - - ('record=', None, - "filename in which to record list of installed files"), - ] - - boolean_options = ['compile', 'force', 'skip-build'] - negative_opt = {'no-compile' : 'compile'} - - - def initialize_options (self): - - # High-level options: these select both an installation base - # and scheme. - self.prefix = None - self.exec_prefix = None - self.home = None - - # These select only the installation base; it's up to the user to - # specify the installation scheme (currently, that means supplying - # the --install-{platlib,purelib,scripts,data} options). - self.install_base = None - self.install_platbase = None - self.root = None - - # These options are the actual installation directories; if not - # supplied by the user, they are filled in using the installation - # scheme implied by prefix/exec-prefix/home and the contents of - # that installation scheme. - self.install_purelib = None # for pure module distributions - self.install_platlib = None # non-pure (dists w/ extensions) - self.install_headers = None # for C/C++ headers - self.install_lib = None # set to either purelib or platlib - self.install_scripts = None - self.install_data = None - - self.compile = None - self.optimize = None - - # These two are for putting non-packagized distributions into their - # own directory and creating a .pth file if it makes sense. - # 'extra_path' comes from the setup file; 'install_path_file' can - # be turned off if it makes no sense to install a .pth file. (But - # better to install it uselessly than to guess wrong and not - # install it when it's necessary and would be used!) Currently, - # 'install_path_file' is always true unless some outsider meddles - # with it. - self.extra_path = None - self.install_path_file = 1 - - # 'force' forces installation, even if target files are not - # out-of-date. 'skip_build' skips running the "build" command, - # handy if you know it's not necessary. 'warn_dir' (which is *not* - # a user option, it's just there so the bdist_* commands can turn - # it off) determines whether we warn about installing to a - # directory not in sys.path. - self.force = 0 - self.skip_build = 0 - self.warn_dir = 1 - - # These are only here as a conduit from the 'build' command to the - # 'install_*' commands that do the real work. ('build_base' isn't - # actually used anywhere, but it might be useful in future.) They - # are not user options, because if the user told the install - # command where the build directory is, that wouldn't affect the - # build command. - self.build_base = None - self.build_lib = None - - # Not defined yet because we don't know anything about - # documentation yet. - #self.install_man = None - #self.install_html = None - #self.install_info = None - - self.record = None - - - # -- Option finalizing methods ------------------------------------- - # (This is rather more involved than for most commands, - # because this is where the policy for installing third- - # party Python modules on various platforms given a wide - # array of user input is decided. Yes, it's quite complex!) - - def finalize_options (self): - - # This method (and its pliant slaves, like 'finalize_unix()', - # 'finalize_other()', and 'select_scheme()') is where the default - # installation directories for modules, extension modules, and - # anything else we care to install from a Python module - # distribution. Thus, this code makes a pretty important policy - # statement about how third-party stuff is added to a Python - # installation! Note that the actual work of installation is done - # by the relatively simple 'install_*' commands; they just take - # their orders from the installation directory options determined - # here. - - # Check for errors/inconsistencies in the options; first, stuff - # that's wrong on any platform. - - if ((self.prefix or self.exec_prefix or self.home) and - (self.install_base or self.install_platbase)): - raise DistutilsOptionError, \ - ("must supply either prefix/exec-prefix/home or " + - "install-base/install-platbase -- not both") - - # Next, stuff that's wrong (or dubious) only on certain platforms. - if os.name == 'posix': - if self.home and (self.prefix or self.exec_prefix): - raise DistutilsOptionError, \ - ("must supply either home or prefix/exec-prefix -- " + - "not both") - else: - if self.exec_prefix: - self.warn("exec-prefix option ignored on this platform") - self.exec_prefix = None - if self.home: - self.warn("home option ignored on this platform") - self.home = None - - # Now the interesting logic -- so interesting that we farm it out - # to other methods. The goal of these methods is to set the final - # values for the install_{lib,scripts,data,...} options, using as - # input a heady brew of prefix, exec_prefix, home, install_base, - # install_platbase, user-supplied versions of - # install_{purelib,platlib,lib,scripts,data,...}, and the - # INSTALL_SCHEME dictionary above. Phew! - - self.dump_dirs("pre-finalize_{unix,other}") - - if os.name == 'posix': - self.finalize_unix() - else: - self.finalize_other() - - self.dump_dirs("post-finalize_{unix,other}()") - - # Expand configuration variables, tilde, etc. in self.install_base - # and self.install_platbase -- that way, we can use $base or - # $platbase in the other installation directories and not worry - # about needing recursive variable expansion (shudder). - - py_version = (string.split(sys.version))[0] - (prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix') - self.config_vars = {'dist_name': self.distribution.get_name(), - 'dist_version': self.distribution.get_version(), - 'dist_fullname': self.distribution.get_fullname(), - 'py_version': py_version, - 'py_version_short': py_version[0:3], - 'sys_prefix': prefix, - 'prefix': prefix, - 'sys_exec_prefix': exec_prefix, - 'exec_prefix': exec_prefix, - } - self.expand_basedirs() - - self.dump_dirs("post-expand_basedirs()") - - # Now define config vars for the base directories so we can expand - # everything else. - self.config_vars['base'] = self.install_base - self.config_vars['platbase'] = self.install_platbase - - if DEBUG: - from pprint import pprint - print "config vars:" - pprint(self.config_vars) - - # Expand "~" and configuration variables in the installation - # directories. - self.expand_dirs() - - self.dump_dirs("post-expand_dirs()") - - # Pick the actual directory to install all modules to: either - # install_purelib or install_platlib, depending on whether this - # module distribution is pure or not. Of course, if the user - # already specified install_lib, use their selection. - if self.install_lib is None: - if self.distribution.ext_modules: # has extensions: non-pure - self.install_lib = self.install_platlib - else: - self.install_lib = self.install_purelib - - - # Convert directories from Unix /-separated syntax to the local - # convention. - self.convert_paths('lib', 'purelib', 'platlib', - 'scripts', 'data', 'headers') - - # Well, we're not actually fully completely finalized yet: we still - # have to deal with 'extra_path', which is the hack for allowing - # non-packagized module distributions (hello, Numerical Python!) to - # get their own directories. - self.handle_extra_path() - self.install_libbase = self.install_lib # needed for .pth file - self.install_lib = os.path.join(self.install_lib, self.extra_dirs) - - # If a new root directory was supplied, make all the installation - # dirs relative to it. - if self.root is not None: - self.change_roots('libbase', 'lib', 'purelib', 'platlib', - 'scripts', 'data', 'headers') - - self.dump_dirs("after prepending root") - - # Find out the build directories, ie. where to install from. - self.set_undefined_options('build', - ('build_base', 'build_base'), - ('build_lib', 'build_lib')) - - # Punt on doc directories for now -- after all, we're punting on - # documentation completely! - - # finalize_options () - - - def dump_dirs (self, msg): - if DEBUG: - from distutils.fancy_getopt import longopt_xlate - print msg + ":" - for opt in self.user_options: - opt_name = opt[0] - if opt_name[-1] == "=": - opt_name = opt_name[0:-1] - if self.negative_opt.has_key(opt_name): - opt_name = string.translate(self.negative_opt[opt_name], - longopt_xlate) - val = not getattr(self, opt_name) - else: - opt_name = string.translate(opt_name, longopt_xlate) - val = getattr(self, opt_name) - print " %s: %s" % (opt_name, val) - - - def finalize_unix (self): - - if self.install_base is not None or self.install_platbase is not None: - if ((self.install_lib is None and - self.install_purelib is None and - self.install_platlib is None) or - self.install_headers is None or - self.install_scripts is None or - self.install_data is None): - raise DistutilsOptionError, \ - ("install-base or install-platbase supplied, but " - "installation scheme is incomplete") - return - - if self.home is not None: - self.install_base = self.install_platbase = self.home - self.select_scheme("unix_home") - else: - if self.prefix is None: - if self.exec_prefix is not None: - raise DistutilsOptionError, \ - "must not supply exec-prefix without prefix" - - self.prefix = os.path.normpath(sys.prefix) - self.exec_prefix = os.path.normpath(sys.exec_prefix) - - else: - if self.exec_prefix is None: - self.exec_prefix = self.prefix - - self.install_base = self.prefix - self.install_platbase = self.exec_prefix - self.select_scheme("unix_prefix") - - # finalize_unix () - - - def finalize_other (self): # Windows and Mac OS for now - - if self.prefix is None: - self.prefix = os.path.normpath(sys.prefix) - - self.install_base = self.install_platbase = self.prefix - try: - self.select_scheme(os.name) - except KeyError: - raise DistutilsPlatformError, \ - "I don't know how to install stuff on '%s'" % os.name - - # finalize_other () - - - def select_scheme (self, name): - # it's the caller's problem if they supply a bad name! - scheme = INSTALL_SCHEMES[name] - for key in SCHEME_KEYS: - attrname = 'install_' + key - if getattr(self, attrname) is None: - setattr(self, attrname, scheme[key]) - - - def _expand_attrs (self, attrs): - for attr in attrs: - val = getattr(self, attr) - if val is not None: - if os.name == 'posix': - val = os.path.expanduser(val) - val = subst_vars(val, self.config_vars) - setattr(self, attr, val) - - - def expand_basedirs (self): - self._expand_attrs(['install_base', - 'install_platbase', - 'root']) - - def expand_dirs (self): - self._expand_attrs(['install_purelib', - 'install_platlib', - 'install_lib', - 'install_headers', - 'install_scripts', - 'install_data',]) - - - def convert_paths (self, *names): - for name in names: - attr = "install_" + name - setattr(self, attr, convert_path(getattr(self, attr))) - - - def handle_extra_path (self): - - if self.extra_path is None: - self.extra_path = self.distribution.extra_path - - if self.extra_path is not None: - if type(self.extra_path) is StringType: - self.extra_path = string.split(self.extra_path, ',') - - if len(self.extra_path) == 1: - path_file = extra_dirs = self.extra_path[0] - elif len(self.extra_path) == 2: - (path_file, extra_dirs) = self.extra_path - else: - raise DistutilsOptionError, \ - ("'extra_path' option must be a list, tuple, or " - "comma-separated string with 1 or 2 elements") - - # convert to local form in case Unix notation used (as it - # should be in setup scripts) - extra_dirs = convert_path(extra_dirs) - - else: - path_file = None - extra_dirs = '' - - # XXX should we warn if path_file and not extra_dirs? (in which - # case the path file would be harmless but pointless) - self.path_file = path_file - self.extra_dirs = extra_dirs - - # handle_extra_path () - - - def change_roots (self, *names): - for name in names: - attr = "install_" + name - setattr(self, attr, change_root(self.root, getattr(self, attr))) - - - # -- Command execution methods ------------------------------------- - - def run (self): - - # Obviously have to build before we can install - if not self.skip_build: - self.run_command('build') - - # Run all sub-commands (at least those that need to be run) - for cmd_name in self.get_sub_commands(): - self.run_command(cmd_name) - - if self.path_file: - self.create_path_file() - - # write list of installed files, if requested. - if self.record: - outputs = self.get_outputs() - if self.root: # strip any package prefix - root_len = len(self.root) - for counter in xrange(len(outputs)): - outputs[counter] = outputs[counter][root_len:] - self.execute(write_file, - (self.record, outputs), - "writing list of installed files to '%s'" % - self.record) - - sys_path = map(os.path.normpath, sys.path) - sys_path = map(os.path.normcase, sys_path) - install_lib = os.path.normcase(os.path.normpath(self.install_lib)) - if (self.warn_dir and - not (self.path_file and self.install_path_file) and - install_lib not in sys_path): - log.debug(("modules installed to '%s', which is not in " - "Python's module search path (sys.path) -- " - "you'll have to change the search path yourself"), - self.install_lib) - - # run () - - def create_path_file (self): - filename = os.path.join(self.install_libbase, - self.path_file + ".pth") - if self.install_path_file: - self.execute(write_file, - (filename, [self.extra_dirs]), - "creating %s" % filename) - else: - self.warn("path file '%s' not created" % filename) - - - # -- Reporting methods --------------------------------------------- - - def get_outputs (self): - # Assemble the outputs of all the sub-commands. - outputs = [] - for cmd_name in self.get_sub_commands(): - cmd = self.get_finalized_command(cmd_name) - # Add the contents of cmd.get_outputs(), ensuring - # that outputs doesn't contain duplicate entries - for filename in cmd.get_outputs(): - if filename not in outputs: - outputs.append(filename) - - if self.path_file and self.install_path_file: - outputs.append(os.path.join(self.install_libbase, - self.path_file + ".pth")) - - return outputs - - def get_inputs (self): - # XXX gee, this looks familiar ;-( - inputs = [] - for cmd_name in self.get_sub_commands(): - cmd = self.get_finalized_command(cmd_name) - inputs.extend(cmd.get_inputs()) - - return inputs - - - # -- Predicates for sub-command list ------------------------------- - - def has_lib (self): - """Return true if the current distribution has any Python - modules to install.""" - return (self.distribution.has_pure_modules() or - self.distribution.has_ext_modules()) - - def has_headers (self): - return self.distribution.has_headers() - - def has_scripts (self): - return self.distribution.has_scripts() - - def has_data (self): - return self.distribution.has_data_files() - - - # 'sub_commands': a list of commands this command might have to run to - # get its work done. See cmd.py for more info. - sub_commands = [('install_lib', has_lib), - ('install_headers', has_headers), - ('install_scripts', has_scripts), - ('install_data', has_data), - ] - -# class install Copied: branches/exposed_annotation/Lib/distutils/command/install.py (from rev 3897, trunk/jython/Lib/distutils/command/install.py) =================================================================== --- branches/exposed_annotation/Lib/distutils/command/install.py (rev 0) +++ branches/exposed_annotation/Lib/distutils/command/install.py 2007-12-30 02:04:55 UTC (rev 3898) @@ -0,0 +1,613 @@ +"""distutils.command.install + +Implements the Distutils 'install' command.""" + +from distutils import log + +# This module should be kept compatible with Python 1.5.2. + +__revision__ = "$Id: install.py 38351 2005-01-20 19:16:27Z theller $" + +import sys, os, string +from types import * +from distutils.core import Command +from distutils.debug import DEBUG +from distutils.sysconfig import get_config_vars +from distutils.errors import DistutilsPlatformError +from distutils.file_util import write_file +from distutils.util import convert_path, subst_vars, change_root +from distutils.errors import DistutilsOptionError +from glob import glob + +if sys.version < "2.2": + WINDOWS_SCHEME = { + 'purelib': '$base', + 'platlib': '$base', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } +else: + WINDOWS_SCHEME = { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } + +INSTALL_SCHEMES = { + 'unix_prefix': { + 'purelib': '$base/lib/python$py_version_short/site-packages', + 'platlib': '$platbase/lib/python$py_version_short/site-packages', + 'headers': '$base/include/python$py_version_short/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'unix_home': { + 'purelib': '$base/lib/python', + 'platlib': '$base/lib/python', + 'headers': '$base/include/python/$dist_name', + 'scripts': '$base/bin', + 'data' : '$base', + }, + 'nt': WINDOWS_SCHEME, + 'mac': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'os2': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + }, + 'java': { + 'purelib': '$base/Lib/site-packages', + 'platlib': '$base/Lib/site-packages', + 'headers': '$base/Include/$dist_name', + 'scripts': '$base/Scripts', + 'data' : '$base', + } + } + +# The keys to an installation scheme; if any new types of files are to be +# installed, be sure to add an entry to every installation scheme above, +# and to SCHEME_KEYS here. +SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data') + + +class install (Command): + + description = "install everything from build directory" + + user_options = [ + # Select installation scheme and set base director(y|ies) + ('prefix=', None, + "installation prefix"), + ('exec-prefix=', None, + "(Unix only) prefix for platform-specific files"), + ('home=', None, + "(Unix only) home directory to install under"), + + # Or, just set the base director(y|ies) + ('install-base=', None, + "base installation directory (instead of --prefix or --home)"), + ('install-platbase=', None, + "base installation directory for platform-specific files " + + "(instead of --exec-prefix or --home)"), + ('root=', None, + "install everything relative to this alternate root directory"), + + # Or, explicitly set the installation scheme + ('install-purelib=', None, + "installation directory for pure Python module distributions"), + ('install-platlib=', None, + "installation directory for non-pure module distributions"), + ('install-lib=', None, + "installation directory for all module distributions " + + "(overrides --install-purelib and --install-platlib)"), + + ('install-headers=', None, + "installation directory for C/C++ headers"), + ('install-scripts=', None, + "installation directory for Python scripts"), + ('install-data=', None, + "installation directory for data files"), + + # Byte-compilation options -- see install_lib.py for details, as + # these are duplicated from there (but only install_lib does + # anything with them). + ('compile', 'c', "compile .py to .pyc [default]"), + ('no-compile', None, "don't compile .py files"), + ('optimize=', 'O', + "also compile with optimization: -O1 for \"python -O\", " + "-O2 for \"python -OO\", and -O0 to disable [default: -O0]"), + + # Miscellaneous control options + ('force', 'f', + "force installation (overwrite any existing files)"), + ('skip-build', None, + "skip rebuilding everything (for testing/debugging)"), + + # Where to install documentation (eventually!) + #('doc-format=', None, "format of documentation to generate"), + #('install-man=', None, "directory for Unix man pages"), + #('install-html=', None, "directory for HTML documentation"), + #('install-info=', None, "directory for GNU info files"), + + ('record=', None, + "filename in which to record list of installed files"), + ] + + boolean_options = ['compile', 'force', 'skip-build'] + negative_opt = {'no-compile' : 'compile'} + + + def initialize_options (self): + + # High-level options: these select both an installation base + # and scheme. + self.prefix = None + self.exec_prefix = None + self.home = None + + # These select only the installation base; it's up to the user to + # specify the installation scheme (currently, that means supplying + # the --install-{platlib,purelib,scripts,data} options). + self.install_base = None + self.install_platbase = None + self.root = None + + # These options are the actual installation directories; if not + # supplied by the user, they are filled in using the installation + # scheme implied by prefix/exec-prefix/home and the contents of + # that installation scheme. + self.install_purelib = None # for pure module distributions + self.install_platlib = None # non-pure (dists w/ extensions) + self.install_headers = None # for C/C++ headers + self.install_lib = None # set to either purelib or platlib + self.install_scri... [truncated message content] |