From: <pj...@us...> - 2008-07-14 19:31:40
|
Revision: 4935 http://jython.svn.sourceforge.net/jython/?rev=4935&view=rev Author: pjenvey Date: 2008-07-14 12:31:38 -0700 (Mon, 14 Jul 2008) Log Message: ----------- o re-integrate Jython distutils changes o check for $py.class on Jython instead of pyc in test_build_py Modified Paths: -------------- branches/asm/Lib/distutils/ccompiler.py branches/asm/Lib/distutils/command/bdist.py branches/asm/Lib/distutils/command/bdist_dumb.py branches/asm/Lib/distutils/command/install.py branches/asm/Lib/distutils/command/sdist.py branches/asm/Lib/distutils/file_util.py branches/asm/Lib/distutils/spawn.py branches/asm/Lib/distutils/sysconfig.py branches/asm/Lib/distutils/tests/test_build_py.py branches/asm/Lib/distutils/util.py Modified: branches/asm/Lib/distutils/ccompiler.py =================================================================== --- branches/asm/Lib/distutils/ccompiler.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/ccompiler.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -1059,6 +1059,7 @@ # compiler ('cygwin.*', 'unix'), ('os2emx', 'emx'), + ('java.*', 'jython'), # OS name mappings ('posix', 'unix'), @@ -1107,6 +1108,8 @@ "MetroWerks CodeWarrior"), 'emx': ('emxccompiler', 'EMXCCompiler', "EMX port of GNU C Compiler for OS/2"), + 'jython': ('jythoncompiler', 'JythonCompiler', + "Compiling is not supported on Jython"), } def show_compilers(): Modified: branches/asm/Lib/distutils/command/bdist.py =================================================================== --- branches/asm/Lib/distutils/command/bdist.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/command/bdist.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -59,6 +59,7 @@ # 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', } Modified: branches/asm/Lib/distutils/command/bdist_dumb.py =================================================================== --- branches/asm/Lib/distutils/command/bdist_dumb.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/command/bdist_dumb.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -42,6 +42,7 @@ boolean_options = ['keep-temp', 'skip-build', 'relative'] default_format = { 'posix': 'gztar', + 'java': 'gztar', 'nt': 'zip', 'os2': 'zip' } Modified: branches/asm/Lib/distutils/command/install.py =================================================================== --- branches/asm/Lib/distutils/command/install.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/command/install.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -65,6 +65,13 @@ '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/bin', + 'data' : '$base', } } Modified: branches/asm/Lib/distutils/command/sdist.py =================================================================== --- branches/asm/Lib/distutils/command/sdist.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/command/sdist.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -80,6 +80,7 @@ 'no-prune': 'prune' } default_format = { 'posix': 'gztar', + 'java': 'gztar', 'nt': 'zip' } def initialize_options (self): @@ -376,13 +377,16 @@ """ log.info("reading manifest file '%s'", self.manifest) manifest = open(self.manifest) - while 1: - line = manifest.readline() - if line == '': # end of file - break - if line[-1] == '\n': - line = line[0:-1] - self.filelist.append(line) + try: + while 1: + line = manifest.readline() + if line == '': # end of file + break + if line[-1] == '\n': + line = line[0:-1] + self.filelist.append(line) + finally: + manifest.close() # read_manifest () Modified: branches/asm/Lib/distutils/file_util.py =================================================================== --- branches/asm/Lib/distutils/file_util.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/file_util.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -170,7 +170,7 @@ # before chmod() (at least under NT). if preserve_times: os.utime(dst, (st[ST_ATIME], st[ST_MTIME])) - if preserve_mode: + if preserve_mode and hasattr(os, 'chmod'): os.chmod(dst, S_IMODE(st[ST_MODE])) return (dst, 1) Modified: branches/asm/Lib/distutils/spawn.py =================================================================== --- branches/asm/Lib/distutils/spawn.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/spawn.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -39,6 +39,8 @@ _spawn_nt(cmd, search_path, dry_run=dry_run) elif os.name == 'os2': _spawn_os2(cmd, search_path, dry_run=dry_run) + elif os.name == 'java': + _spawn_java(cmd, search_path, dry_run=dry_run) else: raise DistutilsPlatformError, \ "don't know how to spawn programs on platform '%s'" % os.name @@ -176,6 +178,27 @@ # _spawn_posix () +def _spawn_java(cmd, + search_path=1, + verbose=0, + dry_run=0): + executable = cmd[0] + cmd = ' '.join(_nt_quote_args(cmd)) + log.info(cmd) + if not dry_run: + try: + rc = os.system(cmd) >> 8 + except OSError, exc: + # this seems to happen when the command isn't found + raise DistutilsExecError, \ + "command '%s' failed: %s" % (executable, exc[-1]) + if rc != 0: + # and this reflects the command running but failing + print "command '%s' failed with exit status %d" % (executable, rc) + raise DistutilsExecError, \ + "command '%s' failed with exit status %d" % (executable, rc) + + def find_executable(executable, path=None): """Try to find 'executable' in the directories listed in 'path' (a string listing directories separated by 'os.pathsep'; defaults to Modified: branches/asm/Lib/distutils/sysconfig.py =================================================================== --- branches/asm/Lib/distutils/sysconfig.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/sysconfig.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -73,7 +73,7 @@ return os.path.join(prefix, "Mac", "Include") else: return os.path.join(prefix, "Include") - elif os.name == "os2": + elif os.name == "os2" or os.name == "java": return os.path.join(prefix, "Include") else: raise DistutilsPlatformError( @@ -127,7 +127,7 @@ else: return os.path.join(prefix, "Lib", "site-packages") - elif os.name == "os2": + elif os.name == "os2" or os.name == "java": if standard_lib: return os.path.join(PREFIX, "Lib") else: @@ -476,6 +476,13 @@ _config_vars = g +def _init_jython(): + """Initialize the module as appropriate for Jython""" + # Stub out some values that build_ext expects; they don't matter + # anyway + _init_os2() + + def get_config_vars(*args): """With no arguments, return a dictionary of all configuration variables relevant for the current platform. Generally this includes @@ -488,7 +495,12 @@ """ global _config_vars if _config_vars is None: - func = globals().get("_init_" + os.name) + if sys.platform.startswith('java'): + # Jython might pose as a different os.name, but we always + # want _init_jython regardless + func = _init_jython + else: + func = globals().get("_init_" + os.name) if func: func() else: Modified: branches/asm/Lib/distutils/tests/test_build_py.py =================================================================== --- branches/asm/Lib/distutils/tests/test_build_py.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/tests/test_build_py.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -53,7 +53,10 @@ pkgdest = os.path.join(destination, "pkg") files = os.listdir(pkgdest) self.assert_("__init__.py" in files) - self.assert_("__init__.pyc" in files) + if sys.platform.startswith('java'): + self.assert_("__init__$py.class" in files, files) + else: + self.assert_("__init__.pyc" in files) self.assert_("README.txt" in files) def test_empty_package_dir (self): Modified: branches/asm/Lib/distutils/util.py =================================================================== --- branches/asm/Lib/distutils/util.py 2008-07-14 19:27:40 UTC (rev 4934) +++ branches/asm/Lib/distutils/util.py 2008-07-14 19:31:38 UTC (rev 4935) @@ -155,7 +155,7 @@ Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. """ - if os.name == 'posix': + if os.name == 'posix' or os.name == 'java': if not os.path.isabs(pathname): return os.path.join(new_root, pathname) else: @@ -480,7 +480,10 @@ # Terminology from the py_compile module: # cfile - byte-compiled file # dfile - purported source filename (same as 'file' by default) - cfile = file + (__debug__ and "c" or "o") + if sys.platform.startswith('java'): + cfile = file[:-3] + '$py.class' + else: + cfile = file + (__debug__ and "c" or "o") dfile = file if prefix: if file[:len(prefix)] != prefix: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |