1. Tarek Ziadé
  2. distribute


Ronny Pfannschmidt  committed a233278 Merge

merge with upstream

  • Participants
  • Parent commits 8dcf337, f2eb0ea
  • Branches 0.6-maintenance

Comments (0)

Files changed (10)

File CHANGES.txt

View file
  • Ignore whitespace
 * Issue 15 and 48: Introduced a socket timeout of 15 seconds on url openings
 * Added indexsidebar.html into MANIFEST.in
 * Issue 108: Fixed TypeError with Python3.1
+* Issue 121: Fixed --help install command trying to actually install.
+* Issue 112: Added an os.makedirs so that Tarek's solution will work.
+* Issue 133: Added --no-find-links to easy_install


View file
  • Ignore whitespace
 * Jannis Leidel
 * Lennart Regebro
 * Martin von Löwis
+* Noufal Ibrahim
 * Philip Jenvey
 * Reinout van Rees
 * Tarek Ziadé

File README.txt

View file
  • Ignore whitespace
 Distribute is only released as a source distribution.
-It can be installed using easy_install or pip, and can be done so with the source
-tarball, the eggs distribution, or by using the ``distribute_setup.py`` script
-provided online.
+It can be installed using pip, and can be done so with the source tarball,
+or by using the ``distribute_setup.py`` script provided online.
 ``distribute_setup.py`` is the simplest and preferred way on all systems.
 Notice this file is also provided in the source release.
-easy_install or pip
 Run easy_install or pip::
-    $ easy_install -U distribute
     $ pip install distribute
-If you want to install the latest dev version, you can also run::
-    $ easy_install -U distribute==dev
-This will get the latest development version at: http://bitbucket.org/tarek/distribute/get/0.6-maintenance.zip#egg=distribute-dev
 Source installation
 Distribute can be removed like this:
-- run ``easy_install -m Distribute``. This will remove the Distribute reference
-  from ``easy-install.pth``. Otherwise, edit the file and remove it yourself.
 - remove the ``distribute*.egg`` file located in your site-packages directory
 - remove the ``setuptools.pth`` file located in you site-packages directory
 - remove the easy_install script located in you ``sys.prefix/bin`` directory

File docs/easy_install.txt

View file
  • Ignore whitespace
     package not being available locally, or due to the use of the ``--update``
     or ``-U`` option.
+``--no-find-links`` Blocks the addition of any link. (New in Distribute 0.6.11)
+    This is useful if you want to avoid adding links defined in a project
+    easy_install is installing (wether it's a requested project or a
+    dependency.). When used, ``--find-links`` is ignored.
 ``--delete-conflicting, -D`` (Removed in 0.6a11)
     (As of 0.6a11, this option is no longer necessary; please do not use it!)

File setup.py

View file
  • Ignore whitespace
         # Installed by buildout, don't mess with a global setuptools.
         return False
     # easy_install marker
-    return 'install' in sys.argv[1:] or _easy_install_marker()
+    if "--help" in sys.argv[1:] or "-h" in sys.argv[1:]: # Don't bother doing anything if they're just asking for help
+        return False
+    return  'install' in sys.argv[1:] or _easy_install_marker()
 if _being_installed():
     from distribute_setup import _before_install

File setuptools/__init__.py

View file
  • Ignore whitespace
 # a distribution with the same version.
 # The distribute_setup script for instance, will check if this
-# attribute is present to decide wether to reinstall the package
+# attribute is present to decide whether to reinstall the package
+# or not.
 _distribute = True
 bootstrap_install_from = None

File setuptools/command/easy_install.py

View file
  • Ignore whitespace
 packages.  For detailed documentation, see the accompanying EasyInstall.txt
 file, or visit the `EasyInstall home page`__.
-__ http://peak.telecommunity.com/DevCenter/EasyInstall
+__ http://packages.python.org/distribute/easy_install.html
 import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random
 from glob import glob
         ('allow-hosts=', 'H', "pattern(s) that hostnames must match"),
         ('local-snapshots-ok', 'l', "allow building eggs from local checkouts"),
         ('version', None, "print version information and exit"),
+        ('no-find-links', None,
+         "Don't load find-links defined in packages being installed")
     boolean_options = [
         'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
         self.install_platbase = None
         self.install_userbase = site.USER_BASE
         self.install_usersite = site.USER_SITE
+        self.no_find_links = None
         # Options not specifiable via command line
         self.package_index = None
         if self.script_dir is None:
             self.script_dir = self.install_dir
+        if self.no_find_links is None:
+            self.no_find_links = False
         # Let install_dir get set by install_lib command, which in turn
         # gets its info from the install command, and takes into account
         # --prefix and --home and all that other crud.
             self.find_links = []
         if self.local_snapshots_ok:
-        self.package_index.add_find_links(self.find_links)
+        if not self.no_find_links:
+            self.package_index.add_find_links(self.find_links)
         self.set_undefined_options('install_lib', ('optimize','optimize'))
         if not isinstance(self.optimize,int):
                             'install_scripts', 'install_data',])
     def run(self):
-        if self.verbose<>self.distribution.verbose:
+        if self.verbose != self.distribution.verbose:
             for spec in self.args:
 For information on other options, you may wish to consult the
 documentation at:
