diff options
author | PJ Eby <distutils-sig@python.org> | 2008-01-18 21:51:23 +0000 |
---|---|---|
committer | PJ Eby <distutils-sig@python.org> | 2008-01-18 21:51:23 +0000 |
commit | 7c4938d53774c51b441970e177ce72cc3bdf68ce (patch) | |
tree | d69680614e16597ee20ded8c4e04d3d66fcfd78f | |
parent | ce75692a87b83cef9ea539fc76f4a544b1398b35 (diff) | |
download | external_python_setuptools-7c4938d53774c51b441970e177ce72cc3bdf68ce.tar.gz external_python_setuptools-7c4938d53774c51b441970e177ce72cc3bdf68ce.tar.bz2 external_python_setuptools-7c4938d53774c51b441970e177ce72cc3bdf68ce.zip |
chmod/test cleanups and Jython compatibility (backport from trunk)
--HG--
branch : setuptools-0.6
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4060062
-rwxr-xr-x | EasyInstall.txt | 4 | ||||
-rwxr-xr-x | setuptools.txt | 2 | ||||
-rw-r--r-- | setuptools/command/bdist_egg.py | 43 | ||||
-rwxr-xr-x | setuptools/command/easy_install.py | 44 | ||||
-rwxr-xr-x | setuptools/command/install_scripts.py | 10 | ||||
-rw-r--r-- | setuptools/tests/test_packageindex.py | 6 | ||||
-rw-r--r-- | setuptools/tests/test_resources.py | 20 |
7 files changed, 87 insertions, 42 deletions
diff --git a/EasyInstall.txt b/EasyInstall.txt index 2f6665f2..fc6c1ef3 100755 --- a/EasyInstall.txt +++ b/EasyInstall.txt @@ -1241,6 +1241,10 @@ Release Notes/Change History * Fixed not picking up dependency links from recursive dependencies. + * Only make ``.py``, ``.dll`` and ``.so`` files executable when unpacking eggs + + * Changes for Jython compatibility + 0.6c7 * ``ftp:`` download URLs now work correctly. diff --git a/setuptools.txt b/setuptools.txt index d68e52c6..65986637 100755 --- a/setuptools.txt +++ b/setuptools.txt @@ -2618,6 +2618,8 @@ Release Notes/Change History * Updated Pyrex support to work with Pyrex 0.9.6 and higher. + * Minor changes for Jython compatibility + 0.6c7 * Fixed ``distutils.filelist.findall()`` crashing on broken symlinks, and ``egg_info`` command failing on new, uncommitted SVN directories. diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 2e9007ce..bb1112c1 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -382,7 +382,7 @@ def analyze_egg(egg_dir, stubs): for flag,fn in safety_flags.items(): if os.path.exists(os.path.join(egg_dir,'EGG-INFO',fn)): return flag - + if not can_scan(): return False safe = True for base, dirs, files in walk_egg(egg_dir): for name in files: @@ -449,6 +449,47 @@ def iter_symbols(code): for name in iter_symbols(const): yield name +def can_scan(): + if not sys.platform.startswith('java') and sys.platform != 'cli': + # CPython, PyPy, etc. + return True + log.warn("Unable to analyze compiled code on this platform.") + log.warn("Please ask the author to include a 'zip_safe'" + " setting (either True or False) in the package's setup.py") + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # Attribute names of options for commands that might need to be convinced to # install to the egg build directory diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d0ce190e..da8434c2 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -608,10 +608,10 @@ Please make the appropriate changes for your system and try again. f = open(target,"w"+mode) f.write(contents) f.close() - try: - os.chmod(target,0755) - except (AttributeError, os.error): - pass + chmod(target,0755) + + + def install_eggs(self, spec, dist_filename, tmpdir): # .egg dirs or files are already built, so just return them @@ -988,18 +988,18 @@ See the setuptools documentation for the "develop" command for more info. def pf(src,dst): if dst.endswith('.py') and not src.startswith('EGG-INFO/'): to_compile.append(dst) - self.unpack_progress(src,dst); to_chmod.append(dst) + to_chmod.append(dst) + elif dst.endswith('.dll') or dst.endswith('.so'): + to_chmod.append(dst) + self.unpack_progress(src,dst) return not self.dry_run and dst or None unpack_archive(egg_path, destination, pf) self.byte_compile(to_compile) if not self.dry_run: - flags = stat.S_IXGRP|stat.S_IXGRP for f in to_chmod: - mode = ((os.stat(f)[stat.ST_MODE]) | 0555) & 07777 - log.debug("changing mode of %s to %o", f, mode) - os.chmod(f, mode) - + mode = ((os.stat(f)[stat.ST_MODE]) | 0555) & 07755 + chmod(f, mode) def byte_compile(self, to_compile): from distutils.util import byte_compile @@ -1435,7 +1435,7 @@ def get_script_header(script_text, executable=sys_executable, wininst=False): def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': - os.chmod(arg, stat.S_IWRITE) + chmod(arg, stat.S_IWRITE) return func(arg) exc = sys.exc_info() raise exc[0], (exc[1][0], exc[1][1] + (" %s %s" % (func,arg))) @@ -1530,18 +1530,18 @@ def is_python_script(script_text, filename): return False # Not any Python I can recognize +try: + from os import chmod as _chmod +except ImportError: + # Jython compatibility + def _chmod(*args): pass - - - - - - - - - - - +def chmod(path, mode): + log.debug("changing mode of %s to %o", path, mode) + try: + _chmod(path, mode) + except os.error, e: + log.debug("chmod failed: %s", e) diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 904704df..c2dc2d59 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -1,6 +1,6 @@ from distutils.command.install_scripts import install_scripts \ as _install_scripts -from easy_install import get_script_args, sys_executable +from easy_install import get_script_args, sys_executable, chmod from pkg_resources import Distribution, PathMetadata, ensure_directory import os from distutils import log @@ -50,10 +50,10 @@ class install_scripts(_install_scripts): f = open(target,"w"+mode) f.write(contents) f.close() - try: - os.chmod(target,0755) - except (AttributeError, os.error): - pass + chmod(target,0755) + + + diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index a2ca36ad..2d619a08 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -2,7 +2,7 @@ """ # More would be better! -import os, shutil, tempfile, unittest +import os, shutil, tempfile, unittest, urllib2 import pkg_resources import setuptools.package_index @@ -12,8 +12,8 @@ class TestPackageIndex(unittest.TestCase): index = setuptools.package_index.PackageIndex() url = 'http://127.0.0.1/nonesuch/test_package_index' try: - index.open_url(url) + v = index.open_url(url) except Exception, v: self.assert_(url in str(v)) else: - self.assert_(False) + self.assert_(isinstance(v,urllib2.HTTPError)) diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 1b15a9eb..1dc078ab 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -39,8 +39,6 @@ class DistroTests(TestCase): # But only 1 package self.assertEqual(list(ad), ['foopkg']) - - # Distributions sort by version self.assertEqual( [dist.version for dist in ad['FooPkg']], ['1.4','1.3-1','1.2'] @@ -255,14 +253,15 @@ class EntryPointTests(TestCase): else: raise AssertionError("Should've been bad", ep) def checkSubMap(self, m): - self.assertEqual(str(m), - "{'feature2': EntryPoint.parse(" - "'feature2 = another.module:SomeClass [extra1,extra2]'), " - "'feature3': EntryPoint.parse('feature3 = this.module [something]'), " - "'feature1': EntryPoint.parse(" - "'feature1 = somemodule:somefunction')}" - ) - + self.assertEqual(len(m), len(self.submap_expect)) + for key, ep in self.submap_expect.iteritems(): + self.assertEqual(repr(m.get(key)), repr(ep)) + + submap_expect = dict( + feature1=EntryPoint('feature1', 'somemodule', ['somefunction']), + feature2=EntryPoint('feature2', 'another.module', ['SomeClass'], ['extra1','extra2']), + feature3=EntryPoint('feature3', 'this.module', extras=['something']) + ) submap_str = """ # define features for blah blah feature1 = somemodule:somefunction @@ -286,7 +285,6 @@ class EntryPointTests(TestCase): self.assertRaises(ValueError, EntryPoint.parse_map, ["[xyz]", "[xyz]"]) self.assertRaises(ValueError, EntryPoint.parse_map, self.submap_str) - class RequirementsTests(TestCase): def testBasics(self): |