[Python-checkins] r60062 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools.txt setuptools/command/bdist_egg.py setuptools/command/easy_install.py setuptools/command/install_scripts.py setuptools/tests/test_packageindex.py setuptools/tests/test_resources.py
phillip.eby
python-checkins at python.org
Fri Jan 18 22:51:24 CET 2008
Author: phillip.eby
Date: Fri Jan 18 22:51:23 2008
New Revision: 60062
Modified:
sandbox/branches/setuptools-0.6/EasyInstall.txt
sandbox/branches/setuptools-0.6/setuptools.txt
sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py
sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py
sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py
sandbox/branches/setuptools-0.6/setuptools/tests/test_packageindex.py
sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py
Log:
chmod/test cleanups and Jython compatibility (backport from trunk)
Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/EasyInstall.txt (original)
+++ sandbox/branches/setuptools-0.6/EasyInstall.txt Fri Jan 18 22:51:23 2008
@@ -1241,6 +1241,10 @@
* 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.
Modified: sandbox/branches/setuptools-0.6/setuptools.txt
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools.txt (original)
+++ sandbox/branches/setuptools-0.6/setuptools.txt Fri Jan 18 22:51:23 2008
@@ -2618,6 +2618,8 @@
* 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.
Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Fri Jan 18 22:51:23 2008
@@ -382,7 +382,7 @@
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 @@
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
Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Fri Jan 18 22:51:23 2008
@@ -608,10 +608,10 @@
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 @@
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 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 @@
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)
Modified: sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/command/install_scripts.py Fri Jan 18 22:51:23 2008
@@ -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 @@
f = open(target,"w"+mode)
f.write(contents)
f.close()
- try:
- os.chmod(target,0755)
- except (AttributeError, os.error):
- pass
+ chmod(target,0755)
+
+
+
Modified: sandbox/branches/setuptools-0.6/setuptools/tests/test_packageindex.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/tests/test_packageindex.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/tests/test_packageindex.py Fri Jan 18 22:51:23 2008
@@ -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 @@
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))
Modified: sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py
==============================================================================
--- sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py (original)
+++ sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py Fri Jan 18 22:51:23 2008
@@ -39,8 +39,6 @@
# 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 @@
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 @@
self.assertRaises(ValueError, EntryPoint.parse_map, ["[xyz]", "[xyz]"])
self.assertRaises(ValueError, EntryPoint.parse_map, self.submap_str)
-
class RequirementsTests(TestCase):
def testBasics(self):
More information about the Python-checkins
mailing list