-  http://peak.telecommunity.com/EasyInstall.html
+  http://packages.python.org/distribute/easy_install.html
 Please make the appropriate changes for your system and try again.
         ok_exists = os.path.exists(ok_file)
             if ok_exists: os.unlink(ok_file)
+            os.makedirs(os.path.dirname(ok_file))
             f = open(pth_file,'w')
         except (OSError,IOError):
         self.installed_projects[dist.key] = dist
         log.info(self.installation_report(requirement, dist, *info))
-        if dist.has_metadata('dependency_links.txt'):
+        if (dist.has_metadata('dependency_links.txt') and
+            not self.no_find_links):
 * You can set up the installation directory to support ".pth" files by
   using one of the approaches described here:
-  http://peak.telecommunity.com/EasyInstall.html#custom-installation-locations
+  http://packages.python.org/distribute/easy_install.html#custom-installation-locations
 Please make the appropriate changes for your system and try again.""" % (
         self.install_dir, os.environ.get('PYTHONPATH','')

File setuptools/sandbox.py

View file
  • Ignore whitespace
 _EXCEPTIONS = [os.devnull,]
+	gen_py = os.path.dirname(__import__('win32com.gen_py', fromlist=['__name__']).__file__)
+	_EXCEPTIONS.append(gen_py)
+except ImportError:
+	pass
 class DirectorySandbox(AbstractSandbox):
     """Restrict operations to a single subdirectory - pseudo-chroot"""
     def __init__(self, sandbox, exceptions=_EXCEPTIONS):
         self._sandbox = os.path.normcase(os.path.realpath(sandbox))
         self._prefix = os.path.join(self._sandbox,'')
-        self._exceptions = exceptions
+        self._exceptions = [os.path.normcase(os.path.realpath(path)) for path in exceptions]
     def _violation(self, operation, *args, **kw):
             self._active = False
             realpath = os.path.normcase(os.path.realpath(path))
-            if (realpath in self._exceptions or realpath == self._sandbox
+            if (self._exempted(realpath) or realpath == self._sandbox
                 or realpath.startswith(self._prefix)):
                 return True
             self._active = active
+    def _exempted(self, filepath):
+        exception_matches = map(filepath.startswith, self._exceptions)
+        return any(exception_matches)
     def _remap_input(self,operation,path,*args,**kw):
         """Called for path inputs"""
         if operation in self.write_ops and not self._ok(path):

File setuptools/tests/test_easy_install.py

View file
  • Ignore whitespace
+    def test_no_find_links(self):
+        # new option '--no-find-links', that blocks find-links added at
+        # the project level
+        dist = Distribution()
+        cmd = easy_install(dist)
+        cmd.check_pth_processing = lambda : True
+        cmd.no_find_links = True
+        cmd.find_links = ['link1', 'link2']
+        cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok')
+        cmd.args = ['ok']
+        cmd.ensure_finalized()
+        self.assertEquals(cmd.package_index.scanned_urls, {})
+        # let's try without it (default behavior)
+        cmd = easy_install(dist)
+        cmd.check_pth_processing = lambda : True
+        cmd.find_links = ['link1', 'link2']
+        cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok')
+        cmd.args = ['ok']
+        cmd.ensure_finalized()
+        keys = cmd.package_index.scanned_urls.keys()
+        keys.sort()
+        self.assertEquals(keys, ['link1', 'link2'])
 class TestPTHFileWriter(unittest.TestCase):
     def test_add_from_cwd_site_sets_dirty(self):
         '''a pth file manager should set dirty 
 class TestUserInstallTest(unittest.TestCase):
     def setUp(self):

File setuptools/tests/test_sandbox.py

View file
  • Ignore whitespace
 import unittest
 import tempfile
-from setuptools.sandbox import DirectorySandbox
+from setuptools.sandbox import DirectorySandbox, SandboxViolation
+def has_win32com():
+    """
+    Run this to determine if the local machine has win32com, and if it
+    does, include additional tests.
+    """
+    if not sys.platform.startswith('win32'):
+        return False
+    try:
+        mod = __import__('win32com')
+    except ImportError:
+        return False
+    return True
 class TestSandbox(unittest.TestCase):
     def test_devnull(self):
         sandbox = DirectorySandbox(self.dir)
+        sandbox.run(self._file_writer(os.devnull))
-        def _write():
-            f = open(os.devnull, 'w')
+    @staticmethod
+    def _file_writer(path):
+        def do_write():
+            f = open(path, 'w')
+        return do_write
-        sandbox.run(_write)
+    if has_win32com():
+        def test_win32com(self):
+            """
+            win32com should not be prevented from caching COM interfaces
+            in gen_py.
+            """
+            import win32com
+            gen_py = win32com.__gen_path__
+            target = os.path.join(gen_py, 'test_write')
+            sandbox = DirectorySandbox(self.dir)
+            try:
+                sandbox.run(self._file_writer(target))
+            except SandboxViolation:
+                self.fail("Could not create gen_py file due to SandboxViolation")
+            finally:
+                if os.path.exists(target): os.remove(target)
+if __name__ == '__main__':
+    unittest.main()